public void PressingInvalidButtonsCausesException() { var gamePad = new MockedGamePad(); Assert.Throws <ArgumentOutOfRangeException>( delegate() { gamePad.Press(-1); } ); Assert.Throws <ArgumentOutOfRangeException>( delegate() { gamePad.Press(129); } ); }
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 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 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 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; } } }