Пример #1
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}]");
            }
        }