Exemplo n.º 1
0
        public void WhenUndoActionThenRelationWeightIsRevertedDataModel()
        {
            RelationChangeWeightAction action = new RelationChangeWeightAction(_model.Object, _relation.Object, NewWeight);

            action.Undo();

            _model.Verify(x => x.ChangeRelationWeight(_relation.Object, OldWeight), Times.Once());
        }
Exemplo n.º 2
0
        public void GivenLoadedActionWhenGettingDataThenActionAttributesMatch()
        {
            _model.Setup(x => x.GetRelationById(RelationId)).Returns(_relation.Object);

            object[] args = { _model.Object, _data };
            RelationChangeWeightAction action = new RelationChangeWeightAction(args);

            Assert.AreEqual(3, action.Data.Count);
            Assert.AreEqual(RelationId.ToString(), _data["relation"]);
            Assert.AreEqual(OldWeight.ToString(), _data["old"]);
            Assert.AreEqual(NewWeight.ToString(), _data["new"]);
        }
Exemplo n.º 3
0
        public IDsmRelation ImportRelation(int consumerId, int providerId, string type, int weight)
        {
            IDsmRelation relation = _dsmModel.FindRelation(consumerId, providerId, type);

            if (relation == null)
            {
                RelationCreateAction action = new RelationCreateAction(_dsmModel, consumerId, providerId, type, weight);
                relation = _actionManager.Execute(action) as IDsmRelation;
                Debug.Assert(relation != null);
            }
            else
            {
                _notFoundRelations.Remove(relation.Id);

                if (relation.Weight != weight)
                {
                    RelationChangeWeightAction action = new RelationChangeWeightAction(_dsmModel, relation, weight);
                    _actionManager.Execute(action);
                }
            }

            return(relation);
        }
Exemplo n.º 4
0
        public void ChangeRelationWeight(IDsmRelation relation, int weight)
        {
            RelationChangeWeightAction action = new RelationChangeWeightAction(_dsmModel, relation, weight);

            _actionManager.Execute(action);
        }