public GameState LoadNewGame(string fileName) { fileName = LocalNewGameProvider.AddFileNameExtension(fileName); var cells = LoadNew2DCellArray(fileName); var board = new TwoDimensionalBoard(cells); var ruleSet = Configuration.DefaultRuleSets.First(r => r.Key == board.GetDimensions().Count).Value; return(new GameState(board, new DefaultBoardProcessor(ruleSet))); }
public void Tick_Returned2DGameStateHasCorrectBoard_GivenInitialGameState(Cell[,] initialCellArray, Cell[,] expectedCellArray) { var boardProcessor = new DefaultBoardProcessor(new RuleSet("2333")); var gameProcessor = new GameProcessor(0); var board = new TwoDimensionalBoard(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)); }
public void GenerateBoardString_GetsCorrect2DBoardString_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) } }; var board = new TwoDimensionalBoard(cellArray); var gameState = new GameState(board, new DefaultBoardProcessor(new RuleSet("2333"))); var renderer = new TwoDimensionalConsoleRenderer(); var renderString = renderer.GenerateBoardString(gameState); var expectedString = "ooo\n" + "..o\n"; Assert.Equal(expectedString, renderString); }