Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create a mock HttpMessageHandler
public class MockHttpMessageHandler : HttpMessageHandler
{
public int CalledTimes { get; private set; }
public HttpResponseMessage Response { get; set; }
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
CalledTimes++;
return Task.FromResult(Response);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.