title: How to get data in JSON format from a controller returning IHttpActionResult in C#?
body: <p>I have a controller that uses Newtonsoft.Json to convert IEnumerable into JSON format.</p>
  
  <pre><code>[Route("")]
  public IHttpActionResult Get()
  {
      IEnumerable&lt;Product&gt; productList = ProductService.GetAllProducts();
      if (!productList.Any())
          return Ok();
  
      return Json(productList, new JsonSerializerSettings
      {
          ContractResolver = new WebContractResolver(),
          Converters = new List&lt;JsonConverter&gt; { new TrimStringDataConverter() }
      });
  }
  </code></pre>
  
  <p>When I hit the API end point through POSTMAN, it gives me the expected JSON data.</p>
  
  <pre><code>[
      {
          "code": "prod101",
          "title": "LAPTOP"
      },
      {
          "code": "prod102",
          "title": "MOBILE"
      }
  ]
  </code></pre>
  
  <p>Now, I am writing unit test(NUnit) for the controller and I want to get this JSON formatted data in my unit test method. 
  I am able to get the IEnumerable - </p>
  
  <pre><code>IHttpActionResult actionResult = mockProductControllerClient.Get();
  JsonResult&lt;IEnumerable&lt;Product&gt;&gt; contentResult = actionResult as JsonResult&lt;IEnumerable&lt;Product&gt;&gt;;
  IEnumerable&lt;Product&gt; data = contentResult.Content;
  </code></pre>
  
  <p>I need the exact same data in Unit Test methods as being received in POSTMAN i.e. JSON data</p>