title: How to Set the content for HttpResponseMessage during a unit test?
body: <p>I am writing a unit test in which I am testing a service that connects to an external service.</p>
  <p>Service code:</p>
  <pre class="lang-cs prettyprint-override"><code>var request = new APIRequest
  {
      Query = query
  };
  
  var response = await _httpService.SendRequestAsync(_configuration.ApiUrl, HttpMethod.Post, request, _configuration.Username, _configuration.Password);
  
  if (response.IsSuccessStatusCode)
  {
      var result = await response.Content.ReadAsAsync&lt;Result&gt;();
      return result;
  }
  </code></pre>
  <p>The unit test that I have written for the above service method.</p>
  <pre class="lang-cs prettyprint-override"><code>public async void GetPerformance_OKResults()
  {
      //ARRANGE
      var resultToReturn = MockedEntitiesRepository.mockNetworkResult;
      HttpResponseMessage mockResponse = new HttpResponseMessage(System.Net.HttpStatusCode.OK);
      mockResponse.Content = new ObjectContent(Type.GetType(resultToReturn), resultToReturn, MediaTypeFormatter.)
  
      mockHttpService.Setup(s =&gt; s.SendRequestAsync(applicationConfiguration.Object.Value.ApiUrl, HttpMethod.Post, It.IsAny&lt;object&gt;(), applicationConfiguration.Object.Value.Username, applicationConfiguration.Object.Value.Password)).Returns(Task.FromResult(mockResponse));
  
      service = new Service(applicationConfiguration.Object, mockHttpService.Object, mockLogger.Object, mockCacheService.Object);
  
      //ACT
      var result = await Service.GetPerformance(It.IsAny&lt;long&gt;(), It.IsAny&lt;DateTimeOffset&gt;(), It.IsAny&lt;DateTimeOffset&gt;(), It.IsAny&lt;string&gt;());
  
      // ASSERT
      Assert.Collection(result, item =&gt; Assert.Equal(something, something));
  }
  </code></pre>
  <p>I want to set the object <code>mockResponse</code>  HTTPResponseMessage content with the object <code>resultToReturn </code> in the unit test so that when the code goes makes an actual call it is able to set the value and i can assert on the result.</p>
  <p>How can I set the value?</p>