Exemplo n.º 1
0
        public void ApplyHigherPriorityBehavior_IfTheyAllApplicable()
        {
            var getNewCardBehaviour  = new GetNewCardBahaviour();
            var moveOwnCardBehaviour = new MoveOwnCardForwardBehaviour();
            var behaviours           = new List <PlayerBehaviourContainer>
            {
                new PlayerBehaviourContainer(priority: 1, behaviour: getNewCardBehaviour),
                new PlayerBehaviourContainer(priority: 2, behaviour: moveOwnCardBehaviour),
            };
            var playerBehaviour = Create.PlayerBehavoiur
                                  .WithTailsBehaviours(behaviours)
                                  .Build();

            var boardMap = $@"  +-------------------------------+
                                +InProgress|InTesting |Completed+
                                +-------------------------------+
                                +Ivan      |          |         +
                                +          |          |         +
                                +-------------------------------+";
            var board    = Create.Board.FromMap(boardMap);

            var newBoard = playerBehaviour.Apply("Ivan", board, CoinSide.Tails);

            Assert.True(getNewCardBehaviour.CanApply("Ivan", board, CoinSide.Tails));
            Assert.True(moveOwnCardBehaviour.CanApply("Ivan", board, CoinSide.Tails));
            AssertBoard.Equals($@"+-------------------------------+
                                  +InProgress|InTesting |Completed+
                                  +-------------------------------+
                                  +Ivan      |          |         +
                                  +Ivan      |          |         +
                                  +-------------------------------+", newBoard);
        }
Exemplo n.º 2
0
        public void CanGetAdditionalCard_OnApply()
        {
            var getNewCardBehaviour = new GetNewCardBahaviour();
            var boardMap            = $@"  +-------------------------------+
                                +InProgress|InTesting |Completed+
                                +-------------------------------+
                                +Ivan      |          |         +
                                +          |          |         +
                                +-------------------------------+";
            var board    = Create.Board.FromMap(boardMap);
            var newBoard = getNewCardBehaviour.Apply("Ivan", board, CoinSide.Eagle);

            Assert.True(getNewCardBehaviour.CanApply("Ivan", board, CoinSide.Eagle));
            AssertBoard.Equals($@"+-------------------------------+
                                  +InProgress|InTesting |Completed+
                                  +-------------------------------+
                                  +Ivan      |          |         +
                                  +Ivan      |          |         +
                                  +-------------------------------+", newBoard);
        }
        public void BlockOwnUnBlockedCard_IfOwnCardUnblocked()
        {
            var blockCardBehaviour = new BlockOwnCardBahaviour();
            var boardMap           = $@"  +-------------------------------+
                                +InProgress|InTesting |Completed+
                                +-------------------------------+
                                +Ivan      |          |         +
                                +          |          |         +
                                +-------------------------------+";
            var board = Create.Board.FromMap(boardMap);

            var newBoard = blockCardBehaviour.Apply("Ivan", board, CoinSide.Eagle);

            Assert.True(blockCardBehaviour.CanApply("Ivan", board, CoinSide.Eagle));
            AssertBoard.Equals($@"+-------------------------------+
                                  +InProgress|InTesting |Completed+
                                  +-------------------------------+
                                  +Ivan*     |          |         +
                                  +          |          |         +
                                  +-------------------------------+", newBoard);
        }
        public void UnblockAnotherPlayerBlockedCard_IfCardBlocked()
        {
            var unblockAnotherPlayerCardBehaviour = new UnblockAnotherPlayerCardBehaviour();
            var boardMap = $@"  +-------------------------------+
                                +InProgress|InTesting |Completed+
                                +-------------------------------+
                                +Vova*     |          |         +
                                +          |          |         +
                                +-------------------------------+";
            var board    = Create.Board.FromMap(boardMap);

            var newBoard = unblockAnotherPlayerCardBehaviour.Apply("Ivan", board, CoinSide.Tails);

            Assert.True(unblockAnotherPlayerCardBehaviour.CanApply("Ivan", board, CoinSide.Tails));
            AssertBoard.Equals($@"+-------------------------------+
                                  +InProgress|InTesting |Completed+
                                  +-------------------------------+
                                  +Vova      |          |         +
                                  +          |          |         +
                                  +-------------------------------+", newBoard);
        }
Exemplo n.º 5
0
        public void MoveOwnUnblockedCard_IfOwnCardUnblocked()
        {
            var moveOwnCardBehaviour = new MoveOwnCardForwardBehaviour();
            var boardMap             = $@"  +-------------------------------+
                                +InProgress|InTesting |Completed+
                                +-------------------------------+
                                +Ivan      |          |         +
                                +          |          |         +
                                +-------------------------------+";
            var board = Create.Board.FromMap(boardMap);

            var newBoard = moveOwnCardBehaviour.Apply("Ivan", board, CoinSide.Tails);

            Assert.True(moveOwnCardBehaviour.CanApply("Ivan", board, CoinSide.Tails));
            AssertBoard.Equals($@"+-------------------------------+
                                  +InProgress|InTesting |Completed+
                                  +-------------------------------+
                                  +          |Ivan      |         +
                                  +          |          |         +
                                  +-------------------------------+", newBoard);
        }
Exemplo n.º 6
0
        public void GetNewCardAndNotBlockBlockedCard_IfNoOwnUnblockedCard()
        {
            var blockOwnAndGetNewBehave = new BlockOwnAndGetNewSticker();
            var boardMap = $@"  +-------------------------------+
                                +InProgress|InTesting |Completed+
                                +-------------------------------+
                                +Ivan*     |          |         +
                                +          |          |         +
                                +-------------------------------+";
            var board    = Create.Board.FromMap(boardMap);

            var newBoard = blockOwnAndGetNewBehave.Apply("Ivan", board, CoinSide.Eagle);

            Assert.True(blockOwnAndGetNewBehave.CanApply("Ivan", board, CoinSide.Eagle));
            AssertBoard.Equals($@"+-------------------------------+
                                  +InProgress|InTesting |Completed+
                                  +-------------------------------+
                                  +Ivan      |          |         +
                                  +Ivan*     |          |         +
                                  +-------------------------------+", newBoard);
        }
Exemplo n.º 7
0
        public void SkipMove_IfNoBehavioursAcceptable()
        {
            var playerBehaviour = Create.PlayerBehavoiur
                                  .WithTailBehaviours(new UnblockOwnCardBahaviour())
                                  .Build();
            var boardMap = $@"  +-------------------------------+
                                +InProgress|InTesting |Completed+
                                +-------------------------------+
                                +Ivan      |          |         +
                                +          |          |         +
                                +-------------------------------+";
            var board    = Create.Board.FromMap(boardMap);

            var newBoard = playerBehaviour.Apply("Ivan", board, CoinSide.Tails);

            AssertBoard.Equals($@"+-------------------------------+
                                  +InProgress|InTesting |Completed+
                                  +-------------------------------+
                                  +Ivan      |          |         +
                                  +          |          |         +
                                  +-------------------------------+", newBoard);
        }
        public void CreatePlayerWhichBlockOwnAndGetNewCard_IfDropEagle()
        {
            var player = new Runner.DSL.PlayerBuilder()
                         .WithName("Ivan")
                         .Build();
            var boardMap = $@"  +-------------------------------+
                                +InProgress|InTesting |Completed+
                                +-------------------------------+
                                +Ivan      |          |         +
                                +          |          |         +
                                +-------------------------------+";
            var board    = Create.Board.FromMap(boardMap);

            var newBoard = player.Play(CoinSide.Eagle, board);

            AssertBoard.Equals($@"+-------------------------------+
                                  +InProgress|InTesting |Completed+
                                  +-------------------------------+
                                  +Ivan      |          |         +
                                  +Ivan*     |          |         +
                                  +-------------------------------+", newBoard);
        }
        public void CreatePlayerWhichMoveOwnCardFirstly_IfDropTails()
        {
            var player = new Runner.DSL.PlayerBuilder()
                         .WithName("Ivan")
                         .Build();
            var boardMap = $@"  +-------------------------------+
                                +InProgress|InTesting |Completed+
                                +-------------------------------+
                                +Ivan      |          |         +
                                +Ivan*     |          |         +
                                +-------------------------------+";
            var board    = Create.Board.FromMap(boardMap);

            var newBoard = player.Play(CoinSide.Tails, board);

            AssertBoard.Equals($@"+-------------------------------+
                                  +InProgress|InTesting |Completed+
                                  +-------------------------------+
                                  +Ivan*     |Ivan      |         +
                                  +          |          |         +
                                  +-------------------------------+", newBoard);
        }
Exemplo n.º 10
0
        public void CreatePlayerWhichUnblockOwnCard_IfDropTailsAndCantGetNewOrMoveOwnCard()
        {
            var player = new Runner.DSL.PlayerBuilder()
                         .WithName("Ivan")
                         .Build();
            var boardMap = $@"  +-------------------------------+
                                +InProgress|InTesting |Completed+
                                +-------------------------------+
                                +Ivan*     |          |         +
                                +          |          |         +
                                #-------------------------------#
                                +Limit:1   |Limit:1   |         +";
            var board    = Create.Board.FromMap(boardMap);

            var newBoard = player.Play(CoinSide.Tails, board);

            AssertBoard.Equals($@"+-------------------------------+
                                  +InProgress|InTesting |Completed+
                                  +-------------------------------+
                                  +Ivan      |          |         +
                                  +          |          |         +
                                  #-------------------------------#
                                  +Limit:1   |Limit:1   |         +", newBoard);
        }