locked
How to suppress a message box while unit testing RRS feed

  • Question

  •  I am writing unit test case for a validation function in Wpf app.  Whenever i run the unit test , due to validation a message box pop up in the screen. I just want to suppress the message box while unit testing.

    Can anyone gimme some idea?

     

    Thursday, November 18, 2010 11:42 AM

All replies

  • any suggestion?
    Friday, November 19, 2010 11:24 AM
  • May be this is not the best way of doing it but you can always wrap up the calls to messagebox show method like this.

    
    public static class MessageBoxHelper
    {
      public void Show(bool suppress, string message)
      {
         if (!suppress)
          System.Windows.MessageBox.Show(message);
      }
    }
    
    
    Monday, December 13, 2010 4:32 AM