示例#1
0
        public void StickerCanMove_WhenWipIsNull()
        {
            var stickersBoard = Create.StickersBoard(@"| InProgress     | Done |
                                                       |                | (0)  |").Please();

            Assert.True(stickersBoard.CanMoveTo(ProgressPosition.First()));
        }
示例#2
0
        public void StickerCanNotMove_WhenNextPositionIsFull()
        {
            var stickersBoard = Create.StickersBoard(@"| InProgress (1) | Done |
                                                       | [P  ]          | (0)  |").Please();

            Assert.False(stickersBoard.CanMoveTo(ProgressPosition.First()));
        }
示例#3
0
        private void InitializeStickersInProgress(int positionsInProgress)
        {
            _stickersInProgress = new Dictionary <ProgressPosition, List <Sticker> >();
            var position = ProgressPosition.First();

            for (var d = 0; d < positionsInProgress; d++)
            {
                _stickersInProgress.Add(position, new List <Sticker>());
                position = position.Next();
            }
        }
        public void InDoneStickersIncrement_WhenStickerIsDone()
        {
            var stickersBoard = Create.StickersBoard(@"| InProgress (1) | Done |
                                                       | [P  ]          | (0)  |").Please();
            var sticker       = stickersBoard.GetStickersIn(ProgressPosition.First()).Single();

            stickersBoard.StepUp(sticker);

            AssertStickerBoard.Equal(@"| InProgress (1) | Done |
                                       |                | (1)  |",
                                     stickersBoard);
        }
示例#5
0
        public void GameCreatesStickersEqualToPlayersCount_WhenSetup()
        {
            var game = Create.Game().Please();

            game.Setup();

            var createdStickers = (game.StickersBoard as StickersBoard)
                                  .GetStickersIn(ProgressPosition.First())
                                  .ToList();

            Assert.Equal(5, createdStickers.Count);
        }
        public void BoardReturnsBlockedStickerForPlayer_WhenBlocked()
        {
            var stickersBoard = Create.StickersBoard(@"| InProgress (2) | Done |
                                                       | [P  ]          | (0)  |").Please();

            var sticker = stickersBoard.GetStickersIn(ProgressPosition.First()).Single();

            sticker.Block();

            AssertStickerBoard.Equal(@"| InProgress (2) | Done |
                                       | [P B]          | (0)  |",
                                     stickersBoard);
        }
        public void StickerNotStepUp_WhenStickerBlocked()
        {
            var stickersBoard = Create.StickersBoard(@"| InProgress (2) | InProgress (2) | Done |
                                                       | [P B]          |                | (0)  |").Please();

            var sticker = stickersBoard.GetStickersIn(ProgressPosition.First()).Single();

            stickersBoard.StepUp(sticker);

            AssertStickerBoard.Equal(@"| InProgress (2) | InProgress (2) | Done |
                                       | [P B]          |                | (0)  |",
                                     stickersBoard);
        }
示例#8
0
        private void ParseColumnState(string line)
        {
            if (!line.Contains('['))
            {
                return;
            }

            var inProgressCount      = GetScale(line);
            var position             = ProgressPosition.First();
            var lastPositionOfSymbol = line.IndexOf("|", 0);

            for (var p = 0; p < inProgressCount; p++)
            {
                var nextPositionOfSymbol = line.IndexOf("|", lastPositionOfSymbol + 1);
                var column       = line.Substring(lastPositionOfSymbol, nextPositionOfSymbol - lastPositionOfSymbol - 1);
                var pattern      = "([A-Z])";
                var stickerParam = Regex.Matches(column, pattern)
                                   .Select(w => w.Value);

                if (!stickerParam.Any())
                {
                    continue;
                }

                var player = _players.FirstOrDefault(pl => pl.Name == stickerParam.First());

                if (player == null)
                {
                    player = Create.Player().WithName(stickerParam.First()).Please();
                }

                if (stickerParam.Contains("B"))
                {
                    _stickersBoardBuilder.WithBlockedStickerInProgressFor(player, position);
                }
                else
                {
                    _stickersBoardBuilder.WithStickerInProgressFor(player, position);
                }

                position             = position.Next();
                lastPositionOfSymbol = nextPositionOfSymbol;
            }
        }