public void GameOfLifeSerializer_Serialization(string template) { GameOfLifeSerializer serializer = new GameOfLifeSerializer(); IGameOfLifeGrid grid = serializer.Deserialize(template); Assert.Equal(template, serializer.Serialize(grid)); }
public void CalculateNextGeneration_AnyLiveCellWithTwoOrThreeLiveNeighbors_Lives(string template, int rowIndex, int columnIndex) { GameOfLifeSerializer serializer = new GameOfLifeSerializer(); GameOfLifeGrid grid = (GameOfLifeGrid)serializer.Deserialize(template); grid.CalculateNextGeneration(); Assert.Equal(CellState.Live, grid[rowIndex, columnIndex].State); }
public void CalculateNextGeneration_AnyLiveCellWithMoreThanThreeLiveNeighbors_Dies(string template) { GameOfLifeSerializer serializer = new GameOfLifeSerializer(); GameOfLifeGrid grid = (GameOfLifeGrid)serializer.Deserialize(template); grid.CalculateNextGeneration(); Assert.Equal(CellState.Dead, grid[1, 1].State); }
public void CalculateNextGeneration_AnyDeadCellWithExactlyThreeLiveNeighbors_BecomesAlive(string template) { GameOfLifeSerializer serializer = new GameOfLifeSerializer(); GameOfLifeGrid grid = (GameOfLifeGrid)serializer.Deserialize(template); Assert.Equal(CellState.Dead, grid[1, 1].State); grid.CalculateNextGeneration(); Assert.Equal(CellState.Live, grid[1, 1].State); }