Exemplo n.º 1
0
 public void ApplyTurnThrowsOnYellowActionWhenRedTurn()
 {
     var gameLogic = new GameLogic();
     var game = new Game()
     {
         CurrentTurnPlayer = Player.Red
     };
     gameLogic.ApplyTurn(game, Player.Yellow, 0);
 }
Exemplo n.º 2
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));
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 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));
 }
Exemplo n.º 5
0
 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);
 }
Exemplo n.º 6
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));
            }
        }
Exemplo n.º 7
0
 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));
 }
Exemplo n.º 8
0
 public GameHub()
 {
     // TODO DI/IoC
     GameRepository = new GameRepository();
     GameLogic = new GameLogic();
 }