-
-
Notifications
You must be signed in to change notification settings - Fork 811
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
Add new overload for throwsasync to allow Func<Exception> #1190
Add new overload for throwsasync to allow Func<Exception> #1190
Conversation
Hi @adam-knights, and first of all, thank you for participating in Moq development! I'll need some more time to decide whether to proceed with this... the main reason being that this new method overload is arguably the least needed one:
If you're willing to work on |
Thanks for such a quick reply. What you've said makes sense, I must admit I did see the new I think I will go ahead and try a new PR for what you've said. There seems to be a few choices as to where to put the implementation - I think it would be NonVoidSetupPhase ? But worth me asking the question before trying again! I also took a look at moq 5 and your chat in https://github.com/moq/moq/issues/53, if I've looked correctly then moq5 does have |
I'd start in
I think I won't mark any of them as obsolete as long as Moq 5 has even one of them. (The way I currently see it, they're a set of methods that really belong together: if |
Closing in favor of #1191. |
Related to #1048. This gets us a step towards the enhancement, in this first instance we now allow
ThrowsAsync(() => new Exception())
. And we refactor to use this in the existing methods.In a future PR we could add support for input arguments to fully cover #1048 - I thought I'd make this change first to make it smaller, before having to also edit
ReturnsExtensions.tt
etc.Note: Git isn't doing the best job of the diff here, probably better viewed side by side. Details...
Three new functions were added underneath the existing ThrowsAync functions.
The original functions were changed to call the new functions using
() => exception
, in the same wayReturnsAsync
does on line 28.I'm happy to add this to moq5 too, either after or before this is merged... didn't want to setup two PRs until this one had some feedback :).