Skip to content

Instantly share code, notes, and snippets.

@alextercete
Created October 1, 2013 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alextercete/6781822 to your computer and use it in GitHub Desktop.
Save alextercete/6781822 to your computer and use it in GitHub Desktop.
public static class HttpMessageHandlerExtensions
{
public static HttpMessageHandler ThatRespondsWithAnEmptyContent(this HttpMessageHandler handler)
{
var mock = Mock.Get(handler);
var responseWithAnEmptyContent = new HttpResponseMessage {Content = new StringContent(string.Empty)};
mock.Protected()
.Setup<Task<HttpResponseMessage>>("SendAsync", new object[]
{
ItExpr.IsAny<HttpRequestMessage>(),
ItExpr.IsAny<CancellationToken>()
})
.Returns(Task.FromResult(responseWithAnEmptyContent));
return handler;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment