public void TestCustomBootstrapping() { // use a Module selection to verify that the bootstrapping is still considering *all* migrations _options.ModuleSelector = moduleName => moduleName == Migration2.Module; Migrator migrator = new Migrator(ConnectionString, ProviderName, _options); IBootstrapper bootstrapper = MockRepository.GenerateStrictMock <IBootstrapper>(); bootstrapper.Expect(b => b.BeginBootstrapping(null, null)).IgnoreArguments(); for (int i = 0; i < Migrations.Count; i++) // assume that all migrations were already performed { long timestamp = Timestamps[i]; bootstrapper.Expect(b => b.IsContained(Arg <IMigrationMetadata> .Matches(m => m.Timestamp == timestamp))).Return(true); } bootstrapper.Expect(b => b.EndBootstrapping(null, null)).IgnoreArguments(); migrator.UseCustomBootstrapping(bootstrapper); IMigrationBatch batch = migrator.FetchMigrations(typeof(Migration1).Assembly); CollectionAssert.IsEmpty(batch.ScheduledMigrations, "All migrations should be viewed as already run."); CollectionAssert.IsEmpty(batch.UnidentifiedMigrations, "There should be no unidentified migrations."); batch.Execute(); // should have no effect as no migrations are scheduled migrator.MigrateAll(typeof(Migration1).Assembly); // should have no effect as no migrations are scheduled // assert Migration1 table was *not* created DataTable table = GetTable(new Migration1().Tables[0].Name); Assert.IsNull(table); // assert Versioning table has necessary entries DataTable versioningTable = GetTable(_options.VersioningTableName); Assert.AreEqual(Migrations.Count, versioningTable.Rows.Count, "The versioning table is missing entries."); bootstrapper.VerifyAllExpectations(); }