private void pruneHistory(IHistoryItemDTO rootNode)
        {
            if (!EnableHistoryPruning)
            {
                return;
            }

            var allLeafNodes = rootNode.AllLeafs.Where(parentIsAMacroWithOneChild).ToList();

            if (allLeafNodes.Count == 0)
            {
                return;
            }

            bool changed = false;

            foreach (var node in allLeafNodes)
            {
                var parentHistory = node.Parent;
                //remove parent history from its own parent and add the node underneath
                var grandParent = parentHistory.Parent;
                if (grandParent != null)
                {
                    parentHistory.RemoveSubHistory(node);
                    grandParent.RemoveSubHistory(parentHistory);
                    grandParent.AddSubHistory(node);
                    changed = true;
                }
            }
            if (changed)
            {
                pruneHistory(rootNode);
            }
        }
Esempio n. 2
0
 public void EditCommentFor(IHistoryItemDTO historyItemDTO)
 {
     _view.Caption            = Captions.Commands.CommentViewCaption(historyItemDTO.State);
     _view.CommandDescription = historyItemDTO.Description;
     _view.BindTo(historyItemDTO);
     _view.Display();
 }
Esempio n. 3
0
 protected override void Context()
 {
     _commentPresenter      = A.Fake <ICommentPresenter>();
     _historyItemDTO        = A.Fake <IHistoryItemDTO>();
     _applicationController = A.Fake <IApplicationController>();
     A.CallTo(() => _applicationController.Start <ICommentPresenter>()).Returns(_commentPresenter);
     sut = new CommentTask(_applicationController);
 }
Esempio n. 4
0
        public void AddSubHistory(IHistoryItemDTO historyItemDto)
        {
            if (historyItemDto.IsAnImplementationOf <NullHistoryItemDTO>())
            {
                return;
            }

            _subHistoryItems.Add(historyItemDto);
            historyItemDto.Parent = this;
        }
        private IHistoryItemDTO simplifiedHistoryItemDTOFrom(IHistoryItemDTO historyItemDTO)
        {
            pruneHistory(historyItemDTO);
            if (historyItemDTO.Children().Count() == 1)
            {
                return(historyItemDTO.Children().ElementAt(0));
            }

            return(historyItemDTO);
        }
Esempio n. 6
0
        public void EditCommentFor(IHistoryItemDTO historyItemDTO)
        {
            if (historyItemDTO.IsAnImplementationOf <NullHistoryItemDTO>())
            {
                return;
            }

            using (var presenter = _applicationController.Start <ICommentPresenter>())
            {
                presenter.EditCommentFor(historyItemDTO);
            }
        }
 private bool parentIsAMacroWithOneChild(IHistoryItemDTO historyItemDTO)
 {
     if (historyItemDTO == null)
     {
         return(false);
     }
     if (historyItemDTO.Parent == null)
     {
         return(false);
     }
     return(historyItemDTO.Parent.Children().Count() == 1);
 }
 protected override void Context()
 {
     base.Context();
     _historyItemId = "tutu";
     _historyItem   = A.Fake <IHistoryItem>();
     _historyList.Add(_historyItem);
     _historyItemDTO       = A.Fake <IHistoryItemDTO>();
     _historyItemDTO.Id    = _historyItemId;
     _historyItemDTO.State = 5;
     A.CallTo(() => _mapper.MapFrom(_historyItem)).Returns(_historyItemDTO);
     A.CallTo(() => _historyItemDTOList.ItemById(_historyItemId)).Returns(_historyItemDTO);
     sut.UpdateHistory();
 }
        protected override void Context()
        {
            base.Context();
            _notALabelItemId  = "_notALabelItemId";
            _aLabelItemId     = "_aLabelItemId";
            _labelHistoryItem = A.Fake <IHistoryItem>();
            A.CallTo(() => _labelHistoryItem.Command).Returns(A.Fake <ILabelCommand>());
            _notALabelHistoryItem = A.Fake <IHistoryItem>();
            A.CallTo(() => _notALabelHistoryItem.Command).Returns(A.Fake <ICommand>());
            _historyList.Add(_labelHistoryItem);
            _historyList.Add(_notALabelHistoryItem);

            _labelHistoryItemDTO = A.Fake <IHistoryItemDTO>().WithId(_aLabelItemId);
            A.CallTo(() => _labelHistoryItemDTO.Command).Returns(_labelHistoryItem.Command);
            _notALabelHistoryItemDTO = A.Fake <IHistoryItemDTO>().WithId(_notALabelItemId);
            A.CallTo(() => _notALabelHistoryItemDTO.Command).Returns(_notALabelHistoryItem.Command);
            A.CallTo(() => _mapper.MapFrom(_labelHistoryItem)).Returns(_labelHistoryItemDTO);
            A.CallTo(() => _mapper.MapFrom(_notALabelHistoryItem)).Returns(_notALabelHistoryItemDTO);
            A.CallTo(() => _historyItemDTOList.ItemById(_aLabelItemId)).Returns(_labelHistoryItemDTO);
            sut.UpdateHistory();
        }
 protected override void Context()
 {
     base.Context();
     _historyItemDTO = A.Fake <IHistoryItemDTO>();
 }
 protected override void Because()
 {
     _result = sut.MapFrom(_simpleHistoryItem);
 }
Esempio n. 12
0
 public void Add(IHistoryItemDTO itemToAdd)
 {
     _dtoList.Add(itemToAdd);
 }
Esempio n. 13
0
 public void AddAtFront(IHistoryItemDTO itemToAdd)
 {
     _dtoList.Insert(0, itemToAdd);
 }
Esempio n. 14
0
 public void Remove(IHistoryItemDTO historyItemDto)
 {
     _dtoList.Remove(historyItemDto);
 }
Esempio n. 15
0
 public void RemoveSubHistory(IHistoryItemDTO historyItemDto)
 {
     _subHistoryItems.Remove(historyItemDto);
     historyItemDto.Parent = null;
 }
Esempio n. 16
0
 public void RemoveSubHistory(IHistoryItemDTO historyItemDto)
 {
 }
Esempio n. 17
0
 public void BindTo(IHistoryItemDTO historyItemDTO)
 {
     _screenBinder.BindToSource(historyItemDTO);
 }
Esempio n. 18
0
 public void AddSubHistory(IHistoryItemDTO historyItemDto)
 {
 }