Beispiel #1
0
        public void TestGetState()
        {
            var gamePad = new MockedGamePad();

            gamePad.GetState();
            // No exception means success
        }
    public void TestMoveRightThumbStick() {
      var gamePad = new MockedGamePad();
      gamePad.MoveRightThumbStick(0.8765f, 0.4321f);
      gamePad.Update();

      GamePadState state = gamePad.GetState();
      Assert.AreEqual(new Vector2(0.8765f, 0.4321f), state.ThumbSticks.Right);
    }
 public void TestMoveLeftThumbStick() {
   var gamePad = new MockedGamePad();
   gamePad.MoveLeftThumbStick(0.1234f, 0.5678f);
   gamePad.Update();
   
   GamePadState state = gamePad.GetState();
   Assert.AreEqual(new Vector2(0.1234f, 0.5678f), state.ThumbSticks.Left);
 }
 public void TestAttachAndDetach() {
   var gamePad = new MockedGamePad();
   Assert.IsFalse(gamePad.IsAttached);
   gamePad.Attach();
   Assert.IsTrue(gamePad.IsAttached);
   gamePad.Detach();
   Assert.IsFalse(gamePad.IsAttached);
 }
        public void MovingInvalidAxisCausesException()
        {
            var gamePad = new MockedGamePad();

            Assert.Throws <ArgumentException>(
                delegate() { gamePad.MoveAxis(ExtendedAxes.X | ExtendedAxes.Y, 0); }
                );
        }
        public void MovingInvalidSliderCausesException()
        {
            var gamePad = new MockedGamePad();

            Assert.Throws <ArgumentException>(
                delegate() { gamePad.MoveSlider(ExtendedSliders.Force1 | ExtendedSliders.Force2, 0); }
                );
        }
        public void MovingUnavailableAxisCausesException()
        {
            var gamePad = new MockedGamePad();

            gamePad.AvailableAxes = 0;

            Assert.Throws <ArgumentException>(
                delegate() { gamePad.MoveAxis(ExtendedAxes.X, 0); }
                );
        }
        public void MovingUnavailableSliderCausesException()
        {
            var gamePad = new MockedGamePad();

            gamePad.AvailableSliders = 0;

            Assert.Throws <ArgumentException>(
                delegate() { gamePad.MoveSlider(ExtendedSliders.Slider1, 0); }
                );
        }
        public void TestPovs(int pov)
        {
            var gamePad = new MockedGamePad();

            gamePad.PovCount = pov + 1;

            gamePad.MovePov(pov, 12345);
            gamePad.Update();
            Assert.AreEqual(12345, gamePad.GetExtendedState().GetPov(pov));
        }
Beispiel #10
0
        public void TestAttachAndDetach()
        {
            var gamePad = new MockedGamePad();

            Assert.IsFalse(gamePad.IsAttached);
            gamePad.Attach();
            Assert.IsTrue(gamePad.IsAttached);
            gamePad.Detach();
            Assert.IsFalse(gamePad.IsAttached);
        }
Beispiel #11
0
        public void TestMoveRightThumbStick()
        {
            var gamePad = new MockedGamePad();

            gamePad.MoveRightThumbStick(0.8765f, 0.4321f);
            gamePad.Update();

            GamePadState state = gamePad.GetState();

            Assert.AreEqual(new Vector2(0.8765f, 0.4321f), state.ThumbSticks.Right);
        }
Beispiel #12
0
        public void TestRightTrigger()
        {
            var gamePad = new MockedGamePad();

            gamePad.PushRightTrigger(0.2468f);
            gamePad.Update();

            GamePadState state = gamePad.GetState();

            Assert.AreEqual(0.2468f, state.Triggers.Right);
        }
        public void ReleasingInvalidButtonsCausesException()
        {
            var gamePad = new MockedGamePad();

            Assert.Throws <ArgumentOutOfRangeException>(
                delegate() { gamePad.Release(-1); }
                );
            Assert.Throws <ArgumentOutOfRangeException>(
                delegate() { gamePad.Release(129); }
                );
        }
Beispiel #14
0
        public void TestMoveLeftThumbStick()
        {
            var gamePad = new MockedGamePad();

            gamePad.MoveLeftThumbStick(0.1234f, 0.5678f);
            gamePad.Update();

            GamePadState state = gamePad.GetState();

            Assert.AreEqual(new Vector2(0.1234f, 0.5678f), state.ThumbSticks.Left);
        }
Beispiel #15
0
        public void TestLeftTrigger()
        {
            var gamePad = new MockedGamePad();

            gamePad.PushLeftTrigger(0.1357f);
            gamePad.Update();

            GamePadState state = gamePad.GetState();

            Assert.AreEqual(0.1357f, state.Triggers.Left);
        }
        public void TestAxisMovement()
        {
            var gamePad = new MockedGamePad();

            foreach (ExtendedAxes axis in Enum.GetValues(typeof(ExtendedAxes)))
            {
                gamePad.AvailableAxes = axis;

                gamePad.MoveAxis(axis, 0.1234f);
                gamePad.Update();
                Assert.AreEqual(0.1234f, gamePad.GetExtendedState().GetAxis(axis));
            }
        }
        public void TestSliderMovement()
        {
            var gamePad = new MockedGamePad();

            foreach (ExtendedSliders slider in Enum.GetValues(typeof(ExtendedSliders)))
            {
                gamePad.AvailableSliders = slider;

                gamePad.MoveSlider(slider, 0.1234f);
                gamePad.Update();
                Assert.AreEqual(0.1234f, gamePad.GetExtendedState().GetSlider(slider));
            }
        }
Beispiel #18
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));
            }
        }
Beispiel #20
0
        public void TestDirectionalPad(Buttons button)
        {
            var gamePad = new MockedGamePad();

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

            GamePadState state = gamePad.GetState();

            switch (button)
            {
            case Buttons.DPadUp: {
                Assert.AreEqual(ButtonState.Pressed, state.DPad.Up);
                Assert.AreEqual(ButtonState.Released, state.DPad.Down);
                break;
            }

            case Buttons.DPadDown: {
                Assert.AreEqual(ButtonState.Pressed, state.DPad.Down);
                Assert.AreEqual(ButtonState.Released, state.DPad.Up);
                break;
            }

            case Buttons.DPadLeft: {
                Assert.AreEqual(ButtonState.Pressed, state.DPad.Left);
                Assert.AreEqual(ButtonState.Released, state.DPad.Right);
                break;
            }

            case Buttons.DPadRight: {
                Assert.AreEqual(ButtonState.Pressed, state.DPad.Right);
                Assert.AreEqual(ButtonState.Released, state.DPad.Left);
                break;
            }
            }
        }
    public void TestRightTrigger() {
      var gamePad = new MockedGamePad();
      gamePad.PushRightTrigger(0.2468f);
      gamePad.Update();

      GamePadState state = gamePad.GetState();
      Assert.AreEqual(0.2468f, state.Triggers.Right);
    }
Beispiel #22
0
        public void TestName()
        {
            var gamePad = new MockedGamePad();

            StringAssert.Contains("mock", gamePad.Name.ToLower());
        }
    public void TestDirectionalPad(Buttons button) {
      var gamePad = new MockedGamePad();
      gamePad.Press(button);
      gamePad.Update();

      GamePadState state = gamePad.GetState();
      switch(button) {
        case Buttons.DPadUp: {
          Assert.AreEqual(ButtonState.Pressed, state.DPad.Up);
          Assert.AreEqual(ButtonState.Released, state.DPad.Down);
          break;
        }
        case Buttons.DPadDown: {
          Assert.AreEqual(ButtonState.Pressed, state.DPad.Down);
          Assert.AreEqual(ButtonState.Released, state.DPad.Up);
          break;
        }
        case Buttons.DPadLeft: {
          Assert.AreEqual(ButtonState.Pressed, state.DPad.Left);
          Assert.AreEqual(ButtonState.Released, state.DPad.Right);
          break;
        }
        case Buttons.DPadRight: {
          Assert.AreEqual(ButtonState.Pressed, state.DPad.Right);
          Assert.AreEqual(ButtonState.Released, state.DPad.Left);
          break;
        }
      }
    }
 public void TestConstructor() {
   var gamePad = new MockedGamePad();
   Assert.IsNotNull(gamePad);
 }
Beispiel #25
0
        public void TestConstructor()
        {
            var gamePad = new MockedGamePad();

            Assert.IsNotNull(gamePad);
        }
    public void TestLeftTrigger() {
      var gamePad = new MockedGamePad();
      gamePad.PushLeftTrigger(0.1357f);
      gamePad.Update();

      GamePadState state = gamePad.GetState();
      Assert.AreEqual(0.1357f, state.Triggers.Left);
    }
    /// <summary>Sets up the collection of available game pads</summary>
    private void setupGamePads() {
      var gamePads = new List<MockedGamePad>();
      var interfaceGamePads = new List<IGamePad>();

      // Add place holders for all unattached game pads
      while (gamePads.Count < 8) {
        var gamePad = new MockedGamePad();
        gamePads.Add(gamePad);
        interfaceGamePads.Add(gamePad);
      }

      this.gamePads = new ReadOnlyCollection<MockedGamePad>(gamePads);
      this.interfaceGamePads = new ReadOnlyCollection<IGamePad>(interfaceGamePads);
    }
 public void TestGetState() {
   var gamePad = new MockedGamePad();
   gamePad.GetState();
   // No exception means success
 }
    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 TestName() {
   var gamePad = new MockedGamePad();
   StringAssert.Contains("mock", gamePad.Name.ToLower());
 }