Add new overload for throwsasync to allow Func<Exception> #1190
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 :).