AddKeyPressEventHandler() public method

Handles the default key press behaviours on a control. This is typically used to change the handling of the enter key (such as having the enter key cause focus to move to the next control).
public AddKeyPressEventHandler ( IControlHabanero control ) : void
control IControlHabanero The control whose events will be handled
return void
        public void Test_KeyPressMovesFocusToNextControl()
        {
            //---------------Set up test pack-------------------
            GlobalRegistry.UIExceptionNotifier = new RethrowingExceptionNotifier();
            var parentControl = _factory.CreateControl();
            var strategyWin = new ControlMapperStrategyWin();
            var textBox = _factory.CreateTextBox();
            textBox.Name = "TestTextBox";
            strategyWin.AddKeyPressEventHandler(textBox);

            parentControl.Controls.Add(textBox);

            var textBox2 = _factory.CreateTextBox();
            parentControl.Controls.Add(textBox2);
            var tbWin = (TextBoxWin)textBox2;
            var gotFocus = false;
            tbWin.GotFocus += delegate { gotFocus = true; };

            var frm = AddControlToForm(parentControl);
            //--------------Assert PreConditions----------------            

            //---------------Execute Test ----------------------
            frm.Show();
            var box = new TextBoxTester("TestTextBox");
            var eveArgsEnter = new KeyEventArgs(Keys.Enter);
            box.FireEvent("KeyUp", eveArgsEnter);

            //---------------Test Result -----------------------
            Assert.IsTrue(tbWin.ContainsFocus);
            Assert.IsTrue(gotFocus);
        }