From 18d8fda181c489ca4395cba3000f8c4470d0cd44 Mon Sep 17 00:00:00 2001 From: Kladzey Date: Wed, 16 Jun 2021 11:46:42 +0300 Subject: [PATCH] Fix InMemoryReadStore.UpdateAsync break --- RELEASE_NOTES.md | 1 + .../Suites/TestSuiteForReadModelStore.cs | 19 +++++++++++++++++++ .../ReadStores/InMemory/InMemoryReadStore.cs | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 1d5982996..f3be87178 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,6 +1,7 @@ ### New in 0.82 (not released yet) * Fix: Source IDs are now added to snapshots +* Fix: InMemoryReadStore will not break on unmodified update result ### New in 0.81.4483 (released 2020-12-14) diff --git a/Source/EventFlow.TestHelpers/Suites/TestSuiteForReadModelStore.cs b/Source/EventFlow.TestHelpers/Suites/TestSuiteForReadModelStore.cs index ecaaabf20..6826a70b6 100644 --- a/Source/EventFlow.TestHelpers/Suites/TestSuiteForReadModelStore.cs +++ b/Source/EventFlow.TestHelpers/Suites/TestSuiteForReadModelStore.cs @@ -202,6 +202,25 @@ public async Task RePopulateHandlesManyAggregates() readModel1.PingsReceived.Should().Be(3); readModel2.PingsReceived.Should().Be(5); } + + [Test] + 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); + } [Test] public async Task PopulateCreatesReadModels() diff --git a/Source/EventFlow/ReadStores/InMemory/InMemoryReadStore.cs b/Source/EventFlow/ReadStores/InMemory/InMemoryReadStore.cs index b8efc4d2d..79f37eb25 100644 --- a/Source/EventFlow/ReadStores/InMemory/InMemoryReadStore.cs +++ b/Source/EventFlow/ReadStores/InMemory/InMemoryReadStore.cs @@ -116,7 +116,7 @@ public override async Task UpdateAsync(IReadOnlyCollection read .ConfigureAwait(false); if (!readModelUpdateResult.IsModified) { - return; + continue; } readModelEnvelope = readModelUpdateResult.Envelope;