I was searching for a way to test the GUI of one of our Windows Forms applications we are currently developing, found NUnitForms which imho is a great framework and easy to understand. Since we are using Inragistics controls I've started to implement tester classes for those controls. When implementing the tester for the Infragistics button I copied the ButtonTester of NUnitForms, did minor changes, also implemented a Test Form and a test based on the original ones. The tests work so far but the only test that behaves a little bit different is the one where the button is set to be not visible from the tester and then trying to click it. The expected exception is thrown and handled but when the form is teared down afterwards it seems that the .NET Framework is throwing 5 exceptions that are displayed in modal messages boxes that are treated by NUnitForms as unexpected modal thus the test fails which is not really true because just closing the form fails. Unfortunately I cannot see what's the reason for the exception but it seems to be a thread exception.

I've set a breakpoint to method Callback_ModalListener in ModalFormTester and what I can see there is that the code=3 (HCBT_CREATEWND). What I've done as a quickfix so that my test passes successfully is to add a check in method UnexpectedModal:

private void UnexpectedModal(string name, IntPtr hWnd, Form form)
{
    Win32.DestroyWindow(hWnd);
    if (!form.Text.Contains(".NET Framework"))
        unexpectedModals.Add(name);
}

This suppresses all message boxes popping up from .NET Framework to be not added as unexpected modal forms.

Maybe someone knows a better solution for that?

Regards,
Wolfgang