public void ApplyTurnThrowsOnYellowActionWhenRedTurn() { var gameLogic = new GameLogic(); var game = new Game() { CurrentTurnPlayer = Player.Red }; gameLogic.ApplyTurn(game, Player.Yellow, 0); }
public void DetermineGameOverStateTestInProgress() { var gameLogic = new GameLogic(); var game = new Game(); game.Cells = new int[,] { { 2, 1, 0, 1 }, { 1, 2, 1, 2 }, { 1, 2, 1, 2 }, { 1, 2, 1, 2 }, }; Assert.AreEqual(GameOverState.InProgress, gameLogic.DetermineGameOverState(game)); }
public void ApplyTurnTestAppliesAndTogglesPlayer() { var gameLogic = new GameLogic(); var game = new Game() { GameOverState = GameOverState.InProgress }; game.Cells = new int[,] { { 2, 1, 0, 0 }, { 1, 2, 1, 2 }, { 1, 2, 1, 2 }, { 1, 2, 1, 2 }, }; var column = 3; gameLogic.ApplyTurn(game, Player.Red, column); Assert.AreEqual(GameOverState.InProgress, game.GameOverState); Assert.AreEqual((int)Player.Red, game.Cells[3, 0]); Assert.AreEqual(Player.Yellow, game.CurrentTurnPlayer); }
public void DetermineGameOverStateTestRedWinColumn() { var gameLogic = new GameLogic(); var game = new Game(); game.Cells = new int[,] { { 0, 0, 0, 1 }, { 0, 0, 2, 1 }, { 0, 0, 2, 1 }, { 0, 2, 2, 1 }, }; Assert.AreEqual(GameOverState.RedWin, gameLogic.DetermineGameOverState(game)); }
public void GetNextCellIndexThrowsOnFullColumn() { var gameLogic = new GameLogic(); var game = new Game(); game.Cells = new int[,] { { 2, 0, 0, 0 }, { 1, 0, 0, 0 }, { 2, 0, 0, 0 }, { 1, 0, 0, 0 }, }; gameLogic.GetNextCellIndex(game, 0); }
public void GetNextCellIndexReturnsExpectedValue() { var gameLogic = new GameLogic(); var game = new Game(); game.Cells = new int[,] { { 1, 0, 0, 0 }, { 1, 0, 0, 0 }, { 1, 0, 0, 0 }, { 1, 0, 0, 0 }, }; var column = 0; // clear cells starting with top one and check that GetNextCellIndex returns just-cleared row value for (var row = 0; row < game.MaxRows; row += 1) { game.Cells[row, column] = 0; Assert.AreEqual(row, gameLogic.GetNextCellIndex(game, column)); } }
public void DetermineGameOverStateTestRedWinDiag1() { var gameLogic = new GameLogic(); var game = new Game(); game.Cells = new int[,] { { 1, 0, 0, 0 }, { 2, 1, 0, 0 }, { 2, 2, 1, 2 }, { 1, 2, 1, 1 }, }; Assert.AreEqual(GameOverState.RedWin, gameLogic.DetermineGameOverState(game)); }
public GameHub() { // TODO DI/IoC GameRepository = new GameRepository(); GameLogic = new GameLogic(); }