Esempio n. 1
0
        public void Verify()
        {
            TearDown();

            if (!verified)
            {
                verified = true;
                List <Form> allForms = new FormFinder().FindAll();

                foreach (Form form in allForms)
                {
                    if (!KeepAlive.ShouldKeepAlive(form))
                    {
                        form.Dispose();
                        form.Hide();
                    }
                }

                string[] errors      = new string[0];
                bool     modalVerify = modal.Verify();
                if (!modalVerify)
                {
                    errors = modal.GetErrors();
                }
                modal.Dispose();

                if (UseHidden)
                {
                    testDesktop.Dispose();
                }

                mouse.Dispose();
                keyboard.Dispose();

                if (!modalVerify)
                {
                    string message = "";
                    foreach (string m in errors)
                    {
                        message += m + ((errors.Length > 1) ? "\r\n" : "");
                    }
                    throw new FormsTestAssertionException(message);
                }
            }
        }
Esempio n. 2
0
        public void Verify()
        {
            try
            {
                TearDown();
                Util.GetMessageHook.RemoveHook();

                if (ModalFormHandler == null)
                {
                    // Make an effort to ensure that no window message is left dangling
                    // Such a message might cause an unexpected dialog box
                    for (int i = 0; i < 10; ++i)
                    {
                        Application.DoEvents();
                    }
                }

                if (!verified)
                {
                    verified = true;
                    List <Form> allForms = new FormFinder().FindAll();

                    foreach (Form form in allForms)
                    {
                        if (!KeepAlive.ShouldKeepAlive(form))
                        {
                            form.Dispose();
                            form.Hide();
                        }
                    }

                    string[] errors = new string[0];
                    ModalFormTester.Result modalResult = modal.Verify();
                    if (!modalResult.AllModalsShown)
                    {
                        throw new FormsTestAssertionException("Expected Modal Form did not show");
                    }
                    if (modalResult.UnexpectedModalWasShown)
                    {
                        string msg = "Unexpected modals: ";
                        foreach (string mod in modalResult.UnexpectedModals)
                        {
                            msg += mod + ", ";
                        }
                        throw new FormsTestAssertionException(msg);
                    }

                    modal.Dispose();

                    if (UseHidden)
                    {
                        testDesktop.Dispose();
                    }
                }
            }
            finally
            {
                modal.Dispose();
                mouse.Dispose();
                keyboard.Dispose();
            }
        }