Inheritance Hierarchy
DeltaEngine.Platforms TestWithMocksOrVisually
DeltaEngine.Input.Tests GamePadTests
Namespace: DeltaEngine.Input.Tests
Assembly: DeltaEngine.Input.Tests (in DeltaEngine.Input.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The GamePadTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
GamePadTests | Initializes a new instance of the GamePadTests class |
Methods
Name | Description | |
---|---|---|
AdvanceTimeAndUpdateEntities | (Inherited from TestWithMocksOrVisually.) | |
CheckGamePadIsAvailable | ||
InitializeResolver | (Inherited from TestWithMocksOrVisually.) | |
PressingGamePadButtonShowsCircle | ||
RegisterMock T | (Inherited from TestWithMocksOrVisually.) | |
Resolve T | (Inherited from TestWithMocksOrVisually.) | |
RunAfterFirstFrame | (Inherited from TestWithMocksOrVisually.) | |
RunTestAndDisposeResolverWhenDone | (Inherited from TestWithMocksOrVisually.) | |
TestGamePadButtonPress | ||
VibrateOnButtonPress |
Properties
Name | Description | |
---|---|---|
IsMockResolver | (Inherited from TestWithMocksOrVisually.) |
Examples
[Test] public void PressingGamePadButtonShowsCircle() { new FontText(Font.Default, "Press X on GamePad to show red circle", Rectangle.One); var ellipse = new Ellipse(new Rectangle(0.1f, 0.1f, 0.1f, 0.1f), Color.Red); new Command(() => ellipse.Center = Vector2D.Half).Add(new GamePadButtonTrigger( GamePadButton.X, State.Pressed)); new Command(() => ellipse.Center = Vector2D.Zero).Add(new GamePadButtonTrigger( GamePadButton.X, State.Released)); }
[Test] public void VibrateOnButtonPress() { var gamePad = Resolve<GamePad>(); new FontText(Font.Default, "Press X on GamePad to vibrate", Rectangle.One); new Command(() => gamePad.Vibrate(1f)).Add(new GamePadButtonTrigger( GamePadButton.X, State.Pressed)); new Command(() => gamePad.Vibrate(0f)).Add(new GamePadButtonTrigger( GamePadButton.X, State.Released)); }
[Test, CloseAfterFirstFrame] public void TestGamePadButtonPress() { bool isPressed = false; new Command(() => isPressed = true).Add(new GamePadButtonTrigger(GamePadButton.A, State.Pressed)); Assert.IsFalse(isPressed); var mockGamePad = Resolve<GamePad>() as MockGamePad; if (mockGamePad == null) return; //ncrunch: no coverage mockGamePad.SetGamePadState(GamePadButton.A, State.Pressed); AdvanceTimeAndUpdateEntities(); Assert.IsTrue(isPressed); Assert.IsTrue(mockGamePad.IsAvailable); }
[Test] public void CheckGamePadIsAvailable() { var gamePad = Resolve<GamePad>(); if (gamePad is MockGamePad) ((MockGamePad)gamePad).SetUnavailable(); Assert.IsFalse(gamePad.IsAvailable); }
See Also