Beispiel #1
0
        public void TestValidMoves()
        {
            var knight = new Knight(board, Color.White);

            board.AddPieceToTheGame(knight, board[4, 4]);

            string str = knight.ToString();

            Assert.IsTrue(knight.Move(board[3, 6]));
            Assert.IsTrue(knight.Move(board[5, 5]));
            Assert.IsTrue(knight.Move(board[7, 6]));
        }
Beispiel #2
0
        public void TestValidMoves()
        {
            var rook = new Rook(board, Color.White);

            board.AddPieceToTheGame(rook, board[4, 4]);

            Assert.IsTrue(rook.Move(board[7, 4]));
            Assert.IsTrue(board[4, 4].Empty);
            Assert.IsFalse(board[7, 4].Empty);

            Assert.IsTrue(rook.Move(board[7, 7]));
            Assert.IsTrue(rook.Move(board[0, 7]));
            Assert.IsTrue(rook.Move(board[0, 0]));
            Assert.IsTrue(rook.Move(board[0, 1]));
        }
Beispiel #3
0
        public void TestNotMovingIntoCheck()
        {
            var rook      = new Rook(board, Color.White);
            var enemyRook = new Rook(board, Color.Black);

            board.AddPieceToTheGame(rook, board[0, 3]);
            board.AddPieceToTheGame(enemyRook, board[0, 5]);

            king.Move(board[4, 5]);
            Assert.IsFalse(board.IsKingSafe(Color.White));

            king.Move(board[4, 4]);
            Assert.IsTrue(board.IsKingSafe(Color.White));

            king.Move(board[4, 3]);
            Assert.IsTrue(board.IsKingSafe(Color.White));;
        }
Beispiel #4
0
        public void CheckKingSafety()
        {
            var king = new King(board, Color.White);

            board.AddPieceToTheGame(king, board[4, 4]);
            Assert.IsTrue(board.IsKingSafe(Color.White));

            var friend = new Rook(board, Color.White);

            board.AddPieceToTheGame(friend, board[4, 5]);
            Assert.IsTrue(board.IsKingSafe(Color.White));

            var enemy = new Rook(board, Color.Black);

            board.AddPieceToTheGame(enemy, board[0, 4]);
            Assert.IsFalse(board.IsKingSafe(Color.White));
        }
Beispiel #5
0
 public void Init()
 {
     board = new ChessBoard(false);
     king  = new King(board, Color.White);
     board.AddPieceToTheGame(king, board[4, 4]);
 }