Exemplo n.º 1
0
        public void TestGetState()
        {
            var gamePad = new MockedGamePad();

            gamePad.GetState();
            // No exception means success
        }
Exemplo n.º 2
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);
    }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
0
 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 13
0
        public void ReleasingInvalidButtonsCausesException()
        {
            var gamePad = new MockedGamePad();

            Assert.Throws <ArgumentOutOfRangeException>(
                delegate() { gamePad.Release(-1); }
                );
            Assert.Throws <ArgumentOutOfRangeException>(
                delegate() { gamePad.Release(129); }
                );
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 16
0
        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));
            }
        }
Exemplo n.º 17
0
        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));
            }
        }
Exemplo n.º 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));
        }
Exemplo n.º 19
0
        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));
            }
        }
Exemplo n.º 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;
            }
            }
        }
Exemplo n.º 21
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);
    }
Exemplo n.º 22
0
        public void TestName()
        {
            var gamePad = new MockedGamePad();

            StringAssert.Contains("mock", gamePad.Name.ToLower());
        }
Exemplo n.º 23
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;
        }
      }
    }
Exemplo n.º 24
0
 public void TestConstructor() {
   var gamePad = new MockedGamePad();
   Assert.IsNotNull(gamePad);
 }
Exemplo n.º 25
0
        public void TestConstructor()
        {
            var gamePad = new MockedGamePad();

            Assert.IsNotNull(gamePad);
        }
Exemplo n.º 26
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);
    }
Exemplo n.º 27
0
    /// <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);
    }
Exemplo n.º 28
0
 public void TestGetState() {
   var gamePad = new MockedGamePad();
   gamePad.GetState();
   // No exception means success
 }
Exemplo n.º 29
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));
    }
Exemplo n.º 30
0
 public void TestName() {
   var gamePad = new MockedGamePad();
   StringAssert.Contains("mock", gamePad.Name.ToLower());
 }