BallInLevelTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  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

public class BallInLevelTests : TestWithMocksOrVisually

The BallInLevelTests type exposes the following members.

Constructors

  NameDescription
Public methodBallInLevelTests
Initializes a new instance of the BallInLevelTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodBallUpdateStartsNewLevel
Public methodDraw
Public methodFireBall
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Public methodPlayGameWithGravity
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Public methodResetBallLosesLive
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
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