private IMigrationBatch FetchMigrationsTo(ContainerConfiguration containerConfiguration, long timestamp) { IVersioning versioning = InitializeVersioning(containerConfiguration); IDictionary <string, IMigrationTimestampProvider> timestampProviders = InitializeTimestampProviders(containerConfiguration); var importer = new MigrationImporter(containerConfiguration, timestampProviders); var batchPreparer = new MigrationBatchPreparer(importer, versioning, Configuration); return(batchPreparer.Prepare(timestamp, _options)); }
public void TestCases(IEnumerable <IMigrationMetadata> importedMigrations, IEnumerable <IAggregateMigrationMetadata> importedAggregateMigrations, IEnumerable <IMigrationMetadata> executedMigrations, IMigrationStepMetadata[] expectedSteps) { var importer = A.Fake <IMigrationImporter>(); var versioning = A.Fake <IVersioning>(); IReadOnlyCollection <ImportedMigration> ignoredMigrations; IReadOnlyCollection <ImportedAggregateMigration> ignoredAggregateMigrations; A.CallTo(() => importer.ImportAll(out ignoredMigrations, out ignoredAggregateMigrations)).AssignsOutAndRefParameters( importedMigrations.Select(m => new ImportedMigration(A.Fake <IMigration>(), m, false)).ToList(), importedAggregateMigrations.Select(m => new ImportedAggregateMigration(A.Fake <IMigration>(), m)).ToList()); A.CallTo(() => versioning.ExecutedMigrations).Returns(executedMigrations); MigrationBatchPreparer preparer = new MigrationBatchPreparer(importer, versioning, A.Fake <IRuntimeConfiguration>()); var batch = preparer.Prepare(long.MaxValue, new MigrationOptions()); Assert.AreEqual(expectedSteps.Length, batch.Steps.Count, "Unexpected count of steps."); for (int i = 0; i < batch.Steps.Count; i++) { CollectionAssert.AreEqual(expectedSteps[i].Migrations.Select(GetMigrationDescription).ToArray(), batch.Steps[i].Migrations.Select(GetMigrationDescription).ToArray(), "Unexpected migrations in step {0}.", i); } }