public async Task ExceptionThrownIfSecondUpdateDocumentFailureAndMigrationFails()
        {
            Mock.Setup(x => x.UpsertDocumentAsync(It.IsAny <object>()))
            .Returns(Task.FromResult(new Exception()));

            var migration = new FailureMigration(true);

            Assert.ThrowsAnyAsync <Exception>(() => migration.ExectuteMigration(Mock.Object, 1));
        }
        public async Task DoesUpdateVersionDocumentWhenMigrationFailed()
        {
            var updatedVersionDocs   = new Dictionary <DateTime, bool>();
            var updatedMigrationDocs = new List <MigrationDetails>();

            var migration = new FailureMigration(true);
            var mockRepo  = new CosmosRepositoryBuilder()
                            .WithUpsertCallback(e => updatedMigrationDocs.Add(e as MigrationDetails))
                            .WithReadingVersionDocument()
                            .WithUpdatingVersionDocument((number, isRunning) => updatedVersionDocs.Add(DateTime.UtcNow, isRunning))
                            .Mock;

            await migration.ExectuteMigration(mockRepo.Object, 1);

            Assert.True(updatedVersionDocs.Count == 2);
            Assert.True(updatedVersionDocs.Last().Value,
                        "the version document was updated for is running to be false");
            Assert.True(updatedMigrationDocs.Count == 2);
            Assert.False(updatedMigrationDocs.Last().DidSucceed, "expected did succeed to be set to false");
            Assert.NotNull(updatedMigrationDocs.Last().FailureMessage);
        }