-
-
Notifications
You must be signed in to change notification settings - Fork 798
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
Adding a generic ThrowsAsync method #692
Comments
|
I've taken a closer look today, and it turns out that this isn't as easy as I thought... more likely, it's not possible to implement this in a useful manner. The problem is that the extension method for While we could just have another extension method overload with an additional So why does the generic argument thingy work with the non-async So unfortunately, I don't think adding the requested |
You can use Moq.SetupAsync to achieve that, but with a slightly different syntax:
The package provide a SetupAsync extension methods, that then provide similar features than the standard Setup method, but we known from the start that we are in an async context which allow to provide the correct implementations for |
Is it possible to add a generic version of ThrowsAsync like it is available with Throws, so that we could write
mock.Setup(p => p.DoAsync()).ThrowsAsync<InvalidOperationException>();
instead of
mock.Setup(p => p.DoAsync()).ThrowsAsync(new InvalidOperationException());
The text was updated successfully, but these errors were encountered: