Exemplo n.º 1
0
        public void TestBasicMovement()
        {
            var board = TestBoard.PopulatedDefault();

            Assert.IsTrue(board.TryMovePiece(board[2, 1], 2, 2), "pawn could not move 1 forward");
            Assert.IsFalse(board.TryMovePiece(board[2, 2], 2, 4), "pawn could move 2 forward, despite having already moved");
            Assert.IsTrue(board.TryMovePiece(board[3, 1], 3, 3), "pawn could not move 2 forward");
        }
Exemplo n.º 2
0
        private void TestGameInternal(string moveSource, bool sourceUsesCheckInsteadOfCheckmate = false)
        {
            var moves = moveSource.Split('.').ToArray();
            var board = TestBoard.PopulatedDefault();

            int turn = 0;

            while (!board.CheckForEndOfGame())
            {
                Assert.IsTrue(turn < moves.Length, "game is still going despite there being no more moves");
                var move = moves[turn];
                Assert.IsTrue(board.TryPerformAlgebraicChessNotationMove(move), $"move failed to execute [{turn}: {move}]");
                turn += 1;
            }
            string LastMove = moves[turn - 1];

            if (!(LastMove.EndsWith('#') || sourceUsesCheckInsteadOfCheckmate && LastMove.EndsWith('+')))
            {
                Assert.IsTrue(turn == moves.Length, $"game ended prematurely [{turn} / {moves.Length}]");
            }
        }