コード例 #1
0
        public void GameOfLifeSerializer_Serialization(string template)
        {
            GameOfLifeSerializer serializer = new GameOfLifeSerializer();
            IGameOfLifeGrid grid = serializer.Deserialize(template);

            Assert.Equal(template, serializer.Serialize(grid));
        }
コード例 #2
0
		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);
		}
コード例 #3
0
		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);
		}
コード例 #4
0
		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);
		}