title: Verifying ArgumentException and its message in Nunit , C#
body: <p>In my test program in Nunit, I want to verify that it's getting the write Argument Exception by verifying the message.</p>
  
  <pre><code>    [Test]
      public void ArgumentsWorkbookNameException()
      {
          const string workbookName = "Tester.xls";
          var args = new[] { workbookName, "Sheet1", "Source3.csv", "Sheet2", "Source4.csv" };
          Assert.Throws(typeof(ArgumentException), delegate { var appargs = new ApplicationArguments(args); }, "Invalid ending parameter of the workbook. Please use .xlsx");
  
      }
  </code></pre>
  
  <p>After testing this out, this doesn't work when I modified the message in the main program.</p>
  
  <pre><code>        int wbLength = args[0].Length;
  
          // Telling the user to type in the correct workbook name file.
          if (args[0].Substring(wbLength-5,5)!=".xlsx")
          {
              throw new ArgumentException(
                  "Invalid ending parameter of the workbook. Please use .xlsx random random");
          }
  </code></pre>
  
  <p>The unit test still passed, regardless if I changed the message.</p>
  
  <p>How do I do it? Or is there no such things in C#. My colleague said there are options like that in Ruby and RSPEC, but he's not 100% sure on C#.</p>