✅ Unit Testing HttpClient
Hello, I'm currently trying to write some unit tests for a class that uses an HttpClientFactory through DI. This is the just of what I'm doing in these tests:
But every test that uses the
IHttpClientFactory
throws the following exception:
4 Replies
does it work if you change your
SetupRequest
to SetupAnyRequest
?
I know you probably don't want it that way ultimately, just trying to narrow it downYeah, it does
so you're missing something in your request matching
or rather, have something wrong
I haven't used that library before, always just used the out of the box
Setup
are you sure the verb + url are correct?Yeah, I've tried debugging and they all look correct. The code itself works, it's just that all tests fail because of this exception being thrown
Turns out it had something to do with the way
BaseAddress
was being parsed, managed to fix it by changing the way I add endpoints to the request URI