public void CancelTest()
 {
     ExpectFileDialog("CancelFileHandler");
       ButtonTester save_btn = new ButtonTester("btSave");
       save_btn.Click();
       Assert.AreEqual(label1.Text, "cancel pressed");
 }
 public void FindNestedControl()
 {
     LabelTester label = new LabelTester("mySecondLabel");
     ButtonTester button = new ButtonTester("myControl2.myButton");
     button.Click();
     Assert.Equal("1", label.Text);
 }
        public void AmbiguousButton()
        {
            AmbiguousNameForm form = new AmbiguousNameForm();
            form.Show();
            Censor.Add("XunitFormsTestApplicationsCustomTesters");
            TestWriter writer = new TestWriter(form);
            Assert.Equal("", writer.Test);

            ButtonTester button = new ButtonTester("myControl2.myButton", form);

            button.Click();
            Assert.Equal(
                @"[Fact]
            public void Test()
            {

            ButtonTester myControl2_myButton = new ButtonTester(""myControl2.myButton"");

            myControl2_myButton.Click();

            }",
                writer.Test);

            Censor.Remove("XunitFormsTestApplicationsCustomTesters");
        }
Beispiel #4
0
 public void ButtonLabelShouldBeTwoAfterClickedTwice()
 {
     ButtonTester button = new ButtonTester("countButton");
     button.Click();
     button.Click();
     Assert.AreEqual("2", button.Text);
 }
        public void EventCausesAnother()
        {
            MultiForm form = new MultiForm();
            form.Show();
            TestWriter writer = new TestWriter(form);
            ButtonTester button = new ButtonTester("btnClose");
            button.Click();
            try
            {
                button.Click();
                Assert.Fail("Window did not close.");
            }
            catch(NoSuchControlException)
            {
                //window is closed.. good.
            }

            Assert.AreEqual(
                    @"[Test]
            public void Test()
            {

            ButtonTester btnClose = new ButtonTester(""btnClose"");

            btnClose.Click();

            }",
                    writer.Test);
        }
        public void AmbiguousNameWithMultipleForms()
        {
            ShowForm(new ButtonTestForm());
            ShowForm(new ButtonTestForm());

            ButtonTester myButton = new ButtonTester("myButton");
            myButton.Click();
        }
 public void CancelTest()
 {
     LabelTester label1 = new LabelTester("lblFileName");
     ExpectFileDialog("CancelFileHandler");
     ButtonTester open_btn = new ButtonTester("btOpenFile");
     open_btn.Click();
     Assert.Equal(label1.Text, "cancel pressed");
 }
        public void AmbiguousNameWithMultipleForms()
        {
            ShowForm(new ButtonTestForm());
            ShowForm(new ButtonTestForm());

            ButtonTester myButton = new ButtonTester("myButton");
            Assert.Throws<AmbiguousNameException>(() => myButton.Click());
        }
 public void DynamicButtonClick()
 {
     ButtonTester addButton = new ButtonTester("addButton");
     addButton.Click();
     ButtonTester dynamicButton = new ButtonTester("button0");
     dynamicButton.Click();
     Assert.AreEqual("1", dynamicButton.Text);
 }
 public override void Setup()
 {
     new ToolStripContainerTestForm().Show();
     button = new ButtonTester("b1");
     box = new TextBoxTester("tb1");
     tsb = new ToolStripItemTester("tsb"); //tool strip button as control
     tsl = new ToolStripItemTester("tsl"); //tool strip label as control.
 }
Beispiel #11
0
        public void TestModalFormByString()
        {
            new ModalMultiForm().Show();

            ExpectModal("Form-0", "ModalFormHandler");

            ButtonTester buttonOne = new ButtonTester("myButton", "Form");

            buttonOne.Click();
        }
 public void ButtonClick()
 {
     Form form = new ButtonTestForm();
     form.Show();
     ButtonTester button = new ButtonTester("myButton", form);
     LabelTester label = new LabelTester("myLabel", form);
     Assert.Equal("0", label.Text);
     button.Click();
     Assert.Equal("1", label.Text);
 }
        public void TestModalForm()
        {
            ModalMultiForm form = new ModalMultiForm();
            form.Show();

            ButtonTester buttonOne = new ButtonTester("myButton", "Form");
            ModalFormHandler = handler;
            buttonOne.Click();
            form.Close();
            Verify();
        }
        public void DynamicControlsWithDuplicateNameCount()
        {
            ButtonTester addDuplicateButton = new ButtonTester("btnAddDuplicate");
            ButtonTester duplicate = new ButtonTester("duplicate");

            addDuplicateButton.Click();
            addDuplicateButton.Click();
            addDuplicateButton.Click();

            Assert.AreEqual(3, duplicate.Count);
        }
Beispiel #15
0
        public void TestModalForm()
        {
            ExpectModal("Form-0", new ModalFormActivated(ModalFormHandler));

            ModalMultiForm form = new ModalMultiForm();
            form.Show();

            ButtonTester buttonOne = new ButtonTester("myButton", "Form");

            buttonOne.Click();
        }
 public void TestAcceptButton()
 {
     ExpectModal(
         "DialogWithNoHandlersForm",
         delegate {
             acceptButton = new ButtonTester("button1");
             acceptButton.Click();
         });
     DialogWithNoHandlersForm form = new DialogWithNoHandlersForm();
     DialogResult result = form.ShowDialog();
     Assert.AreEqual(DialogResult.OK, result, "Wrong dialog result.");
     Assert.IsFalse(form.Visible, "Form was still visible.");
 }
 public void TestAcceptButton()
 {
     ModalFormHandler =
         delegate(string name, System.IntPtr hWnd, System.Windows.Forms.Form fform)
         {
             acceptButton = new ButtonTester("button1");
             acceptButton.Click();
         };
     DialogWithNoHandlersForm form = new DialogWithNoHandlersForm();
     DialogResult result = form.ShowDialog();
     Assert.Equal(DialogResult.OK, result);
     Assert.False(form.Visible, "Form was still visible.");
     form.Close();
 }
        public void PressEnterClicksButton()
        {
            Form form = new ButtonTestForm();
            form.Show();
            LabelTester label = new LabelTester("myLabel", form);
            ButtonTester button = new ButtonTester("myButton", form);

            Assert.Equal("0", label.Text);

            Keyboard.UseOn(button);
            Keyboard.Click(Key.RETURN);

            Assert.Equal("1", label.Text);
        }
        public void SaveTest()
        {
            ExpectFileDialog("SaveFileHandler");

              // Generate a temporary file
              _fileName = System.IO.Path.GetTempPath() + "MbUnitFormsTestFile.tmp";
              // If exists remove it
              if (System.IO.File.Exists(_fileName))
              {
            System.IO.File.Delete(_fileName);
              }

              ButtonTester save_btn = new ButtonTester("btSave");
              save_btn.Click();
              Assert.AreEqual(label1.Text, _fileName);
        }
        public void DynamicControlRecorded()
        {
            DynamicControlsTestForm form = new DynamicControlsTestForm();
            form.Show();
            TestWriter writer = new TestWriter(form);
            Assert.AreEqual("", writer.Test);

            ButtonTester button = new ButtonTester("addButton", form);
            ButtonTester button0 = new ButtonTester("button0", form);

            button.Click();
            button0.Click();

            Assert.IsTrue(writer.Test.IndexOf(@"addButton.Click();
            button0.Click();") != -1);
        }
        public void TestMultipleForms()
        {
            MultiForm form = new MultiForm();
            form.Show();

            ButtonTester buttonOne = new ButtonTester("myButton", "Form");
            ButtonTester buttonTwo = new ButtonTester("myButton", "Form-0");
            ButtonTester buttonThree = new ButtonTester("myButton", "Form-0-0");
            ButtonTester buttonFour = new ButtonTester("myButton", "Form-1");

            buttonOne.Click();
            buttonTwo.Click();
            buttonThree.Click();
            buttonOne.Click();
            buttonFour.Click();
        }
Beispiel #22
0
        public void Listen()
        {
            ButtonTestForm form = new ButtonTestForm();
            form.Show();
            FireCount = 0;
            Listener listener = new Listener();
            listener.ListenTo(form);

            listener.Event += new EventHappened(EventListener);

            ButtonTester button = new ButtonTester("myButton", form);
            button.Click();
            Assert.AreEqual(1, FireCount);
            button.Click();
            Assert.AreEqual(2, FireCount);
        }
        public void CancelTest()
        {
            OpenFileDialogTestForm f = new OpenFileDialogTestForm();
            f.Show();

            LabelTester label1 = new LabelTester("lblFileName");
            ButtonTester open_btn = new ButtonTester("btOpenFile");
            ModalFormHandler = CancelFileHandler;
            System.Windows.Forms.Application.DoEvents();
            open_btn.Click();
            System.Windows.Forms.Application.DoEvents();

            Assert.Equal(label1.Text, "cancel pressed");

            f.Close();
        }
Beispiel #24
0
        public void Close()
        {
            using (MultiForm formMultiForm = new MultiForm())
            {
                formMultiForm.Show();
                ButtonTester myButton = new ButtonTester("myButton");
                using (FormTester form = new FormTester("Form"))
                {
                    Assert.True(myButton.Properties.Visible);
                    form.Close();

                    Assert.Throws<NoSuchControlException>(delegate {
                        bool shouldNotGetMe = myButton.Properties.Visible;
                    });
                }
            }
        }
        public void DynamicControlsWithDuplicateNameEnumerator()
        {
            ButtonTester addDuplicateButton = new ButtonTester("btnAddDuplicate");
            ButtonTester duplicate = new ButtonTester("duplicate");

            addDuplicateButton.Click();
            addDuplicateButton.Click();
            addDuplicateButton.Click();

            foreach(ButtonTester button in duplicate)
            {
                button.Click();
            }

            foreach(ButtonTester button in duplicate)
            {
                Assert.AreEqual("1", button.Text);
            }
        }
Beispiel #26
0
        public void Close()
        {
            using (MultiForm formMultiForm = new MultiForm())
            {
                formMultiForm.Show();
                ButtonTester myButton = new ButtonTester("myButton");
                using (FormTester form = new FormTester("Form"))
                {
                    Assert.IsTrue(myButton.Properties.Visible);
                    form.Close();

                    try
                    {
                        bool shouldNotGetMe = myButton.Properties.Visible;
                        Assert.Fail("found control after closing form");
                    }
                    catch (NoSuchControlException) {}
                }
            }
        }
        public void EventCausesAnother()
        {
            MultiForm form = new MultiForm();
            form.Show();
            TestWriter writer = new TestWriter(form);
            ButtonTester button = new ButtonTester("btnClose");
            button.Click();
            Assert.Throws<NoSuchControlException>(() => button.Click());

            Assert.Equal(
                @"[Fact]
            public void Test()
            {

            ButtonTester btnClose = new ButtonTester(""btnClose"");

            btnClose.Click();

            }",
                writer.Test);
        }
        public void DontNeedToSpecifyForm()
        {
            ShowForm(new ButtonTestForm());
            ShowForm(new TabControlTestForm());

            ButtonTester myButton = new ButtonTester("myButton");
            LabelTester myLabel = new LabelTester("myLabel");
            TabControlTester myTabs = new TabControlTester("myTabs");
            ButtonTester tabButton = new ButtonTester("button2");
            LabelTester tabLabel = new LabelTester("label2");

            myTabs.SelectTab(1);
            Assert.Equal("0", tabLabel.Text);

            Assert.Equal("0", myLabel.Text);
            myButton.Click();
            Assert.Equal("1", myLabel.Text);

            tabButton.Click();
            Assert.Equal("1", tabLabel.Text);
        }
        public void SimpleButton()
        {
            ButtonTestForm form = new ButtonTestForm();
            form.Show();
            TestWriter writer = new TestWriter(form);
            Assert.Equal("", writer.Test);

            ButtonTester button = new ButtonTester("myButton", form);
            button.Click();

            Assert.Equal(
                @"[Fact]
            public void Test()
            {

            ButtonTester myButton = new ButtonTester(""myButton"");

            myButton.Click();

            }",
                writer.Test);
        }
Beispiel #30
0
        public void ButtonLabelShouldBeControllerValue()
        {
            controller = mockRepository.DynamicMock<IAppController>();

            using (mockRepository.Record())
            {
                Expect.
                    On(controller).
                    Call(controller.GetData()).
                    Return(UpdatedValue);
            }
            using (mockRepository.Playback())
            {
                alternateAppForm = new AlternateAppForm(controller);
                alternateAppForm.Show();

                ButtonTester button = new ButtonTester("countButton");
                button["Text"] = TestValue;

                Assert.AreEqual(TestValue, button.Text);
            }
        }