-
-
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
SetReturnsDefault not working for Task<> #673
Comments
Hi @Albert221, there's no problem with
In your case, the very last of those bullet points applies. Since Basically, if you just remove the dummy setup for I know, that the above logic is ridiculously complex. Problem is, this cannot be easily rectified without possibly breaking existing user code. |
Okay, it all makes sense now, thank you for your explanation! I suggest adding this explanation (or reference to it) to XML documentation maybe? I've just searched for that in the Wiki, and it is present there, but I wonder whether it would be helpful and would save time for people like me :) |
@Albert221: That's a good idea! I'd suggest that for now, we add a hint in the XML documentation for Would you like to submit a PR? |
Will do! |
@Albert221: Thank you for contributing to Moq! 👍 |
Explanation in comment.
Looks like
Mock.SetReturnsDefault()
doesn't likeTask
type, becauseobj.SomeMethod()
returnsnull
instead ofTask<bool>
. Although, if I add.ReturnsAsync(false)
after.Setup
(and removeSetReturnsDefault
line) then everything is okay, obviously.The text was updated successfully, but these errors were encountered: