Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

MessageBox with empty caption

Help
2008-03-19
2013-04-24
  • Hi all,
    is it possible to test for MessageBox with empty caption?

    Is set an Expectation for a modal window like this:
    ExpectModal(String.Empty, "CloseMessageBox");

    And when the MessageBox is Displayed the delegate CloseMessageBox is correctly called.
    The code of the CloseMessageBox method is:

    private void CloseMessageBox() {
        MessageBoxTester msgBox = new MessageBoxTester(String.Empty);
        Console.WriteLine(msgBox.Count);
        msgBox.ClickOk();
    }

    but the msgBox.Count is 0. And the messageBox is not closed.
    Thanks for your help.

     
  • Mark Freedman
    Mark Freedman
    2010-05-11

    I had the same problems that you were having, in that the MessageBoxTester couldn't get a handle on the message box.  My solution was to add Captions to all of the Message Boxes.  It's clearer to the operator to see boxes with captions, IMO.

     
  • lhab
    lhab
    2010-08-11

    With the latest svn rev, you can register a handler that takes the window handle of the message box as argument, and pass that handle to the message box tester constructor.

    ModalFormHandler = delegate(string name, IntPtr hwnd, Form f)
    {
        MessageBoxTester mbt = new MessageBoxTester(hwnd);
        // whatever you please; you may for instance use mbt.Text to check that you really get the expected msg box
    };

    The handlers you input into ModalFormHandler are single-shot, a new one should be installed before any modal form is expected.