This tool provides LocalDb database setup for running integration tests with tools such as Entity Framework.
To use this tool as part of continuous integration, the build agent must also support LocalDb, which can be provided by Visual Studio Team Services hosted build agents.
// using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestSetup
{
private static IDbIntegrationTestSetup DbIntegrationTestSetup;
[AssemblyInitialize]
public static void TestInit(TestContext testContext)
{
DbIntegrationTestSetup = new LocalDbIntegrationTestSetup()
.SetDatabaseName("IntegrationTestTools_IntegrationTest")
.Startup(() =>
{
// note can run migrations here
});
}
[AssemblyCleanup]
public static void TestCleanup()
{
DbIntegrationTestSetup.Shutdown();
}
}