title: How to unit test FileContentResult?
body: <p>I have a method that exports data into CSV file.</p>
  
  <pre><code>public FileContentResult Index(SearchModel search)
  {    
      ...
      if (search.Action == SearchActionEnum.ExportToTSV)
      {
          const string fileName = "Result.txt";
          const string tab = "\t";
          var sb = BuildTextFile(result, tab);
          return File(new UTF8Encoding().GetBytes(sb.ToString()), "text/tsv", fileName);
      }
      if (search.Action == SearchActionEnum.ExportToCSV)
      {
          const string fileName = "Result.csv";
          const string comma = ",";
          var sb = BuildTextFile(result, comma);
          return File(new UTF8Encoding().GetBytes(sb.ToString()), "text/csv", fileName);
      }
      return null;
  }
  </code></pre>
  
  <p>My test, in NUnit:</p>
  
  <pre><code>[Test]
  public void Export_To_CSV()
  {
      #region Arrange
      ...
      #endregion
  
      #region Act
  
      var result = controller.Index(search);
  
      #endregion
  
      #region Assert
      result.ShouldSatisfyAllConditions(
          ()=&gt;result.FileDownloadName.ShouldBe("Result.csv"),
          ()=&gt;result.ContentType.ShouldBe("text/csv")
          );
      #endregion
  }
  </code></pre>
  
  <p>In addition to <code>FileDownloadName</code> and <code>ContentType</code>, I want to check the content of the <code>result</code>. </p>
  
  <p>It seems I should look into <code>result.FileContents</code>, but it is a <code>byte[]</code>.</p>
  
  <p>How can I get hold of the <code>result</code> as a text string?</p>
  
  <p>And is my result saved somewhere as a CSV file in the solution every time I run the test?</p>