-
-
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
Improve "Member x does not exist" failure message #852
Comments
@thomasfdm, not sure how often people run into this problem, but having good diagnostic messages can't hurt. Would you like to submit a PR? |
Happy to give it a go, but no definite ETA on it 😄 |
I'll try and get it done today |
@thomasfdm - One thing to keep in mind (IIRC): It might be wrong to assume that the method parameter list has to match exactly with the provided arguments. (For example, on some |
Good catch, I've changed my error message accordingly: I've now got the method to generate it, just need to replace the calls from |
Currently an
ArgumentException
is thrown when a.Protected().Verify(methodName, times, arguments)
call is made whenarguments
doesn't match the arguments in methodName's signature which just statesSystem.ArgumentException : Member Class.Method does not exist.
.For example, if mocking a HttpMessageHandler you would use the following code to check if SendAsync was called with any (correct type) arguments:
If I was to accidentally use the wrong generic type for one of the arguments (for example
string
instead ofCancellationToken
) my code would instead look like this:and, then the test is run would give the following error:
This gives the impression that there is no such method as SendAsync at all in the class, whereas it's only the case that there isn't a SendAsync signature which takes
(HttpRequestMessage, string)
. Might it be worth updating this error message to include the erroneous signature i.e. something like:to make it easier to debug why tests are failing?
The text was updated successfully, but these errors were encountered: