示例#1
0
        public void TestWithEmptyMockedChess(
            int moveOrder,
            bool player
            )
        {
            try
            {
                IGame game = new MockedGame(
                    moveOrder,
                    player,
                    new MockedChess());

                var move = new Move(
                    new Square(Files.a, Ranks.one),
                    new Square(Files.b, Ranks.two),
                    MoveType.Normal);

                Assert.Equal(Outcome.Game, game.Outcome);
                Assert.Equal(moveOrder, game.MoveCount);
                Assert.Equal(player, game.CurrentPlayer);
                Assert.False(game.ProcessMove(move));
                Assert.Empty(game.CapturedPieces);
                Assert.Empty(game.MoveEntries);
                Assert.Empty(game.Position);
                Assert.Empty(game.Moves);
                Assert.Equal(0, game.Score);
                Assert.Empty(game.AvailableMoves());
            }
            catch (System.ArgumentOutOfRangeException)
            {
                Assert.True(moveOrder < 0);
            }
        }
示例#2
0
        public void TestWithCustomChess(
            bool player,
            int moveCount
            )
        {
            IGame game = new MockedGame(0, player, new Custom(CustomPositionA));

            var whiteMove = new Move(
                new Square(Files.a, Ranks.one),
                new Square(Files.a, Ranks.two),
                MoveType.Normal);

            var blackMove = new Move(
                new Square(Files.b, Ranks.seven),
                new Square(Files.b, Ranks.six),
                MoveType.Normal);

            var availableMove = player ? whiteMove : blackMove;
            var forbidenMove  = player ? blackMove : whiteMove;

            Assert.Equal(moveCount, game.AvailableMoves().Count);
            Assert.True(game.ProcessMove(availableMove));
            Assert.False(game.ProcessMove(forbidenMove));
        }