Exemplo n.º 1
0
        public void R22_2_SCENARIO_BALL_RANDOM()
        {
            Game  game      = FactoryTest.getGameWithScenario(new BallRandom());
            int   sizeBoard = Properties.DEFAULT_SIZE_BOARD;
            Board board     = game.Board;
            bool  ball      = false;

            for (int i = 0; i < sizeBoard; i++)
            {
                Assert.IsTrue(board.getTile(0, i).hasPiece());
                Assert.IsTrue(board.getTile(0, i).Piece.Player.Equals(game.P1));
                if (board.getTile(0, i).Piece.hasBall())
                {
                    Assert.IsTrue(board.getTile(0, i).Piece.Ball.Player.Equals(game.P1));
                    ball = true;
                }
            }
            Assert.IsTrue(ball);
            ball = false;
            for (int i = 0; i < sizeBoard; i++)
            {
                Assert.IsTrue(board.getTile(sizeBoard - 1, i).hasPiece());
                Assert.IsTrue(board.getTile(sizeBoard - 1, i).Piece.Player.Equals(game.P2));
                if (board.getTile(sizeBoard - 1, i).Piece.hasBall())
                {
                    Assert.IsTrue(board.getTile(sizeBoard - 1, i).Piece.Ball.Player.Equals(game.P2));
                    ball = true;
                }
            }
            Assert.IsTrue(ball);
        }
Exemplo n.º 2
0
        public void R22_1_SCENARIO_STANDARD()
        {
            Game  game      = FactoryTest.getGameWithScenario(new Standart());
            int   sizeBoard = Properties.DEFAULT_SIZE_BOARD;
            Board board     = game.Board;

            for (int i = 0; i < sizeBoard; i++)
            {
                Assert.IsTrue(board.getTile(0, i).hasPiece());
                Assert.IsTrue(board.getTile(0, i).Piece.Player.Equals(game.P1));
                if (i == (sizeBoard / 2))
                {
                    Assert.IsTrue(board.getTile(0, i).Piece.Ball.Player.Equals(game.P1));
                    Assert.IsTrue(board.getTile(0, i).Piece.hasBall());
                }
            }
            for (int i = 0; i < sizeBoard; i++)
            {
                Assert.IsTrue(board.getTile(sizeBoard - 1, i).hasPiece());
                Assert.IsTrue(board.getTile(sizeBoard - 1, i).Piece.Player.Equals(game.P2));
                if (i == sizeBoard / 2)
                {
                    Assert.IsTrue(board.getTile(sizeBoard - 1, i).Piece.Ball.Player.Equals(game.P2));
                    Assert.IsTrue(board.getTile(sizeBoard - 1, i).Piece.hasBall());
                }
            }
        }
Exemplo n.º 3
0
        public void R21_4_GAME_BALL_ENEMY_AMONG_US()
        {
            Game  game      = FactoryTest.getGameWithScenario(new EnemyAmongUs());
            int   nbBallP1  = 0;
            int   nbBallP2  = 0;
            int   sizeBoard = Properties.DEFAULT_SIZE_BOARD;
            Board board     = game.Board;

            for (int i = 0; i < sizeBoard; i++)
            {
                for (int j = 0; j < sizeBoard; j++)
                {
                    if (board.getTile(i, j).hasPiece() && board.getTile(i, j).Piece.hasBall())
                    {
                        if (board.getTile(i, j).Piece.Player.Equals(game.P1))
                        {
                            nbBallP1++;
                        }
                        if (board.getTile(i, j).Piece.Player.Equals(game.P2))
                        {
                            nbBallP2++;
                        }
                    }
                }
            }
            Assert.AreEqual(nbBallP1, nbBallP2);
            Assert.AreEqual(1, nbBallP2);
        }
Exemplo n.º 4
0
        public void R21_3_GAME_PIECES_NUMBER_OF_PIECES_BALL_RANDOM()
        {
            Game  game      = FactoryTest.getGameWithScenario(new BallRandom());
            int   nbPieceP1 = 0;
            int   nbPieceP2 = 0;
            int   sizeBoard = Properties.DEFAULT_SIZE_BOARD;
            Board board     = game.Board;

            for (int i = 0; i < sizeBoard; i++)
            {
                for (int j = 0; j < sizeBoard; j++)
                {
                    if (board.getTile(i, j).hasPiece())
                    {
                        if (board.getTile(i, j).Piece.Player.Equals(game.P1))
                        {
                            nbPieceP1++;
                        }
                        if (board.getTile(i, j).Piece.Player.Equals(game.P2))
                        {
                            nbPieceP2++;
                        }
                    }
                }
            }
            Assert.AreEqual(nbPieceP1, nbPieceP2);
            Assert.AreEqual(nbPieceP1, sizeBoard);
        }
Exemplo n.º 5
0
        public void R24_1_VICTORY_P2()
        {
            Game game = FactoryTest.getGameWithScenario(new Standart());

            Assert.AreEqual(0, game.verifyVictory());
            game.Board.getTile(0, 0).Piece = game.Board.getTile(game.Board.SizeBoard - 1, game.Board.SizeBoard / 2).Piece;
            Assert.AreEqual(2, game.verifyVictory());
        }
Exemplo n.º 6
0
        public void R22_3_SCENARIO_ENEMY_AMONG_US()
        {
            Game  game      = FactoryTest.getGameWithScenario(new EnemyAmongUs());
            int   sizeBoard = Properties.DEFAULT_SIZE_BOARD;
            Board board     = game.Board;

            int nbPieceP1 = 0;
            int nbPieceP2 = 0;

            for (int i = 0; i < sizeBoard; i++)
            {
                if (i == sizeBoard / 2)
                {
                    Assert.IsTrue(board.getTile(0, i).Piece.Ball.Player.Equals(game.P1));
                    nbPieceP1++;
                }
                else if (board.getTile(0, i).Piece.Player.Equals(game.P1))
                {
                    nbPieceP1++;
                }
                else if (board.getTile(0, i).Piece.Player.Equals(game.P2))
                {
                    nbPieceP2++;
                }
            }

            Assert.AreEqual(nbPieceP1, sizeBoard - 2);
            Assert.AreEqual(nbPieceP2, 2);
            nbPieceP1 = 0;
            nbPieceP2 = 0;

            for (int i = 0; i < sizeBoard; i++)
            {
                if (i == sizeBoard / 2)
                {
                    Assert.IsTrue(board.getTile(sizeBoard - 1, i).Piece.Ball.Player.Equals(game.P2));
                    nbPieceP2++;
                }
                else if (board.getTile(sizeBoard - 1, i).Piece.Player.Equals(game.P1))
                {
                    nbPieceP1++;
                }
                else if (board.getTile(sizeBoard - 1, i).Piece.Player.Equals(game.P2))
                {
                    nbPieceP2++;
                }
            }

            Assert.AreEqual(nbPieceP2, sizeBoard - 2);
            Assert.AreEqual(nbPieceP1, 2);
        }