title: Unit test : check if a method is being called
body: <p>I have the following classes:</p>
  
  <pre><code>public class MyClass
  {
      public void MyMethod()
      {
          try
          {
              ...
              save data to file
              ...
          }
          catch (Exception exception)
          { 
              ErrorDisplay.ShowErrorMessage("MyMethod", exception);
          }
      }
  }
  
  public class ErrorDisplay
  {
      public static ShowErrorMessage(string methodName, Exception exception)
      {
          if (exception is IOException)
              MessageBox.Show(methodName + " : " + GetIODisplayMessage());
          else if ... 
              ...
          else
              ...
     }
  
      public static string GetIODisplayMessage()
      {
          return "IO error";
      }
  
      ....
  }
  </code></pre>
  
  <p>I need to write a unit test in witch i will mock the IOException and i need to check that
  <code>GetIODisplayMessage()</code> method is being called. Is there a way to test if a method is called?
  Or maybe another idea on how to make a unit test for my case?</p>
  
  <p>Thanks. </p>