I have the following method in an interface..
Task<SearchResult<T>> SearchAsync(TU searchOptions);
works great.
Now i'm trying to make a unit test to test when something goes wrong - and the code throws an exception.
In this case, I've setup my method to throw an HttpRequestException
. My unit test fails to say that I threw that exception ..
var result = Should.Throw<HttpRequestException>
(async () => await service.SearchAsync(searchOptions));
the error message from the unit test is
Shouldly.ChuckedAWobbly
var result = Should
throw
System.Net.Http.HttpRequestException
but does not
So the assertion framework is saying: You've expected an exception, but none was thrown.
When I step -through- the code, the exception is 100% thrown.
Can anyone see what i've done wrong with my unit test code, please?