title: Unit Testing contents of error message?
body: <p>I have a class that raises an event with an error message.</p>
  
  <p>In some of my tests I am subscribing to the event and asserting that the error message is not empty.</p>
  
  <pre><code>[Test]
  public MyMethod_DoBad_ErrorMessageNotEmpty()
  {
      var logic = new MyClass();
  
      string ErrorMessage = String.Empty;
  
      logic.DisplayError += delegate(string s)
      {
           ErrorMessage = s;
      };
  
      logic.DoItBadly();
  
      Assert.IsFalse(String.IsNullOrWhiteSpace(ErrorMessage));
  
  }
  
  //MyClass
  
  public void DoItBadly()
  {
    //do something naughty but not final
    DisplayError("Naughty");
  
    //some other problem arises
    if (1==1)
      DisplayError("Something else naughty");
  }
  </code></pre>
  
  <p>However I am starting to find in edge case testing that my new tests that should fail, pass because it has raised an error event previously in the code before it has got to where I want it to.</p>
  
  <p>Therefore should I be asserting that the error message contains a specified string?</p>