title: Unit Testing that HttpResponseMessage Contains the Desired Response
body: <p>I'm writing a Web API controller and right now I have the following code:</p>
  
  <pre><code>public class PicklistsController : ApiController
  {
      private readonly IPicklistRepository _repository;
  
      public PicklistsController(IPicklistRepository repository)
      {
          _repository = repository;
      }
  
      public HttpResponseMessage GetPicklistValues(string entityName, string fieldName)
      {
          if(_repository.Exists(entityName, fieldName))
              return Request.CreateResponse(HttpStatusCode.Accepted, _repository.Get(entityName, fieldName));
  
          return new HttpResponseMessage(HttpStatusCode.NotFound);
      }
  
  }
  </code></pre>
  
  <p>I'm trying to test this method and all I really want to do is verify that the HttpResponseMessage contains values in the POCO PicklistItem when the repository finds this combination of values.  Being new to this framework, I don't understand the internal workings of HttpResponseMessage very well, and what I've found on this site and through general googling tells me to use various ReadAsync methods on its Content, but I don't really want to do use async if I can avoid it.  I really just want to verify that the thing I stuffed into the object I'm returning is in the object when I return it.  Here's what I have so far with the unit test (using JustMock to setup the repository, Target is the CUT):</p>
  
  <pre><code>public void Returns_Picklist_Item_JSON_When_Results_Exist()
  {
      Repository.Arrange(repo =&gt; repo.Exists(EntityName, FieldName)).Returns(true);
  
      const int value = 2;
      const string label = "asdf";
      var mynewPicklistItem = new PicklistItem() { Label = label, Value = value };
      Repository.Arrange(repo =&gt; repo.Get(EntityName, FieldName)).Returns(Enumerable.Repeat&lt;PicklistItem&gt;(mynewPicklistItem, 1));
  
      var response = Target.GetPicklistValues(EntityName, FieldName);
      //Assert.IsTrue(I don't know what to do here -- suggestions appreciated);
  }
  </code></pre>
  
  <p>Any ideas for the Assert?  Or am I barking up the wrong tree/fundamentally misunderstanding how this should be working?  Thanks...</p>