I'm trying to mock var response = await httpClient.SendAsync(request, CancellationToken.None);
but my response.Content
is always null
.
My mock looks like...
var httpResponseMessage = new HttpResponseMessage(System.Net.HttpStatusCode.OK);
httpResponseMessage.Content = new StringContent("test content", System.Text.Encoding.UTF8, "application/json");
A.CallTo(() => httpClient.SendAsync(A.Fake<HttpRequestMessage>(), CancellationToken.None)).Returns(Task.FromResult(httpResponseMessage));
it seems like it is properly mocked but the response.Content is null but the status code - for example - reflects what I set in the test.
I'm sure one of you guys out here have encountered this problem, all help will be greatly appreciated. Thanks.