WinPhone, CaliburnMicro, and Sqlite

Where is TDD in WP dev?

Simple class can be tested in SilverLight.NUint project, (must modify guid to make it look as WP project), but most WP classes are not TDD friendly, e.g., IsolatedStorageFile (another MS no-interface sealed class), how can we make IsolatedStorageFile.GetUserStoreForApplication() run in non-WP environment?  So shameful doing F5 for testing every single code change.

Tried to switch to Sqlite on WP7 project, same issue, can’t run in out of simulator, but, sqlite is much popular, it’s also supported in iPhone, while Apple suggests developer go to core-data.

Anther bad news, no NHibernate for Sqlite on WP yet.

Powerful Caliburn.Micro

Convention binding in CaliburnMicro is amazing, cal:AppBarButton can be easily hooked up to the method with then same name as the message sent by button.

Url get parameter auto-wiring works like a charm in those decedents from Screen base class. Wiring won’t be ready in ctor, must wait in OnInitialize.

Navigation service is handy, but View-based style binding still looks awful to me, passing object instead of values to the new opened view/viewmodel is very difficult, I had to back to evil global/static class to pass object around, ugly, but very easy to use.

OnViewLoaded method is great, a perfect place to hook up event handle to view.

‘Unrecognized char’ issue in sqlite

Got this issue when trying insert string using sqlite_execute, suggestion is to use sqlite3_prepare/bind_text/step/reset instead.

string sql = string.Format("INSERT INTO my_table (id, title, summary ) VALUES({0},?,?);",

Sqlite3.Vdbe stmt = null;

_rc = Sqlite3.sqlite3_prepare_v2(_db, sql, -1, ref stmt, Sqlite3.SQLITE_NULL);
if (_rc != Sqlite3.SQLITE_OK) { throw new SqliteException(Sqlite3.sqlite3_errmsg(_db) ); }

_rc = Sqlite3.sqlite3_bind_text(stmt, 1,  Title, -1, Sqlite3.SQLITE_STATIC);
if (_rc != Sqlite3.SQLITE_OK) { throw new SqliteException(Sqlite3.sqlite3_errmsg(_db)); }

_rc = Sqlite3.sqlite3_bind_text(stmt, 2,  Summary, -1, Sqlite3.SQLITE_STATIC);
if (_rc != Sqlite3.SQLITE_OK) { throw new SqliteException(Sqlite3.sqlite3_errmsg(_db)); }

_rc = Sqlite3.sqlite3_step(stmt);
if (_rc != Sqlite3.SQLITE_DONE) { throw new SqliteException(Sqlite3.sqlite3_errmsg(_db)); }

_rc = Sqlite3.sqlite3_reset(stmt);
if (_rc != Sqlite3.SQLITE_OK) { throw new SqliteException(Sqlite3.sqlite3_errmsg(_db)); }

It’s strange that sqlite3_step returns 101 instead of 0.


One thought on “WinPhone, CaliburnMicro, and Sqlite

  1. Even though you don’t have NHibernate on Sqlite on WP7, you might be interested in a non-relational database. I’ve created a database for WP7 that has object mapping built-in. It’s called Correspondence. I’ve written a quick intro at

    Correspondence has four project templates:
    * Model
    * View Model
    * Unit Test
    * Application

    For the unit test project template, I use the Silverlight Unit Testing framework at You have to install that separately. It has some frustrating shortcomings, but it’s better than nothing.

    Correspondence is in beta, but I’m using it to build my WP7 applications right now. Once I release a couple and work out the kinks, I’ll call it stable. I’d love to get your feedback.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s