I am writing unit tests in C# using Moq framework. How can I write a mock statement for the following:
HttpClient httpClient;
var request = new HttpRequestMessage() { ... }
httpClient.Send(request);
I have found solutions for mocking SendAsync method, but not for just Send() method. Since I am writing unit tests, I do not want my test to send an actual request to the URL.
Hence, I would like to mock it and just verify if the Send method was called. What URL should be provided to ensure this behavior, without running into any other issues?
I am not in a position to modify my original code. Is it possible to use HttpMessageHandler to do this? What URL should I provide to mock this statement and how can I mock this statement without making an actual request to the URL and without running into additional issues such as invalid host or failed to connect to host etc? Thank you.