예제 #1
0
        public void Test_HandleEnterKey_WhenTextBoxIsMultiLine_ShouldNotMoveFocusToNextControl_FixBug1419()
        {
            //---------------Set up test pack-------------------
            GlobalRegistry.UIExceptionNotifier = new RethrowingExceptionNotifier();
            var parentControl = _factory.CreateControl();
            var strategyWin   = new ControlMapperStrategyWinSpy();
            var textBox1      = GetTextBox(parentControl);

            textBox1.Multiline = true;
            strategyWin.AddKeyPressEventHandler(textBox1);

            var tbWin2 = (TextBoxWin)GetTextBox(parentControl);

            var gotFocus = false;

            tbWin2.GotFocus += delegate { gotFocus = true; };
            var frm = AddControlToForm(parentControl);

            //--------------Assert PreConditions----------------
            Assert.AreEqual(2, parentControl.Controls.Count);
            Assert.IsTrue(textBox1.Multiline);
            //---------------Execute Test ----------------------
            frm.Show();
            strategyWin.CallCtlKeyUpHandler(Keys.Enter);
            //---------------Test Result -----------------------
            Assert.IsFalse(tbWin2.ContainsFocus, "Second control should not have focus.");
            Assert.IsFalse(gotFocus);
        }
예제 #2
0
        public void Test_HandleEnterKey_WhenCheckBox_ShouldMoveToNextControl()
        {
            //---------------Set up test pack-------------------
            GlobalRegistry.UIExceptionNotifier = new RethrowingExceptionNotifier();
            var parentControl = _factory.CreateControl();
            var strategyWin   = new ControlMapperStrategyWinSpy();
            var checkBox      = GetCheckBox(parentControl);

            strategyWin.AddKeyPressEventHandler(checkBox);

            var cbWin = (CheckBoxWin)GetCheckBox(parentControl);

            var gotFocus = false;

            cbWin.GotFocus += delegate { gotFocus = true; };
            var frm = AddControlToForm(parentControl);

            //--------------Assert PreConditions----------------
            Assert.AreEqual(2, parentControl.Controls.Count);
            //---------------Execute Test ----------------------
            frm.Show();
            strategyWin.CallCtlKeyUpHandler();
            //---------------Test Result -----------------------
            Assert.IsTrue(cbWin.ContainsFocus, "CheckBoxWin was expected to contain the focus");
            Assert.IsTrue(gotFocus, "CheckBoxWin should have received the gotfocus event");
        }
        public void Test_HandleEnterKey_WhenTextBoxIsMultiLine_ShouldNotMoveFocusToNextControl_FixBug1419()
        {
            //---------------Set up test pack-------------------
            GlobalRegistry.UIExceptionNotifier = new RethrowingExceptionNotifier();
            var parentControl = _factory.CreateControl();
            var strategyWin = new ControlMapperStrategyWinSpy();
            var textBox1 = GetTextBox(parentControl);
            textBox1.Multiline = true;
            strategyWin.AddKeyPressEventHandler(textBox1);

            var tbWin2 = (TextBoxWin)GetTextBox(parentControl);

            var gotFocus = false;
            tbWin2.GotFocus += delegate { gotFocus = true; };
            var frm = AddControlToForm(parentControl);
            //--------------Assert PreConditions----------------            
            Assert.AreEqual(2, parentControl.Controls.Count);
            Assert.IsTrue(textBox1.Multiline);
            //---------------Execute Test ----------------------
            frm.Show();
            strategyWin.CallCtlKeyUpHandler(Keys.Enter);
            //---------------Test Result -----------------------
            Assert.IsFalse(tbWin2.ContainsFocus, "Second control should not have focus.");
            Assert.IsFalse(gotFocus);
        }
        public void Test_HandleEnterKey_WhenCheckBox_ShouldMoveToNextControl()
        {
            //---------------Set up test pack-------------------
            GlobalRegistry.UIExceptionNotifier = new RethrowingExceptionNotifier();
            var parentControl = _factory.CreateControl();
            var strategyWin = new ControlMapperStrategyWinSpy();
            var checkBox = GetCheckBox(parentControl);
            strategyWin.AddKeyPressEventHandler(checkBox);

            var cbWin = (CheckBoxWin)GetCheckBox(parentControl);

            var gotFocus = false;
            cbWin.GotFocus += delegate { gotFocus = true; };
            var frm = AddControlToForm(parentControl);
            //--------------Assert PreConditions----------------            
            Assert.AreEqual(2, parentControl.Controls.Count);
            //---------------Execute Test ----------------------
            frm.Show();
            strategyWin.CallCtlKeyUpHandler();
            //---------------Test Result -----------------------
            Assert.IsTrue(cbWin.ContainsFocus, "CheckBoxWin was expected to contain the focus");
            Assert.IsTrue(gotFocus, "CheckBoxWin should have received the gotfocus event");
        }