public void TestHomeAndEnd()
        {
            Screen       screen = new Screen();
            InputControl input  = new InputControl();

            screen.Desktop.Children.Add(input);
            screen.FocusedControl = input;

            input.ProcessCharacter('W');
            input.ProcessCharacter('o');
            input.ProcessCharacter('r');
            input.ProcessCharacter('l');
            input.ProcessCharacter('d');

            input.ProcessKeyPress(Keys.Home, false);

            input.ProcessCharacter('H');
            input.ProcessCharacter('e');
            input.ProcessCharacter('l');
            input.ProcessCharacter('l');
            input.ProcessCharacter('o');
            input.ProcessCharacter(' ');

            input.ProcessKeyPress(Keys.End, false);

            input.ProcessCharacter('!');

            Assert.AreEqual("Hello World!", input.Text);
        }
        public void TestUnfocusedKeyPress()
        {
            InputControl input = new InputControl();

            Assert.IsFalse(input.ProcessKeyPress(Keys.Left, false));
            Assert.IsFalse(input.ProcessKeyPress(Keys.Right, false));
        }
        public void TestUnhandledKeyPress()
        {
            Screen       screen = new Screen();
            InputControl input  = new InputControl();

            screen.Desktop.Children.Add(input);
            screen.FocusedControl = input;

            Assert.IsTrue(input.ProcessKeyPress(Keys.Left, false));
            input.ProcessKeyRelease(Keys.Left);
            Assert.IsTrue(input.ProcessKeyPress(Keys.Right, false));
            input.ProcessKeyRelease(Keys.Right);

            Assert.IsFalse(input.ProcessKeyPress(Keys.Up, false));
            Assert.IsFalse(input.ProcessKeyPress(Keys.Down, false));
        }
        public void TestDelete()
        {
            Screen       screen = new Screen();
            InputControl input  = new InputControl();

            screen.Desktop.Children.Add(input);
            screen.FocusedControl = input;

            input.ProcessCharacter('T');
            input.ProcessCharacter('e');
            input.ProcessCharacter('l');
            input.ProcessCharacter('l');
            input.ProcessCharacter('o');

            input.ProcessKeyPress(Keys.Home, false);
            input.ProcessKeyPress(Keys.Delete, false);

            input.ProcessCharacter('H');

            Assert.AreEqual("Hello", input.Text);
        }
        public void TestCaretMovementByCursor()
        {
            Screen       screen = new Screen();
            InputControl input  = new InputControl();

            screen.Desktop.Children.Add(input);
            screen.FocusedControl = input;

            input.ProcessCharacter('H');
            input.ProcessCharacter('e');
            input.ProcessCharacter('l');
            input.ProcessCharacter('o');

            input.ProcessKeyPress(Keys.Left, false);

            input.ProcessCharacter('l');

            input.ProcessKeyPress(Keys.Right, false);

            input.ProcessCharacter('!');

            Assert.AreEqual("Hello!", input.Text);
        }
Пример #6
0
    public void TestDelete() {
      Screen screen = new Screen();
      InputControl input = new InputControl();
      screen.Desktop.Children.Add(input);
      screen.FocusedControl = input;

      input.ProcessCharacter('T');
      input.ProcessCharacter('e');
      input.ProcessCharacter('l');
      input.ProcessCharacter('l');
      input.ProcessCharacter('o');

      input.ProcessKeyPress(Keys.Home, false);
      input.ProcessKeyPress(Keys.Delete, false);

      input.ProcessCharacter('H');

      Assert.AreEqual("Hello", input.Text);
    }
Пример #7
0
    public void TestUnfocusedKeyPress() {
      InputControl input = new InputControl();

      Assert.IsFalse(input.ProcessKeyPress(Keys.Left, false));
      Assert.IsFalse(input.ProcessKeyPress(Keys.Right, false));
    }
Пример #8
0
    public void TestUnhandledKeyPress() {
      Screen screen = new Screen();
      InputControl input = new InputControl();
      screen.Desktop.Children.Add(input);
      screen.FocusedControl = input;

      Assert.IsTrue(input.ProcessKeyPress(Keys.Left, false));
      input.ProcessKeyRelease(Keys.Left);
      Assert.IsTrue(input.ProcessKeyPress(Keys.Right, false));
      input.ProcessKeyRelease(Keys.Right);
      
      Assert.IsFalse(input.ProcessKeyPress(Keys.Up, false));
      Assert.IsFalse(input.ProcessKeyPress(Keys.Down, false));
    }
Пример #9
0
    public void TestCaretMovementByCursor() {
      Screen screen = new Screen();
      InputControl input = new InputControl();
      screen.Desktop.Children.Add(input);
      screen.FocusedControl = input;

      input.ProcessCharacter('H');
      input.ProcessCharacter('e');
      input.ProcessCharacter('l');
      input.ProcessCharacter('o');

      input.ProcessKeyPress(Keys.Left, false);

      input.ProcessCharacter('l');

      input.ProcessKeyPress(Keys.Right, false);

      input.ProcessCharacter('!');

      Assert.AreEqual("Hello!", input.Text);
    }
Пример #10
0
    public void TestHomeAndEnd() {
      Screen screen = new Screen();
      InputControl input = new InputControl();
      screen.Desktop.Children.Add(input);
      screen.FocusedControl = input;

      input.ProcessCharacter('W');
      input.ProcessCharacter('o');
      input.ProcessCharacter('r');
      input.ProcessCharacter('l');
      input.ProcessCharacter('d');

      input.ProcessKeyPress(Keys.Home, false);

      input.ProcessCharacter('H');
      input.ProcessCharacter('e');
      input.ProcessCharacter('l');
      input.ProcessCharacter('l');
      input.ProcessCharacter('o');
      input.ProcessCharacter(' ');

      input.ProcessKeyPress(Keys.End, false);

      input.ProcessCharacter('!');

      Assert.AreEqual("Hello World!", input.Text);
    }