public async Task CreatedActivitiesShouldAppearInBothElasticAndCosmos(int activitiesToCreate) { var fixtures = new IntegrityCheckTestFixtures(); await fixtures.CreateActivities(activitiesToCreate); var tasks = new [] { fixtures.AssertAllCreatedActivitiesAppearInCosmos(), fixtures.AssertAllCreatedActivitiesAppearInElastic() }; await Task.WhenAll(tasks); }
public async Task ActivitiesMissingInBothSidesShouldEchoBothWays(int totalActivitiesRequired, int activitiesToRemoveFromCosmos, int activitiesToRemoveFromElastic) { // arrange var fixtures = new IntegrityCheckTestFixtures(); await fixtures.DeleteAllExistingActivitiesFromElasticAndCosmos(); await fixtures.CreateActivities(totalActivitiesRequired); var randomActivities = fixtures.GetRandomPostedActivities(activitiesToRemoveFromCosmos + activitiesToRemoveFromElastic); var cosmosDeleted = randomActivities.Take(activitiesToRemoveFromCosmos).ToArray(); var elasticDeleted = randomActivities.Skip(activitiesToRemoveFromCosmos).Take(activitiesToRemoveFromElastic).ToArray(); var deleteTasks = new Task[] { fixtures.DeleteActivitiesFromCosmos(cosmosDeleted), fixtures.DeleteActivitiesFromElastic(elasticDeleted) }; Task.WaitAll(deleteTasks); // Action var logger = await fixtures.RunIntegrityCheck($"_{totalActivitiesRequired}.{activitiesToRemoveFromCosmos}"); fixtures.CancellationTokenSource.Cancel(); // Assert await fixtures.AssertAllCreatedActivitiesAppearInCosmos(); await fixtures.AssertAllCreatedActivitiesAppearInElastic(); int expectedNumberOfFixes = activitiesToRemoveFromCosmos + activitiesToRemoveFromElastic; int actualNumberOfFixes = logger.FixesApplied; Assert.AreEqual(expectedNumberOfFixes, actualNumberOfFixes, "Incorrect number of fixes applied"); }
public async Task ActivitiesMissingInElasticShouldNotCauseThoseActivitiesToBeRemovedFromCosmos() { // arrange var fixtures = new IntegrityCheckTestFixtures(); var deleteTasks = new Task[] { fixtures.DeleteAllActivitiesFromCosmos(), fixtures.DeleteAllActivitiesFromElastic() }; await Task.WhenAll(deleteTasks); await fixtures.CreateActivities(50); var randomActivities = fixtures.GetRandomPostedActivities(10); await fixtures.DeleteActivitiesFromCosmos(randomActivities); // Act await fixtures.RunIntegrityCheck(null); // Assert await fixtures.AssertAllCreatedActivitiesAppearInElastic(); }