Inheritance Hierarchy
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
The GameOfLifeTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
GameOfLifeTests | Initializes a new instance of the GameOfLifeTests class |
Methods
Properties
Name | Description | |
---|---|---|
IsMockResolver | (Inherited from TestWithMocksOrVisually.) |
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