コード例 #1
0
 public void TestKing_Position()
 {
     for (int i = 0; i < 100; i++)
     {
         Random random = new Random();
         int row = random.Next(0, 7);
         int col = random.Next(0, 7);
         Position position = new Position(row, col);
         King king = new King(position);
         Assert.AreEqual<Position>(king.Position, position, "King`s position is not working correctly");
     }
 }
コード例 #2
0
        public void TestPawnUpMoveInTableBorders()
        {
            List<Figure> figures = new List<Figure>();
            figures.Add(new Pawn(new Position(0, 0), 'A'));
            figures.Add(new Pawn(new Position(0, 2), 'B'));
            figures.Add(new Pawn(new Position(0, 4), 'C'));
            Pawn newPawn = new Pawn(new Position(3, 4), 'D');
            figures.Add(newPawn);
            King newKing = new King(new Position(4, 5));
            figures.Add(newKing);
            GameBoard gameBoard = new GameBoard(figures);
            Engine currentEngine = new Engine(gameBoard, figures);
            Position newPosition = currentEngine.GetNewCoordinates(newPawn, Direction.UR) ;

            Assert.IsFalse(currentEngine.ValidateCommand("DUR"), "You can't move in this direction");
        }
コード例 #3
0
        public void TestPawnImpossibleMove()
        {
            List<Figure> figures = new List<Figure>();
            figures.Add(new Pawn(new Position(0, 0), 'A'));
            figures.Add(new Pawn(new Position(0, 2), 'B'));
            figures.Add(new Pawn(new Position(0, 4), 'C'));
            Pawn newPawn = new Pawn(new Position(3, 4), 'D');
            figures.Add(newPawn);
            King newKing = new King(new Position(4, 5));
            figures.Add(newKing);
            GameBoard gameBoard = new GameBoard(figures);
            Engine currentEngine = new Engine(gameBoard, figures);
            Position newPosition = currentEngine.GetNewCoordinates(newPawn, Direction.DR) ;

            Assert.IsNull(newPosition, "You can't move here,cell is busy");
        }
コード例 #4
0
 public void TestPawnImpossibleOutOfBorderMove()
 {
     List<Figure> figures = new List<Figure>();
     figures.Add(new Pawn(new Position(0, 0), 'A'));
     figures.Add(new Pawn(new Position(0, 2), 'B'));
     figures.Add(new Pawn(new Position(0, 4), 'C'));
     figures.Add(new Pawn(new Position(0, 6), 'D'));
     King newKing = new King(new Position(3, 7));
     figures.Add(newKing);
     GameBoard gameBoard = new GameBoard(figures);
     Engine currentEngine = new Engine(gameBoard, figures);
     Assert.IsNull(currentEngine.GetNewCoordinates(newKing, Direction.UR), "You can't move here");
 }
コード例 #5
0
        public void TestKingPossibleMove()
        {
            List<Figure> figures = new List<Figure>();
            figures.Add(new Pawn(new Position(0, 0), 'A'));
            figures.Add(new Pawn(new Position(0, 2), 'B'));
            figures.Add(new Pawn(new Position(0, 4), 'C'));
            figures.Add(new Pawn(new Position(0, 6), 'D'));
            King newKing = new King(new Position(3, 7));
            figures.Add(newKing);
            GameBoard gameBoard = new GameBoard(figures);
            Engine currentEngine = new Engine(gameBoard, figures);
            bool isNewPosition=(currentEngine.GetNewCoordinates(newKing, Direction.UL))is Position ;

            Assert.IsTrue(isNewPosition, "You can move here");
        }