Open utterances-bot opened 2 years ago
Was this NOT a thing when you wrote this article?
System.NotSupportedException HResult=0x80131515 Message=Unsupported expression: x => x.CreateClient() Extension methods (here: HttpClientFactoryExtensions.CreateClient) may not be used in setup / verification expressions. Source=Moq
Hopefully I can find something out there on how to fix this. : /
The answer is that you must created a "Named" HttpClient via the .CreateClient("this can be empty")
method.
How to test HttpClientFactory with Moq - Code4IT
Mocking IHttpClientFactory is hard, but luckily we can use some advanced features of Moq to write better tests.
https://www.code4it.dev/blog/testing-httpclientfactory-moq