public void CorrectlyMigratesUpward()
{
string serverName = @"(localdb)\mssqllocaldb";
string databaseName = $"GalenTest_{Guid.NewGuid():N}";
string deployedAssemblyPath = TestUtils.BuildTestAssemblyPath(2);
var expectedMigrationHistory = new[]
{
"201404181533201_InitialCreate",
"201404181719410_AddedAddresInfoToCustomer",
"201404181726158_MoveAddressInformationIntoContactInfo",
"201404181729406_AddedRowVersionToDomainObjectBase",
"201404181740359_AddedMultiplePropertiesToCustomer",
};
var assemblyLoader = new AssemblyLoader();
TestUtils.InitializeDatabase(assemblyLoader, deployedAssemblyPath, "Pinpoint.Test.Data.TestContext", serverName, databaseName);
//Migration v2 to v3
var config = new DbDeploymentManagerConfiguration()
{
TargetAssemblyPath = TestUtils.BuildTestAssemblyPath(3),
Database = new DatabaseEndpoint {
ServerName = serverName, DatabaseName = databaseName
},
MigrationConfig = new MigrationConfigurationInfo
{
Type = "Pinpoint.Test.Data.Migrations.Configuration"
}
};
try
{
var sut = new DbDeploymentManager(config, assemblyLoader, new SqlClientDbConnectionInfoBuilder());
sut.Deploy();
Assert.AreEqual(1,
TestUtils.GetDeploymentHistoryRowCount(serverName, databaseName, config.MigrationConfig.Type));
var migrationHistory = TestUtils.GetMigrationHistory(serverName, databaseName, config.MigrationConfig.Type);
Assert.IsNotNull(migrationHistory);
Assert.AreEqual(expectedMigrationHistory.Length, migrationHistory.Count());
Assert.IsTrue(expectedMigrationHistory.SequenceEqual(migrationHistory));
}
finally
{
//Be sure to clean up
TestUtils.DropDatabase(config.Database.ServerName, config.Database.DatabaseName);
}
}