title: Fail try/catch block reading a csv
body: <p>I'm unit testing my C# application that Parses a CSV. I'm at 94% code coverage, because I can't force it to fail the try/catch blocks... I'm using CsvHelper from Nuget <a href="http://joshclose.github.io/CsvHelper" rel="nofollow">http://joshclose.github.io/CsvHelper</a></p>
  
  <pre><code>public void ParseCsv([FromBody] string csvText)
  {
      var parseCsv = new XsvData(new[] { "\t", "," });
      try
      {
          using (var reader = new XsvReader(new StringReader(csvText)))
          {
              parseCsv.Read(reader, headerExists: true);
          }
      }
      catch (Exception)
      {
          var response = new HttpResponseMessage(HttpStatusCode.BadRequest)
          {
              Content = new StringContent("Unable to read CSV."),
              ReasonPhrase = "Invalid CSV"
          };
  
          throw new HttpResponseException(response);
      }
  }
  </code></pre>
  
  <p>I've tried passing the most obscure strings I could think of to it, but it makes it through this, and errors out later on in the function..</p>
  
  <pre><code>[TestMethod]
  //[ExpectedException(typeof(HttpResponseException))]
  public void TestUploadCsv_UploadingCsvNonCsv()
  {
      const string csvText = "fhfhk@- jhjfh@ajh- fjkqeqir%hjewq@hf- ujewqh$phfuw \n hfwu- ihfq&amp;if*u@q- afuhwu- fhiue@wfhiuewhiuf";
      var context = GetMyFakeEntityDatabase();
      var controller = new MyController(context);
      controller.ParseCsv(csvText);
  }
  </code></pre>
  
  <p>After the try/catch blocks, I have a section that enforces all the headers exist, and it fails there, but it should be failing during the reading, for this example. How do I force my unit test to fail? Any help is appreciated! Thanks in advance.</p>