Testing Modal Dialogs
I'm trying to use NUnitForms to test NHibernate Query Analyzer, and I'm having problems testing some of the modal dialogs. What I want now is simply to find out if the modal dialog is displayed to the user. I can get my test method to load the modal dialog and an event to be fired when it does, but I don't know how I can access the form itself when I've done that.
In the code below, shown is set to true, but the test hang because the modal dialog is not closed, and I can't figute out a way to get the form so I could close it.
There is another hanlder, ModalFormActivatedHwnd, that gets the Hwnd of the shown form, but it's marked internal, so I can't use it. Any suggestion?
Here is the code:
         [TestFixture]
         public class MessageDialogTests : NUnitFormTest
         {
          string text = "Which ?? - Driven Design do you use?";
          string title = "What Design Driven?";
          string []args = {"Test Driven Design", "Doamin Driven Design", "User Driven Design", "WTF Driven Design"};
          private bool shown;
          [Test]
          public void TestMessageDialogShowsForm()
          {
           ExpectModal("MessageDialog."+title,new ModalFormActivated(MessageDialogHanlderShowForm));
           shown = false;
           MessageDialog.Show(text, title, MessageBoxIcon.Question, args);
           Assert.IsTrue(shown,"Message Dialog was not shown");
          }
          private void MessageDialogHanlderShowForm()
          {
           shown = true;
          }
         }    

Comments
Comment preview