Inheritance Hierarchy
DeltaEngine.Platforms TestWithMocksOrVisually
Breakout.Tests BallInLevelTests
Namespace: Breakout.Tests
Assembly: Breakout.Tests (in Breakout.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The BallInLevelTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
BallInLevelTests | Initializes a new instance of the BallInLevelTests class |
Methods
Name | Description | |
---|---|---|
AdvanceTimeAndUpdateEntities | (Inherited from TestWithMocksOrVisually.) | |
BallUpdateStartsNewLevel | ||
Draw | ||
FireBall | ||
InitializeResolver | (Inherited from TestWithMocksOrVisually.) | |
PlayGameWithGravity | ||
RegisterMock T | (Inherited from TestWithMocksOrVisually.) | |
ResetBallLosesLive | ||
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() { Resolve<BallInLevel>(); }
[Test, CloseAfterFirstFrame] public void FireBall() { Resolve<BallInLevel>(); var ball = Resolve<Ball>(); Assert.IsTrue(ball.IsVisible); AdvanceTimeAndUpdateEntities(0.01f); var initialBallPosition = new Vector2D(0.5f, 0.86f); Assert.AreEqual(initialBallPosition, ball.Position); if (!IsMockResolver) return; //ncrunch: no coverage Resolve<MockKeyboard>().SetKeyboardState(Key.Space, State.Pressing); AdvanceTimeAndUpdateEntities(); Assert.AreNotEqual(initialBallPosition, ball.Position); }
[Test, CloseAfterFirstFrame] public void ResetBallLosesLive() { var score = Resolve<Score>(); bool lost = false; score.GameOver += () => lost = true; var ball = Resolve<BallInLevel>(); ball.ResetBall(); ball.ResetBall(); ball.ResetBall(); Assert.IsTrue(lost); }
[Test, CloseAfterFirstFrame] public void BallUpdateStartsNewLevel() { if (!IsMockResolver) return; //ncrunch: no coverage Resolve<BallInLevel>(); var level = Resolve<Level>(); level.GetBrickAt(0.25f, 0.125f).IsVisible = false; level.GetBrickAt(0.75f, 0.125f).IsVisible = false; level.GetBrickAt(0.25f, 0.375f).IsVisible = false; level.GetBrickAt(0.75f, 0.375f).IsVisible = false; Assert.AreEqual(0, level.BricksLeft); Resolve<MockKeyboard>().SetKeyboardState(Key.Space, State.Pressing); AdvanceTimeAndUpdateEntities(); Assert.AreNotEqual(0, level.BricksLeft); }
[Test] public void PlayGameWithGravity() { Resolve<Paddle>(); Resolve<BallWithGravity>(); }
See Also