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

            Assert.False(stickersBoard.CanMoveTo(ProgressPosition.First()));
        }
示例#2
0
        public StickersBoardBuilder WithBlockedStickerInProgressFor(Player player, ProgressPosition position)
        {
            var sticker = Create.Sticker().Blocked().For(player).Please();

            _stickersInProgress[position].Add(sticker);
            return(this);
        }
示例#3
0
        public void StickerCanMove_WhenWipIsNull()
        {
            var stickersBoard = Create.StickersBoard(@"| InProgress     | Done |
                                                       |                | (0)  |").Please();

            Assert.True(stickersBoard.CanMoveTo(ProgressPosition.First()));
        }
示例#4
0
        private string StickerToString(Sticker sticker, ProgressPosition position)
        {
            var stickerOwnerName = sticker.Owner.Name;
            var blocked          = sticker.Blocked ? "B" : " ";

            return($" [{stickerOwnerName} {blocked}]         |");
        }
示例#5
0
        public bool Equals(ProgressPosition p)
        {
            if ((object)p == null)
            {
                return(false);
            }

            return(p.Step == Step);
        }
示例#6
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();
            }
        }
示例#7
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 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);
        }
        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);
        }
        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);
        }
示例#11
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;
            }
        }
示例#12
0
 /// <summary>
 /// 状态变化事件
 /// </summary>
 private void StateChanged(CmdString state)
 {
     if (state.IsType(CmdStrings.Progress))
     {
         CmdString progress    = state.GetChildCmd();
         long      finisedSize = 0;
         if (long.TryParse(progress.ToString(), out finisedSize))
         {
             ProgressChanged(finisedSize);
             _pauseInfo.SetPausePos(finisedSize);
         }
     }
     else if (state.Match(CmdStrings.StartMirror))
     {
         SourcePosition.IsMirroring = true;
     }
     else if (state.Match(CmdStrings.AllFinishState))
     {
         _msgBox.ShowDialogSuccessMsg("镜像完成");
         SourcePosition.IsMirroring    = false;
         ProgressPosition.FinishedSize = ProgressPosition.TotalSize;
         ProgressPosition.Stop();
     }
     else if (state.IsType(CmdStrings.Exception))
     {
         _msgBox.ShowErrorMsg("镜像失败" + state.GetChildCmd());
         SourcePosition.IsMirroring = false;
     }
     else if (state.Match(CmdStrings.StopMirror))
     {
         _msgBox.ShowDialogSuccessMsg("镜像停止");
         SourcePosition.IsMirroring = false;
     }
     else if (state.Match(CmdStrings.NoSelectedPartition))
     {
         _msgBox.ShowDialogSuccessMsg("请选择至少一个分区");
         SourcePosition.IsMirroring = false;
     }
     else if (state.Match(CmdStrings.PauseMirror) ||
              state.Match(CmdStrings.ContinueMirror))
     {
         _msgBox.ShowDialogSuccessMsg(state.ToString());
     }
 }
示例#13
0
        private void Start()
        {
            //开始镜像前,检测剩余空间
            long freeValue = _driverInfo.GetTargetDriverFreeSpace(TargetPosition.DirPath);

            if (freeValue <= SourcePosition.CurrentSelectedDisk.SelectedTotalSize * 1.1)
            {
                _msgBox.ShowErrorMsg(string.Format("目录{0}所在的磁盘空间不足以存放镜像后的数据", TargetPosition.DirPath));
                return;
            }
            //开始镜像
            if (SourcePosition.CurrentSelectedDisk.Items != null)
            {
                ProgressPosition.TotalSize = SourcePosition.CurrentSelectedDisk.SelectedTotalSize;
                ProgressPosition.Start();
            }
            SourcePosition.Start(TargetPosition.DirPath);
            SourcePosition.IsMirroring = true;
        }
示例#14
0
 public Sticker(Player player)
 {
     Owner            = player;
     ProgressPosition = ProgressPosition.First();
 }
示例#15
0
 /// <summary>
 /// 进度变化事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ProgressChanged(long progress)
 {
     ProgressPosition.FinishedSize += ProgressPosition.GetIntervalToLastTime(progress);
     ProgressPosition.OnProgress(ProgressPosition.TotalSize - ProgressPosition.FinishedSize);
 }
示例#16
0
文件: Scale.cs 项目: xneg/featureban
 public bool IsValid(ProgressPosition progressPosition)
 {
     return(progressPosition.Step <= _inProgressStepsCount);
 }
示例#17
0
 public void ChangePosition(ProgressPosition progressPosition)
 {
     ProgressPosition = progressPosition;
 }