In C#/nHibernate-projects I am using SQLite to unit test my code, aproximately using the method described here: http://ift.tt/1q8TEN7.
However, I find that building and configuring the in-memory database typically takes about 150ms. I have lots of unit test so this rapidly adds up.
I want to build and configure the database once, store it in a static variable, and copy it every time a unit test needs a database.
How do I back-up an in-memory database?
I first tried to create a named in-memory database. According to http://ift.tt/1z1GqHh this is possible. However, if I change my current connection string, I invariably recieve errors about it not having the correct format. This is my current connection string:
private const string ConnectionString = "Data Source=:memory:;Version=3;";
Connection strings I tried are:
private const string ConnectionString = "Data Source=memdb1?mode=memory&cache=shared;Version=3;";
private const string ConnectionString = "Data Source=file:memdb1?mode=memory&cache=shared;Version=3;";
private const string ConnectionString = "Data Source=memdb1?mode=memory";
private const string ConnectionString = "Data Source=memdb1&mode=memory";
But even if I succeed in creating two in-memory databases, how do I quickly copy content from one to another?
Aucun commentaire:
Enregistrer un commentaire