I do not understanding why TestableSaga AdvanceTime indicates timeout when no timeout should have been raised. Maybe AdvanceTime is not working as I think?
I have a simple Saga, that when started request a timeout after 30 minute.
It also haves a Handler to set up a new timeout in 1 hour.
The problem is the last two line, which both fails (one at a time)
I would venture to guess your problem is stemming from breaking the conventions of async/await code. When dealing with async code, you should (almost never) use .Wait() or .Result as they probably aren’t going to work as you expect, so what happens is that your code goes on to the next line before the async code has come to its conclusion, so at the end, where you think you’ve advanced time a total of 2 hours, in reality the CurrentTime property on the testable saga has not done that yet.
I would rewrite this code as the following. (And I’m speaking NUnit here - I think you’re using Shouldly but I can’t replicate that off the top of my head so I apologize for that)
You are right, I should make my test code async for readability. But with proper Wait and Result the behavior should be the same. I have checked, everything is awaited properly, so the odd behavior still remains.
Ah, without the surrounding method I missed that you were passing the same context into both handler calls. You only need to provide a context if you need to customize it in some way, and then it needs to be a new context for each call.