Пример #1
0
        public async Task UndoAndRedo_AllMovesUndo_ThenRedoOne()
        {
            var stat = new MoqStatictics();
            var game = GetSubject(gameStatistics: stat);

            //move are
            var player1 = new PresetTestPlayer(GameSide.Black,
                                               PresetTestPlayer.FirstWalkMove,
                                               PresetTestPlayer.FirstWalkMove,
                                               PresetTestPlayer.FirstWalkMove);
            var player2 = new PresetTestPlayer(GameSide.Red,
                                               PresetTestPlayer.FirstWalkMove,
                                               PresetTestPlayer.FirstWalkMove,
                                               PresetTestPlayer.UndoMove,
                                               PresetTestPlayer.UndoMove,
                                               PresetTestPlayer.RedoMove);

            game.Start(player1, player2);
            await game;

            Assert.Equal(9, stat.BoardHistory.Count);
            Assert.Equal(stat.BoardHistory[2], game.Board);
            Assert.Equal(3u, game.Turn);
            Assert.Equal(player2, game.CurrentPlayer);
        }
Пример #2
0
        public async Task Redo_WalkMoveShouldBreakFurtherRedoMoves()
        {
            var stat = new MoqStatictics();
            var game = GetSubject(gameStatistics: stat);

            stat.Append(null, game); //append initial board as well

            var player1 = new PresetTestPlayer(GameSide.Black,
                                               PresetTestPlayer.FirstWalkMove,
                                               PresetTestPlayer.FirstWalkMove,
                                               PresetTestPlayer.UndoMove,
                                               PresetTestPlayer.UndoMove,
                                               PresetTestPlayer.FirstWalkMove,
                                               PresetTestPlayer.RedoMove);
            var player2 = new PresetTestPlayer(GameSide.Red,
                                               PresetTestPlayer.FirstWalkMove,
                                               PresetTestPlayer.FirstWalkMove,
                                               PresetTestPlayer.FirstWalkMove);

            game.Start(player1, player2);
            await game;

            Assert.Equal(GameStatus.Error, game.Status);
            Assert.IsType <NoSuchMoveException>(game.Error);
        }
Пример #3
0
        public async Task Start_SingleJumpMoveExistOnly_RedWon()
        {
            var game    = GetSubject(boardBuilder: new PresetBoardBuilder());
            var player1 = new PresetTestPlayer(GameSide.Red, PresetTestPlayer.FirstWalkMove);
            var player2 = new PresetTestPlayer(GameSide.Black);

            game.Start(player1, player2);
            await game;

            Assert.Equal(GameStatus.Player1Wins, game.Status);
            Assert.Equal(1u, game.Turn);
            Assert.Equal(player2, game.CurrentPlayer);
        }
Пример #4
0
        public async Task Start_AfterSecondMove_TurnToFirstPlayerAgain()
        {
            var game    = GetSubject();
            var player1 = new PresetTestPlayer(GameSide.Black, PresetTestPlayer.FirstWalkMove);
            var player2 = new PresetTestPlayer(GameSide.Red, PresetTestPlayer.FirstWalkMove);

            game.Start(player1, player2);
            await game;

            //Assert.Equal(GameStatus.Stopped, game.Status);
            Assert.Equal(2u, game.Turn);
            Assert.Equal(player1, game.CurrentPlayer);
        }
Пример #5
0
        public async Task Start_BeforeAnyMove_InitialGameState()
        {
            var game    = GetSubject();
            var player1 = new PresetTestPlayer(GameSide.Black /*, NO MOVES available */);
            var player2 = new PresetTestPlayer(GameSide.Red /*, NO MOVES available */);

            game.Start(player1, player2);
            await game;

            //Assert.Equal(GameStatus.Stopped, game.Status);
            Assert.Equal(0u, game.Turn);
            Assert.Equal(player1, game.CurrentPlayer);
        }
Пример #6
0
        public async Task Undo_FirstMove()
        {
            var stat = new MoqStatictics();
            var game = GetSubject(gameStatistics: stat);

            stat.Append(null, game); //append initial board as well

            var player1 = new PresetTestPlayer(GameSide.Black,
                                               PresetTestPlayer.FirstWalkMove,
                                               PresetTestPlayer.UndoMove);
            var player2 = new PresetTestPlayer(GameSide.Red,
                                               PresetTestPlayer.FirstWalkMove);

            game.Start(player1, player2);
            await game;

            Assert.Equal(5, stat.BoardHistory.Count); //init board + 3 moves + terminal board
            Assert.Equal(stat.BoardHistory[0], game.Board);
            Assert.Equal(0u, game.Turn);
            Assert.Equal(player1, game.CurrentPlayer);
        }
Пример #7
0
        public async Task Undo_AllMoves_EnemyFirstMoveLeft()
        {
            var stat = new MoqStatictics();
            var game = GetSubject(gameStatistics: stat);

            var player1 = new PresetTestPlayer(GameSide.Black,
                                               PresetTestPlayer.FirstWalkMove,
                                               PresetTestPlayer.FirstWalkMove,
                                               PresetTestPlayer.FirstWalkMove);
            var player2 = new PresetTestPlayer(GameSide.Red,
                                               PresetTestPlayer.FirstWalkMove,
                                               PresetTestPlayer.FirstWalkMove,
                                               PresetTestPlayer.UndoMove,
                                               PresetTestPlayer.UndoMove);

            game.Start(player1, player2);
            await game;

            Assert.Equal(8, stat.BoardHistory.Count);
            Assert.Equal(stat.BoardHistory[0], game.Board);
            Assert.Equal(1u, game.Turn);
            Assert.Equal(player2, game.CurrentPlayer);
        }