-
-
Notifications
You must be signed in to change notification settings - Fork 794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ReturnsAsync and ThrowsAsync with delay parameter starts timer at setup #593
Comments
Thanks for reporting! 👍 Looks like a definite bug to me. (Or can you imagine any scenario where this could be the intended behavior?) Since you're already working on One thing about your test, I find that even if I remove the (And one more thing out of personal curiosity: I'm often seeing people using |
As you want to wait in that line before the Asserts the simplest line would be |
@stakx I will fix it too as it is related to the same code. The unit test depends on execution time. Seems like there are some implementation details of I agree to use |
@snrnats: There are a few unit tests dealing with e. g. thread safety that work with fixed time spans, so your test wouldn't be the first. It's not an ideal way of testing things but often it's the only way. 100 ms seems to be a good compromise to me between keeping the test quick and keeping it "accurate". I'd say 1 sec would be the upper limit, but it's good to stay away from it if possible. Thanks for looking into this. @informatorius: Thanks for confirming that |
ReturnsAsync
andThrowsAsync
with delay parameter start timer at setup, not at mock method invocation.The reason is that
Task.Delay
is called insideDelayedResult/DelayedException
but it needs to be deferred until mock method is invoked.The text was updated successfully, but these errors were encountered: