public void Corner_cells_can_be_set() { World world = new World(Height, Width); world.SetCell(world.GetCoordinate(0, 0), Cell.Alive); world.SetCell(world.GetCoordinate(0, Width - 1), Cell.Alive); world.SetCell(world.GetCoordinate(Height - 1, Width - 1), Cell.Alive); world.SetCell(world.GetCoordinate(Height - 1, 0), Cell.Alive); }
public void ToString_returns_a_grid_representing_the_world() { World world = new World(3, 3); Assert.AreEqual("- - -\r\n- - -\r\n- - -", world.ToString()); world.SetCell(world.GetCoordinate(0, 0), Cell.Alive); world.SetCell(world.GetCoordinate(2, 0), Cell.Alive); world.SetCell(world.GetCoordinate(1, 1), Cell.Alive); world.SetCell(world.GetCoordinate(0, 2), Cell.Alive); world.SetCell(world.GetCoordinate(2, 2), Cell.Alive); Assert.AreEqual("O - O\r\n- O -\r\nO - O", world.ToString()); }
public void Cell_can_be_retrieved_as_set() { World world = new World(Height, Width); const int row = 2; const int column = 2; Coordinate coordinate = world.GetCoordinate(row, column); world.SetCell(coordinate, Cell.Alive); Assert.IsTrue(world.GetCell(coordinate).IsAlive()); }
public void GetNeighbors_returns_3_neighbors_for_corner_cells() { World world = new World(5, 5); Coordinate coordinate = world.GetCoordinate(0, 0); List<Cell> cells = world.GetNeighbors(coordinate); Assert.AreEqual(3, cells.Count); }
public void GetNeighbors_returns_8_neighbors_for_non_edge_cells() { World world = new World(5, 5); Coordinate coordinate = world.GetCoordinate(2, 2); List<Cell> cells = world.GetNeighbors(coordinate); Assert.AreEqual(8, cells.Count); }