private DatabaseChangeSet TryMergingAndCompare(FileInfo migration, string baseDbWithNoMigrations, ICollection<string> migrationsToRun, string dbTempDirPath)
        {
            string dbPlusMigration = null, dbWithMigrationMerged = null;
            DatabaseChangeSet changes = null;
            try {
                if (Directory.Exists(dbTempDirPath))
                {
                    Directory.Delete(dbTempDirPath, true);
                }
                var dbTempDir = Directory.CreateDirectory(dbTempDirPath);
                Folders.CopyDirectory(_dbPath.FullName, dbTempDir.FullName);
                Console.WriteLine(dbTempDir.FullName);

                var lonelyCreator = new DisposableDbManager(_dbCreationPath, _disposableDbServer, DbName, dbTempDir.FullName);
                lonelyCreator.AllowCreatingSameDb = true;

                dbPlusMigration = lonelyCreator.CreateCompleteDisposableDbWithMigrations(migrationsToRun);
                DatabaseChangeSet changesFromMigration =
                    DbComparer.CompareDatabases(_disposableDbServer.Databases[baseDbWithNoMigrations],
                                                _disposableDbServer.Databases[dbPlusMigration]);

                DbScriptFolderManager.UpdateScripts(dbTempDir.FullName, changesFromMigration, migration);

                dbWithMigrationMerged = lonelyCreator.CreateCompleteDisposableDbWithMigrations(new string[0]);
                changes = DbComparer.CompareDatabases(_disposableDbServer.Databases[dbPlusMigration], _disposableDbServer.Databases[dbWithMigrationMerged],
                                                      DatabaseComparisonTests.DefaultSanitizeForComparison);
            } finally {
                Cleanup(dbPlusMigration, dbWithMigrationMerged);
            }

            return changes;
        }
        public void CheckThatDisposableDbCreationStillWorksAfterApplyingEachMigration()
        {
            _dbCreationPath = ConfigurationManager.AppSettings["DbCreationPath"];
            _disposableDbServer = DatabaseCreationTests.GetDisposableDbServer();

            var creator = new DisposableDbManager(_dbCreationPath, _disposableDbServer, DbName);
            creator.AllowCreatingSameDb = true;

            var baseDbWithNoMigrations = creator.CreateCompleteDisposableDbWithMigrations(new string[0]);

            _dbPath = DisposableDbManager.FindDatabaseScriptsPath(DbName);
            IEnumerable<FileInfo> migrations = new MigrationManager().GetSqlSriptsIn(_dbPath.FullName);

            var migrationsAlreadyTested = new List<string>();

            foreach (var migration in migrations)
            {
                TestMigration(migration, migrationsAlreadyTested, baseDbWithNoMigrations);
                migrationsAlreadyTested.Add(Path.GetFileNameWithoutExtension(migration.FullName));
            }
        }