Example #1
0
        public void ShowErrorMessageWhenThereIsNoCell()
        {
            var cellPositions = new List <CellPosition> {
            };

            GameOfLife gameOfLife = new GameOfLife(cellPositions);

            Assert.Throws <Exception>(() => gameOfLife.Play());
        }
Example #2
0
        public void EndIfOnlyTwoCellsAreIntroduced()
        {
            var cellPositions = new List <CellPosition> {
                new CellPosition(0, 1), new CellPosition(1, 1)
            };
            GameOfLife gameOfLife = new GameOfLife(cellPositions);

            var result = gameOfLife.Play();

            Assert.Null(result);
        }
Example #3
0
        public void ReturnAliveCellsOnAnSquarePattern()
        {
            var cellPositions = new List <CellPosition> {
                new CellPosition(0, 0), new CellPosition(0, 1), new CellPosition(1, 0), new CellPosition(1, 1)
            };
            GameOfLife gameOfLife = new GameOfLife(cellPositions);

            var result = gameOfLife.Play();

            Assert.Equal(new List <CellPosition> {
                new CellPosition(0, 0), new CellPosition(0, 1), new CellPosition(1, 0), new CellPosition(1, 1)
            }, result);
        }
Example #4
0
        public void ReturnAliveCellsAndRevivedCellsOnAThreeOnVerticalLineCellsPattern()
        {
            var cellPosition = new List <CellPosition> {
                new CellPosition(1, 1), new CellPosition(2, 1), new CellPosition(3, 1)
            };

            GameOfLife gameOfLife = new GameOfLife(cellPosition);

            var result = gameOfLife.Play();

            Assert.Equal(new List <CellPosition> {
                new CellPosition(2, 1), new CellPosition(2, 2), new CellPosition(2, 0)
            }, result);
        }
Example #5
0
        public void ReturnAliveCellsAfterTwoGenerationsOnAnSquarePattern()
        {
            var cellPositions = new List <CellPosition> {
                new CellPosition(0, 0), new CellPosition(0, 1), new CellPosition(1, 0), new CellPosition(1, 1)
            };

            GameOfLife gameOfLifeFirstRound = new GameOfLife(cellPositions);

            var resultFirstRound = gameOfLifeFirstRound.Play();

            GameOfLife gameOfLifeSecondRound = new GameOfLife(resultFirstRound);

            var resultSecondRound = gameOfLifeSecondRound.Play();

            Assert.Equal(new List <CellPosition> {
                new CellPosition(0, 0), new CellPosition(0, 1), new CellPosition(1, 0), new CellPosition(1, 1)
            }, resultSecondRound);
        }
Example #6
0
        public void ReturnNewPatternAfterTwoGenerationsOnThreeVerticalLinePattern()
        {
            var cellPositions = new List <CellPosition> {
                new CellPosition(0, 0), new CellPosition(0, 1), new CellPosition(0, 2)
            };

            GameOfLife gameOfLifeFirstRound = new GameOfLife(cellPositions);

            var resultFirstRound = gameOfLifeFirstRound.Play();

            GameOfLife gameOfLifeSecondRound = new GameOfLife(resultFirstRound);

            var resultSecondRound = gameOfLifeSecondRound.Play();

            Assert.Equal(new List <CellPosition> {
                new CellPosition(0, 1), new CellPosition(0, 2), new CellPosition(0, 0)
            }, resultSecondRound);
        }