public void CanMigrate_Always_GetsFactoryAndInitializes() { using (_mocks.Record()) { SetupResult.For(_migrationFactoryChooser.ChooseFactory(_steps[string.Empty][0].MigrationReference)).Return(_migrationFactory); SetupResult.For(_migrationFactoryChooser.ChooseFactory(_steps[string.Empty][1].MigrationReference)).Return(_migrationFactory); SetupResult.For(_migrationFactory.CreateMigration(_steps[string.Empty][0].MigrationReference)).Return(_migration1); SetupResult.For(_migrationFactory.CreateMigration(_steps[string.Empty][1].MigrationReference)).Return(_migration2); _migrationInitializer.InitializeMigration(_migration1); _migrationInitializer.InitializeMigration(_migration2); } _target.CanMigrate(_steps); _mocks.VerifyAll(); Assert.AreEqual(_migration1, _steps[string.Empty][0].DatabaseMigration); Assert.AreEqual(_migration2, _steps[string.Empty][1].DatabaseMigration); }
public bool CanMigrate(IDictionary <string, List <MigrationStep> > steps) { foreach (MigrationStep step in steps.SelectMany(row => row.Value).OrderBy(row => row.Version)) { MigrationReference migrationReference = step.MigrationReference; IMigrationFactory migrationFactory = _migrationFactoryChooser.ChooseFactory(migrationReference); IDatabaseMigration migration = migrationFactory.CreateMigration(migrationReference); step.DatabaseMigration = migration; _migrationInitializer.InitializeMigration(migration); } _log.Info("All migrations are initialized."); return(true); }