public void ReleasingInvalidButtonsCausesException()
        {
            var gamePad = new MockedGamePad();

            Assert.Throws <ArgumentOutOfRangeException>(
                delegate() { gamePad.Release(-1); }
                );
            Assert.Throws <ArgumentOutOfRangeException>(
                delegate() { gamePad.Release(129); }
                );
        }
Example #2
0
        public void TestButtons(Buttons button)
        {
            var gamePad = new MockedGamePad();

            GamePadState state = gamePad.GetState();

            Assert.IsFalse(state.IsButtonDown(button));

            gamePad.Press(button);
            gamePad.Update();

            state = gamePad.GetState();
            Assert.IsTrue(state.IsButtonDown(button));

            gamePad.Release(button);
            gamePad.Update();

            state = gamePad.GetState();
            Assert.IsFalse(state.IsButtonDown(button));
        }
        public void TestExtendedButtons()
        {
            var gamePad = new MockedGamePad();

            gamePad.ButtonCount = 128;

            for (int index = 0; index < 128; ++index)
            {
                ExtendedGamePadState state = gamePad.GetExtendedState();
                Assert.IsFalse(state.IsButtonDown(index));

                gamePad.Press(index);
                gamePad.Update();

                state = gamePad.GetExtendedState();
                Assert.IsTrue(state.IsButtonDown(index));

                gamePad.Release(index);
                gamePad.Update();

                state = gamePad.GetExtendedState();
                Assert.IsFalse(state.IsButtonDown(index));
            }
        }
    public void TestButtons(Buttons button) {
      var gamePad = new MockedGamePad();

      GamePadState state = gamePad.GetState();
      Assert.IsFalse(state.IsButtonDown(button));

      gamePad.Press(button);
      gamePad.Update();

      state = gamePad.GetState();
      Assert.IsTrue(state.IsButtonDown(button));

      gamePad.Release(button);
      gamePad.Update();

      state = gamePad.GetState();
      Assert.IsFalse(state.IsButtonDown(button));
    }