DEV Community

Discussion on: Mocking the HttpClient in .NET Core (with NSubstitute)

Collapse
 
yadurajshakti profile image
Yaduraj Shakti

This was really helpful. Thanks Lars!

Just want to add:-

If your implementation does not accepts HttpClient in constructor and creates HttpClient directly, then you may use IHttpClientFactory.CreateClient() in your code. Now mock this IHttpClientFactory.CreateClient() to return your HttpClient in test.