public void TestIgnoreInvalidShortcut()
        {
            TestPressableControl pressable = new TestPressableControl();

            pressable.ShortcutButton = (Buttons)(-1);

            Assert.IsFalse(pressable.ProcessKeyPress(Keys.D, false));
        }
        public void TestThrowOnInvalidCommand()
        {
            TestPressableControl pressable = new TestPressableControl();

            Assert.Throws <ArgumentException>(
                delegate() { pressable.ProcessCommand((Command)(-1)); }
                );
        }
    public void TestPressByMouse() {
      TestPressableControl pressable = new TestPressableControl();
      pressable.Bounds = new UniRectangle(10, 10, 100, 100);

      // Move the mouse over the control and do a left-click
      pressable.ProcessMouseMove(0, 0, 50, 50);
      pressable.ProcessMousePress(MouseButtons.Left);
      pressable.ProcessMouseRelease(MouseButtons.Left);

      Assert.AreEqual(1, pressable.PressCount);
    }
        public void TestShortcutAssignment()
        {
            TestPressableControl pressable = new TestPressableControl();

            Assert.IsFalse(pressable.ShortcutButton.HasValue);

            pressable.ShortcutButton = Buttons.A;

            Assert.IsTrue(pressable.ShortcutButton.HasValue);
            Assert.AreEqual(Buttons.A, pressable.ShortcutButton.Value);
        }
        public void TestPressByMouse()
        {
            TestPressableControl pressable = new TestPressableControl();

            pressable.Bounds = new UniRectangle(10, 10, 100, 100);

            // Move the mouse over the control and do a left-click
            pressable.ProcessMouseMove(0, 0, 50, 50);
            pressable.ProcessMousePress(MouseButtons.Left);
            pressable.ProcessMouseRelease(MouseButtons.Left);

            Assert.AreEqual(1, pressable.PressCount);
        }
        public void TestShortcutByKeyboard(Buttons button, Keys key)
        {
            TestPressableControl pressable = new TestPressableControl();

            pressable.ShortcutButton = button;

            Assert.IsFalse(pressable.ProcessKeyPress(Keys.D, false));

            Assert.AreEqual(0, pressable.PressCount);

            Assert.IsTrue(pressable.ProcessKeyPress(key, false));
            pressable.ProcessKeyRelease(key);

            Assert.AreEqual(1, pressable.PressCount);
        }
        public void TestShortcutByGamepad()
        {
            TestPressableControl pressable = new TestPressableControl();

            pressable.ShortcutButton = Buttons.A;

            pressable.ProcessButtonPress(Buttons.B);
            pressable.ProcessButtonRelease(Buttons.B);

            Assert.AreEqual(0, pressable.PressCount);

            pressable.ProcessButtonPress(Buttons.A);
            pressable.ProcessButtonRelease(Buttons.A);

            Assert.AreEqual(1, pressable.PressCount);
        }
        public void TestPressWithSpaceBar()
        {
            TestPressableControl pressable = new TestPressableControl();

            pressable.Enabled = false;

            Screen screen = new Screen();

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

            // Press the space bar on the control
            pressable.ProcessKeyPress(Keys.Space, false);
            pressable.ProcessKeyRelease(Keys.Space);

            Assert.AreEqual(1, pressable.PressCount);
        }
        public void TestIgnoredKeys()
        {
            TestPressableControl pressable = new TestPressableControl();

            pressable.Enabled = false;

            Screen screen = new Screen();

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

            // Press the space bar on the control after pressing 'G'
            screen.InjectKeyPress(Keys.G);
            screen.InjectKeyPress(Keys.G);
            screen.InjectKeyPress(Keys.Space);
            screen.InjectKeyRelease(Keys.G);
            screen.InjectKeyRelease(Keys.Space);

            Assert.IsFalse(pressable.Depressed);
        }
    public void TestShortcutAssignment() {
      TestPressableControl pressable = new TestPressableControl();

      Assert.IsFalse(pressable.ShortcutButton.HasValue);

      pressable.ShortcutButton = Buttons.A;

      Assert.IsTrue(pressable.ShortcutButton.HasValue);
      Assert.AreEqual(Buttons.A, pressable.ShortcutButton.Value);
    }
    public void TestIgnoreInvalidShortcut() {
      TestPressableControl pressable = new TestPressableControl();
      pressable.ShortcutButton = (Buttons)(-1);

      Assert.IsFalse(pressable.ProcessKeyPress(Keys.D, false));
    }
    public void TestShortcutByKeyboard(Buttons button, Keys key) {
      TestPressableControl pressable = new TestPressableControl();
      pressable.ShortcutButton = button;

      Assert.IsFalse(pressable.ProcessKeyPress(Keys.D, false));

      Assert.AreEqual(0, pressable.PressCount);

      Assert.IsTrue(pressable.ProcessKeyPress(key, false));
      pressable.ProcessKeyRelease(key);

      Assert.AreEqual(1, pressable.PressCount);
    }
    public void TestShortcutByGamepad() {
      TestPressableControl pressable = new TestPressableControl();
      pressable.ShortcutButton = Buttons.A;

      pressable.ProcessButtonPress(Buttons.B);
      pressable.ProcessButtonRelease(Buttons.B);

      Assert.AreEqual(0, pressable.PressCount);

      pressable.ProcessButtonPress(Buttons.A);
      pressable.ProcessButtonRelease(Buttons.A);
      
      Assert.AreEqual(1, pressable.PressCount);
    }
 public void TestThrowOnInvalidCommand() {
   TestPressableControl pressable = new TestPressableControl();
   Assert.Throws<ArgumentException>(
     delegate() { pressable.ProcessCommand((Command)(-1)); }
   );
 }
    public void TestIgnoredKeys() {
      TestPressableControl pressable = new TestPressableControl();
      pressable.Enabled = false;

      Screen screen = new Screen();
      screen.Desktop.Children.Add(pressable);
      screen.FocusedControl = pressable;

      // Press the space bar on the control after pressing 'G'
      screen.InjectKeyPress(Keys.G);
      screen.InjectKeyPress(Keys.G);
      screen.InjectKeyPress(Keys.Space);
      screen.InjectKeyRelease(Keys.G);
      screen.InjectKeyRelease(Keys.Space);

      Assert.IsFalse(pressable.Depressed);
    }
    public void TestPressWithSpaceBar() {
      TestPressableControl pressable = new TestPressableControl();
      pressable.Enabled = false;
      
      Screen screen = new Screen();
      screen.Desktop.Children.Add(pressable);
      screen.FocusedControl = pressable;
      
      // Press the space bar on the control
      pressable.ProcessKeyPress(Keys.Space, false);
      pressable.ProcessKeyRelease(Keys.Space);

      Assert.AreEqual(1, pressable.PressCount);
    }