GameOfLifeTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Platforms TestWithMocksOrVisually
    GameOfLife.Tests GameOfLifeTests

Namespace: GameOfLife.Tests
Assembly: GameOfLife.Tests (in GameOfLife.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class GameOfLifeTests : TestWithMocksOrVisually

The GameOfLifeTests type exposes the following members.

Constructors

  NameDescription
Public methodGameOfLifeTests
Initializes a new instance of the GameOfLifeTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodBlinkerShouldChangeOrientationAfterOneTick
Public methodBoundCheckOnTheBottomLeftBorderOfTheGrid
Public methodBoundCheckOnTheBottomRightBorderOfTheGrid
Public methodBoundCheckOnTheTopLeftBorderOfTheGrid
Public methodBoundCheckOnTheTopRightBorderOfTheGrid
Public methodCheckForLiveCellOnTheBottom
Public methodCheckForLiveCellOnTheBottomLeft
Public methodCheckForLiveCellOnTheBottomRight
Public methodCheckForLiveCellOnTheLeft
Public methodCheckForLiveCellOnTheRight
Public methodCheckForLiveCellOnTheTop
Public methodCheckForLiveCellOnTheTopLeft
Public methodCheckForLiveCellOnTheTopRight
Public methodCreateGameOfLife
Public methodDeadCellWithExactlyThreeLiveNeighborsComesToLiveAgain
Public methodGridShouldHaveRightSize
Public methodGridToString
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Public methodLiveCellWithFewerThanTwoLiveNeighborsDies
Public methodLiveCellWithMoreThanThreeLiveNeighborsDies
Public methodLiveCellWithThreeNeighborsLives
Public methodLiveCellWithTwoNeighborsLives
Public methodNewCreatedGridShouldHaveJustDeadCells
Public methodOktagonSeedShouldHaveSameShapeAgainAfterFiveTicks
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Public methodResetGameState
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunningSimulationIncrementsGenerationByOne
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Public methodStaticObjectShouldNotChangeShapeAfterOneTick
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[Test, CloseAfterFirstFrame]
public void GridShouldHaveRightSize()
{
    var gridSize = new Size(5);
    Assert.AreEqual(gridSize, gameOfLife.GameGrid.Dimension);
}
[Test, CloseAfterFirstFrame]
public void NewCreatedGridShouldHaveJustDeadCells()
{
    Assert.AreEqual(0, gameOfLife.Population);
}
[Test, CloseAfterFirstFrame]
public void RunningSimulationIncrementsGenerationByOne()
{
    Assert.AreEqual(0, gameOfLife.Generation);
    gameOfLife.SimulateNextGeneration();
    Assert.AreEqual(1, gameOfLife.Generation);
}
[Test, CloseAfterFirstFrame]
public void ResetGameState()
{
    ReviveAllCells();
    gameOfLife.SimulateNextGeneration();
    gameOfLife.ResetGameState();
    Assert.AreEqual(0, gameOfLife.Population);
    Assert.AreEqual(0, gameOfLife.Generation);
}
[Test, CloseAfterFirstFrame]
public void CheckForLiveCellOnTheTop()
{
    gameOfLife.ReviveCellAtPosition(2, 1);
    AssertOneNeighborCellIsAliveFromCenterOfGrid();
}
[Test, CloseAfterFirstFrame]
public void CheckForLiveCellOnTheTopRight()
{
    gameOfLife.ReviveCellAtPosition(3, 1);
    AssertOneNeighborCellIsAliveFromCenterOfGrid();
}
[Test, CloseAfterFirstFrame]
public void CheckForLiveCellOnTheRight()
{
    gameOfLife.ReviveCellAtPosition(3, 2);
    AssertOneNeighborCellIsAliveFromCenterOfGrid();
}
[Test, CloseAfterFirstFrame]
public void CheckForLiveCellOnTheBottomRight()
{
    gameOfLife.ReviveCellAtPosition(3, 3);
    AssertOneNeighborCellIsAliveFromCenterOfGrid();
}
[Test, CloseAfterFirstFrame]
public void CheckForLiveCellOnTheBottom()
{
    gameOfLife.ReviveCellAtPosition(2, 3);
    AssertOneNeighborCellIsAliveFromCenterOfGrid();
}
[Test, CloseAfterFirstFrame]
public void CheckForLiveCellOnTheBottomLeft()
{
    gameOfLife.ReviveCellAtPosition(1, 3);
    AssertOneNeighborCellIsAliveFromCenterOfGrid();
}
[Test, CloseAfterFirstFrame]
public void CheckForLiveCellOnTheLeft()
{
    gameOfLife.ReviveCellAtPosition(1, 2);
    AssertOneNeighborCellIsAliveFromCenterOfGrid();
}
[Test, CloseAfterFirstFrame]
public void CheckForLiveCellOnTheTopLeft()
{
    gameOfLife.ReviveCellAtPosition(1, 1);
    AssertOneNeighborCellIsAliveFromCenterOfGrid();
}
[Test, CloseAfterFirstFrame]
public void BoundCheckOnTheTopLeftBorderOfTheGrid()
{
    AssertNoNeighborCellIsAliveOutsideTheGridBorder(0, 0);
}
[Test, CloseAfterFirstFrame]
public void BoundCheckOnTheTopRightBorderOfTheGrid()
{
    AssertNoNeighborCellIsAliveOutsideTheGridBorder(4, 0);
}
[Test, CloseAfterFirstFrame]
public void BoundCheckOnTheBottomRightBorderOfTheGrid()
{
    AssertNoNeighborCellIsAliveOutsideTheGridBorder(4, 4);
}
[Test, CloseAfterFirstFrame]
public void BoundCheckOnTheBottomLeftBorderOfTheGrid()
{
    AssertNoNeighborCellIsAliveOutsideTheGridBorder(0, 4);
}
[Test, CloseAfterFirstFrame]
public void LiveCellWithFewerThanTwoLiveNeighborsDies()
{
    InitializeGameOfLife(new Size(3));
    gameOfLife.BatchReviveCells(new[,] { { 1, 1 }, { 2, 2 } });
[Test, CloseAfterFirstFrame]
public void LiveCellWithTwoNeighborsLives()
{
    InitializeGameOfLife(new Size(3));
    gameOfLife.BatchReviveCells(new[,] { { 1, 1 }, { 1, 2 }, { 2, 1 } });
[Test, CloseAfterFirstFrame]
public void LiveCellWithThreeNeighborsLives()
{
    InitializeGameOfLife(new Size(3));
    gameOfLife.BatchReviveCells(new[,] { { 0, 1 }, { 1, 1 }, { 1, 2 }, { 2, 1 } });
[Test, CloseAfterFirstFrame]
public void LiveCellWithMoreThanThreeLiveNeighborsDies()
{
    InitializeGameOfLife(new Size(3));
    ReviveAllCells();
    gameOfLife.SimulateNextGeneration();
    Assert.IsFalse(gameOfLife.IsCellAlive(1, 1));
}
[Test, CloseAfterFirstFrame]
public void DeadCellWithExactlyThreeLiveNeighborsComesToLiveAgain()
{
    InitializeGameOfLife(new Size(3));
    gameOfLife.BatchReviveCells(new[,] { { 0, 0 }, { 1, 0 }, { 2, 0 } });
[Test, CloseAfterFirstFrame]
public void BlinkerShouldChangeOrientationAfterOneTick()
{
    gameOfLife.BatchReviveCells(new[,] { { 2, 1 }, { 2, 2 }, { 2, 3 } });
[Test, CloseAfterFirstFrame]
public void StaticObjectShouldNotChangeShapeAfterOneTick()
{
    var staticSeed = new[,] { { 2, 1 }, { 1, 2 }, { 3, 2 }, { 2, 3 } };
    gameOfLife.BatchReviveCells(staticSeed);
    gameOfLife.SimulateNextGeneration();
    AssertAllCellsAreAlive(staticSeed);
}
[Test, CloseAfterFirstFrame]
public void OktagonSeedShouldHaveSameShapeAgainAfterFiveTicks()
{
    InitializeGameOfLife(new Size(10));
    gameOfLife.BatchReviveCells(GameManager.OktagonSeed);
    for (int i = 0; i < 5; i++)
        gameOfLife.SimulateNextGeneration();
    AssertAllCellsAreAlive(GameManager.OktagonSeed);
}
        [Test]
        public void GridToString()
        {
            var cellsToVisualize = new[,]
            { { 2, 0 }, { 1, 1 }, { 3, 1 }, { 0, 2 }, { 2, 2 }, { 4, 2 }, { 2, 3 }, { 2, 4 } };
            gameOfLife.BatchReviveCells(cellsToVisualize);
            const string ExpectedVisualGrid = @"--#--
-#-#-
#-#-#
--#--
--#--";
            Assert.AreEqual(ExpectedVisualGrid, gameOfLife.ToString());
        }
    }
See Also