Galen.Ci.EntityFramework.Tests.DbDeploymentManagerIntegrationTests.CorrectlyMigratesDownwardPastInitialMigration C# (CSharp) Method

CorrectlyMigratesDownwardPastInitialMigration() private method

private CorrectlyMigratesDownwardPastInitialMigration ( ) : void
return void
		public void CorrectlyMigratesDownwardPastInitialMigration()
		{
			string serverName = @"(localdb)\mssqllocaldb";
			string databaseName = $"GalenTest_{Guid.NewGuid():N}";
			string deployedAssemblyPath = TestUtils.BuildTestAssemblyPath(3);

			var assemblyLoader = new AssemblyLoader();
			TestUtils.InitializeDatabase(assemblyLoader, deployedAssemblyPath, "Pinpoint.Test.Data.TestContext", serverName, databaseName);
			TestUtils.InitializeDatabase(assemblyLoader, deployedAssemblyPath, "Pinpoint.Test.Data.AnotherTestContext", serverName, databaseName);

			//Migration v3 to v1
			var config = new DbDeploymentManagerConfiguration()
			{
				TargetAssemblyPath=TestUtils.BuildTestAssemblyPath(1),
				DeployedAssemblyOverridePath=deployedAssemblyPath,      // we didn't initialize using the deployer so this is required
				Database=new DatabaseEndpoint { ServerName=serverName, DatabaseName=databaseName },
				MigrationConfig=new MigrationConfigurationInfo
				{
				    Type = "Pinpoint.Test.Data.AnotherTestContextMigrations.Configuration"
				}
			};

			try
			{
				var sut = new DbDeploymentManager(config, assemblyLoader, new SqlClientDbConnectionInfoBuilder());
				sut.Deploy();

			    Assert.AreEqual(1,
			        TestUtils.GetDeploymentHistoryRowCount(serverName, databaseName, config.MigrationConfig.Type));

                //We expect all schema related to AnotherTestContext would be deleted
                var migrationHistory = TestUtils.GetMigrationHistory(serverName, databaseName, config.MigrationConfig.Type);

				Assert.IsNotNull(migrationHistory);
				Assert.AreEqual(0, migrationHistory.Count());
			}
			finally
			{
				//Be sure to clean up
				TestUtils.DropDatabase(config.Database.ServerName, config.Database.DatabaseName);
			}
		}