I'm having a super weird issue when using FakeItEasy in my unit tests...
I'm asserting whether a call has been made to a mock and I specify a constraint on one of the method's parameter, something like:
A.CallTo(() => fakeStorageClient.StoreAsync("commands", A<CommandEnvelope<FakeCommand>>.Ignored, false)).MustHaveHappened(Repeated.Exactly.Once);
The problem is that this assertion fails sometimes. I've noticed that usually it would fail when I run all my tests in one run ("Run All"), but doesn't if I only run this particular Fact
alone. As you've noticed, the method is async
so I was thinking about some async-related issue, but all the calls are properly await
ed.
Looking at the details of the assertion failures, the log is:
Assertion failed for the following call:
Backend.Data.MessageStorage.IMessageStorageClient.StoreAsync("commands", <NULL>, False)
Expected to find it exactly once but found it #0 times among the calls:
1: Backend.Data.MessageStorage.IMessageStorageClient.StoreAsync(
tableName: "commandStream",
entity: Backend.Domain.Commands.CommandEnvelope`1[Backend.Domain.Tests.FakeCommand],
streamMode: True)
2: Backend.Data.MessageStorage.IMessageStorageClient.StoreAsync(
tableName: "commands",
entity: Backend.Domain.Commands.CommandEnvelope`1[Backend.Domain.Tests.FakeCommand],
streamMode: False)
As you see, the expected call did happen (it's the case #2) but for some reason, FakeItEasy was expecting a call with NULL as the second parameter!
I hope someone can help me figure out why FakeItEasy would evaluate the A<CommandEnvelope<FakeCommand>>.Ignored
constraint to NULL and moreover, why it would do that only sometimes...
Aucun commentaire:
Enregistrer un commentaire