Inheritance Hierarchy
DeltaEngine.Platforms TestWithMocksOrVisually
Breakout.Tests PaddleTests
Namespace: Breakout.Tests
Assembly: Breakout.Tests (in Breakout.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The PaddleTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
PaddleTests | Initializes a new instance of the PaddleTests class |
Methods
Name | Description | |
---|---|---|
AdvanceTimeAndUpdateEntities | (Inherited from TestWithMocksOrVisually.) | |
ControlPaddleVirtuallyWithGamePad | ||
ControlPaddleVirtuallyWithKeyboard | ||
ControlPaddleVirtuallyWithMouse | ||
Draw | ||
InitializeResolver | (Inherited from TestWithMocksOrVisually.) | |
IsBallReleasedAfterSpacePressed | ||
RegisterMock T | (Inherited from TestWithMocksOrVisually.) | |
Resolve T | (Inherited from TestWithMocksOrVisually.) | |
RunAfterFirstFrame | (Inherited from TestWithMocksOrVisually.) | |
RunTestAndDisposeResolverWhenDone | (Inherited from TestWithMocksOrVisually.) |
Properties
Name | Description | |
---|---|---|
IsMockResolver | (Inherited from TestWithMocksOrVisually.) |
Examples
[Test] public void Draw() { var ball = Resolve<TestBall>(); var paddle = Resolve<Paddle>(); Assert.AreEqual(0.5f, paddle.Position.X); Assert.IsTrue(ball.IsCurrentlyOnPaddle); Assert.AreEqual(0.5f, ball.Position.X); }
[Test] public void ControlPaddleVirtuallyWithKeyboard() { if (!IsMockResolver) return; //ncrunch: no coverage Resolve<TestBall>(); var paddle = Resolve<Paddle>(); var keyboard = Resolve<MockKeyboard>(); keyboard.SetKeyboardState(Key.CursorLeft, State.Pressed); AssertPaddleMovesLeftCorrectly(paddle); keyboard.SetKeyboardState(Key.CursorLeft, State.Released); keyboard.SetKeyboardState(Key.CursorRight, State.Pressed); AssertPaddleMovesRightCorrectly(paddle); }
[Test, CloseAfterFirstFrame] public void ControlPaddleVirtuallyWithGamePad() { if (!IsMockResolver) return; //ncrunch: no coverage var paddle = Resolve<Paddle>(); var gamePad = Resolve<MockGamePad>(); gamePad.SetGamePadState(GamePadButton.Left, State.Pressed); AssertPaddleMovesLeftCorrectly(paddle); gamePad.SetGamePadState(GamePadButton.Left, State.Released); gamePad.SetGamePadState(GamePadButton.Right, State.Pressed); AssertPaddleMovesRightCorrectly(paddle); }
[Test, CloseAfterFirstFrame] public void ControlPaddleVirtuallyWithMouse() { if (!IsMockResolver) return; //ncrunch: no coverage var paddle = Resolve<Paddle>(); var mouse = Resolve<MockMouse>(); mouse.SetNativePosition(new Vector2D(0.45f, 0.76f)); mouse.SetButtonState(MouseButton.Left, State.Pressed); AssertPaddleMovesLeftCorrectly(paddle); mouse.SetNativePosition(new Vector2D(0.55f, 0.76f)); mouse.SetButtonState(MouseButton.Left, State.Released); mouse.SetButtonState(MouseButton.Left, State.Pressed); AssertPaddleMovesRightCorrectly(paddle); }
[Test, CloseAfterFirstFrame] public void IsBallReleasedAfterSpacePressed() { if (!IsMockResolver) return; //ncrunch: no coverage var ball = Resolve<TestBall>(); Resolve<Paddle>(); PressSpaceOneTick(); Assert.IsFalse(ball.IsCurrentlyOnPaddle); Assert.AreNotEqual(0.5f, ball.Position.X); }
See Also