public void GenerateBoardString_GetsCorrect3DBoardString_GivenGameState()
        {
            var cellArray = new [, , ]
            {
                {
                    { new Cell(0, CellState.Alive), new Cell(1, CellState.Alive) },
                    { new Cell(0, CellState.Dead), new Cell(1, CellState.Alive) },
                    { new Cell(0, CellState.Dead), new Cell(1, CellState.Alive) }
                },
                {
                    { new Cell(0, CellState.Alive), new Cell(1, CellState.Alive) },
                    { new Cell(0, CellState.Dead), new Cell(1, CellState.Alive) },
                    { new Cell(0, CellState.Dead), new Cell(1, CellState.Alive) }
                }
            };

            var board = new ThreeDimensionalBoard(cellArray);

            var renderer = new ThreeDimensionalConsoleRenderer();

            var gameState = new GameState(board, new DefaultBoardProcessor(new RuleSet("4555")));

            var renderString = renderer.GenerateBoardString(gameState);

            var expectedString = "----------\n" +
                                 ".. | oo | \n" +
                                 ".. | oo | \n" +
                                 "oo | oo | \n" +
                                 "----------\n";

            Assert.Equal(expectedString, renderString);
        }
예제 #2
0
        public GameState LoadNewGame(string fileName)
        {
            fileName = LocalNewGameProvider.AddFileNameExtension(fileName);
            var cells = LoadNew3DCellArray(fileName);

            var board = new ThreeDimensionalBoard(cells);

            var ruleSet = Configuration.DefaultRuleSets.First(r => r.Key == board.GetDimensions().Count).Value;

            return(new GameState(board, new DefaultBoardProcessor(ruleSet)));
        }
예제 #3
0
        public void Tick_Returned3DGameStateHasCorrectBoard_GivenInitialGameState(Cell[,,] initialCellArray, Cell[,,] expectedCellArray)
        {
            var boardProcessor = new DefaultBoardProcessor(new RuleSet("4555"));
            var gameProcessor  = new GameProcessor(0);

            var board = new ThreeDimensionalBoard(initialCellArray);

            var initialGameState = new GameState(board, boardProcessor);

            initialGameState = gameProcessor.StartNewGame(initialGameState);

            var nextGameState = gameProcessor.Tick();

            var actualCellArray = (Cell[, , ])nextGameState.Board.GetCellArray();

            Assert.Equal(JsonConvert.SerializeObject(expectedCellArray), JsonConvert.SerializeObject(actualCellArray));
        }