示例#1
0
        public void ShouldThrowIfBoardIsBelowMinimumSize()
        {
            gameOfLifeRuleMock.Setup(x => x.LifeStatusForNextTick(It.IsAny <DeadOrAliveNeighboursCount>(), It.IsAny <LifeStatus>())).Returns(LifeStatus.Alive);
            var gol = new GameOfLifeBoard(gameOfLifeRuleMock.Object);

            Assert.Throws <InvalidBoardSizeException>(() => gol.CreateNewBoard(2, 2));
        }
示例#2
0
        public void ShouldThrowErrorForInvalidSeedValues()
        {
            gameOfLifeRuleMock.Setup(x => x.LifeStatusForNextTick(It.IsAny <DeadOrAliveNeighboursCount>(), It.IsAny <LifeStatus>())).Returns(LifeStatus.Alive);
            var gol = new GameOfLifeBoard(gameOfLifeRuleMock.Object);

            gol.CreateNewBoard(4, 4);
            Assert.Throws <InvalidSeedException>(() => gol.Seed(new List <RowColumnLifeStatus>()
            {
                new RowColumnLifeStatus(-4, 4, LifeStatus.Alive)
            }));
        }
示例#3
0
文件: Program.cs 项目: lesley86/Ozow
        private static void SetupAndPlayGameOfLife(GameOfLifeBoard gol, int rows, int columns, int tickGenerations, List <RowColumnLifeStatus> seedList)
        {
            var boardVisualizer = new ConsoleBoardOutput();

            gol.CreateNewBoard(rows, columns);
            if (seedList.Any())
            {
                gol.Seed(seedList);
            }

            gol.PlayGame(tickGenerations, boardVisualizer.Output);
        }