How to test this code?
I am trying to refactor some code in a background service that looks like this:
Complex work should usually be kept somewhere else outside of the loop of the backgroundService. However, things get hairy enough that some tests will help.
2 Replies
To test the code, II mocked the consumer and i have a lot of tests like this
When I launch tests, the majority fail and I am trying to wrap my head around and understand why. When Launching tests individually, they all pass !
Observations:
1. Some tests fail with a null value when a non null value is expected
2. Some tests fail with a value that is not null but different from the expected.
Any help ? 🤔
Is MockedSender static or part of a fixture?
If you want to wait until a message is received in a mock then use some form of barrier like ManualResetEvent (instead of doing an arbitrary wait, which btw is not the 'Act' of the test)