I am writing integration tests for an application and have not been able to find any best practices on how to set up a test database for my integration suite. I am working o
Just setup a connection string in the app.config of your unit test project that points to the new DB instance.
You can then use the initialisation and cleanup methods in your test class to create and delete the DB.
The connection string is just the usual, e.g.
Then to create the DB, once per test, you could do:
YourContext _ctx;
[TestInitialize]
public void Initiaslise()
{
YourNameDbInitialise initialiser = new YourNameDbInitialiseForTest();
Database.SetInitializer(initialiser);
_ctx = new YourNameContext();
initialiser.InitializeDatabase(_ctx);
}
and this to delete at the end of each test
[TestCleanup]
public void Cleanup()
{
Database.Delete("YourName");
}