public void Test() { //Arrange //Row/Column CellState[,] matrix = new CellState[6, 6] { { CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead }, { CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead }, { CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead }, { CellState.Alive, CellState.Alive, CellState.Alive, CellState.Dead, CellState.Dead, CellState.Dead }, { CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead }, { CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead } }; var game = new GameOfLife(matrix); //Act var matrixResult = game.ComputeNextGeneration(); //Assert var cell1 = matrixResult[1, 0]; CellState[,] expectedmatrix = new CellState[6, 6] { { CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead }, { CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead }, { CellState.Dead, CellState.Alive, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead }, { CellState.Dead, CellState.Alive, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead }, { CellState.Dead, CellState.Alive, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead }, { CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead } }; Assert.Equal(expectedmatrix, matrix); }
public void Test_Generation_Should_Get_Expected_Result() { _gameOfLife.SetLivingCell(1, 4); _gameOfLife.SetLivingCell(2, 3); _gameOfLife.SetLivingCell(2, 4); _gameOfLife.ComputeNextGeneration(); _gameOfLife.Cells[1, 3].IsAlive.Should().BeTrue(); _gameOfLife.Cells[1, 4].IsAlive.Should().BeTrue(); _gameOfLife.Cells[2, 3].IsAlive.Should().BeTrue(); _gameOfLife.Cells[2, 4].IsAlive.Should().BeTrue(); }
public void Next_generation_should_be_split_according_to_rules() { _gameOfLife.SetLivingCell(1, 4); _gameOfLife.SetLivingCell(2, 3); _gameOfLife.SetLivingCell(2, 4); _gameOfLife.ComputeNextGeneration(); _gameOfLife.Cells[1, 3].IsAlive.Should().BeTrue(); _gameOfLife.Cells[1, 4].IsAlive.Should().BeTrue(); _gameOfLife.Cells[2, 3].IsAlive.Should().BeTrue(); _gameOfLife.Cells[2, 4].IsAlive.Should().BeTrue(); }
public void ComputeNextGeneration_CellWithMoreThenThreeLiveNeighboor_Dead() { //Arrange //Row/Column CellState[,] matrix = new CellState[6, 6] { { CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead }, { CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead }, { CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead }, { CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead }, { CellState.Dead, CellState.Dead, CellState.Dead, CellState.Alive, CellState.Alive, CellState.Alive }, { CellState.Dead, CellState.Dead, CellState.Dead, CellState.Dead, CellState.Alive, CellState.Alive } }; var game = new GameOfLife(matrix); //Act var matrixResult = game.ComputeNextGeneration(); //Assert var cell1 = matrixResult[4, 4]; Assert.Equal(CellState.Dead, cell1); }
public void ComputeNextGeneration_DeadMatrix_ReturnsDeadMatrix() { //Arrange //Row / Column CellState[,] matrix = new CellState[3, 3] { { CellState.Dead, CellState.Dead, CellState.Dead }, { CellState.Dead, CellState.Dead, CellState.Dead }, { CellState.Dead, CellState.Dead, CellState.Dead } }; var game = new GameOfLife(matrix); //Act var matrixResult = game.ComputeNextGeneration(); //Assert CellState[,] expectedMatrix = new CellState[3, 3] { { CellState.Dead, CellState.Dead, CellState.Dead }, { CellState.Dead, CellState.Dead, CellState.Dead }, { CellState.Dead, CellState.Dead, CellState.Dead } }; Assert.Equal(expectedMatrix, matrix); }