Persistence unit tests. How to wait until all events are saved to journal? #7094
Unanswered
AlexeyRokhin
asked this question in
Q&A
Replies: 1 comment 1 reply
-
@AlexeyRokhin Would using AwaitAssert(() => Assert.Equal(3, this.writeInterceptor.Messages.Count)); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi.
I'm creating unit tests to test persistence and recovery. To collect saved and recovered messages I'm using a JournalInterceptor that stores the persistence events in the
List<IPersistentRepresentation> Messages
property.So, I send a message to the actor using the following code:
Then I try to validate the number of persistence messages and the messages themselves:
And
Assert.Equal
fails becausethis.writeInterceptor.Messages.Count
actually equals to1
.When I add
await Task.Delay(100)
before the validation, then it succeeds.Then I stop the current actor and create a new one with the same
PersistenceId
. And I get the same issue withrecoveryInterceptor
.Without
await Task.Delay(100)
itsMessages
collection is empty.Is there any way to fix the issues without using
Task.Delay
?Beta Was this translation helpful? Give feedback.
All reactions