public async Task DeleteRemovesSpecificReadModel() { // Arrange var id1 = ThingyId.New; var id2 = ThingyId.New; await PublishPingCommandAsync(id1).ConfigureAwait(false); await PublishPingCommandAsync(id2).ConfigureAwait(false); var readModel1 = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id1)).ConfigureAwait(false); var readModel2 = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id2)).ConfigureAwait(false); readModel1.Should().NotBeNull(); readModel2.Should().NotBeNull(); // Act await ReadModelPopulator.DeleteAsync( id1.Value, ReadModelType, CancellationToken.None) .ConfigureAwait(false); // Assert readModel1 = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id1)).ConfigureAwait(false); readModel2 = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id2)).ConfigureAwait(false); readModel1.Should().BeNull(); readModel2.Should().NotBeNull(); }
public async Task RePopulateHandlesDeletedAggregate() { // Arrange var id1 = ThingyId.New; var id2 = ThingyId.New; await PublishPingCommandsAsync(id1, 3).ConfigureAwait(false); await PublishPingCommandsAsync(id2, 5).ConfigureAwait(false); // Act await ReadModelPopulator.DeleteAsync(id2.Value, ReadModelType, CancellationToken.None).ConfigureAwait(false); await ReadModelPopulator.PopulateAsync(ReadModelType, CancellationToken.None).ConfigureAwait(false); // Assert var readModel = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id2)).ConfigureAwait(false); readModel.PingsReceived.Should().Be(5); }