public async Task DoesRunMigrationIfFailToGetVersionDocument() { var updatedVersionDocs = new Dictionary <DateTime, bool>(); var updatedMigrationDocs = new List <MigrationDetails>(); var migration = new _0001_TestMigrationFirst(); var mockRepo = new CosmosRepositoryBuilder() .WithUpsertCallback(e => updatedMigrationDocs.Add(e as MigrationDetails)) .WithReadingVersionDocument(null, true) .WithUpdatingVersionDocument((number, isRunning) => updatedVersionDocs.Add(DateTime.UtcNow, isRunning)) .Mock; migration.ExectuteMigration(mockRepo.Object, 1); Assert.True(updatedVersionDocs.Count > 0, "called to update version docs"); Assert.True(updatedMigrationDocs.Count > 0, "called to update migration docs"); }
public async Task DoesNotRunMigrationIfOneAlreadyRunning() { var updatedVersionDocs = new Dictionary <DateTime, bool>(); var updatedMigrationDocs = new List <MigrationDetails>(); var migration = new _0001_TestMigrationFirst(); var mockRepo = new CosmosRepositoryBuilder() .WithUpsertCallback(e => updatedMigrationDocs.Add(e as MigrationDetails)) .WithReadingVersionDocument(new VersionDocument() { IsApplyingMigration = true }) .WithUpdatingVersionDocument((number, isRunning) => updatedVersionDocs.Add(DateTime.UtcNow, isRunning)) .Mock; Assert.ThrowsAsync <OnGoingMigrationException>( () => migration.ExectuteMigration(mockRepo.Object, 1)); Assert.True(updatedVersionDocs.Count == 0); Assert.True(updatedMigrationDocs.Count == 0); }