Пример #1
0
        public void WhenDoActionThenRelationIsAddedToDataModel()
        {
            RelationCreateAction action = new RelationCreateAction(_model.Object, ConsumerId, ProviderId, Type, Weight);

            action.Do();

            _model.Verify(x => x.AddRelation(ConsumerId, ProviderId, Type, Weight), Times.Once());
        }
Пример #2
0
        public void WhenUndoActionThenRelationIsRemovedFromDataModel()
        {
            _model.Setup(x => x.GetRelationById(RelationId)).Returns(_relation.Object);

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

            action.Undo();

            _model.Verify(x => x.RemoveRelation(RelationId), Times.Once());
        }
Пример #3
0
        public void GivenLoadedActionWhenGettingDataThenActionAttributesMatch()
        {
            _model.Setup(x => x.GetRelationById(RelationId)).Returns(_relation.Object);

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

            Assert.AreEqual(5, action.Data.Count);
            Assert.AreEqual(RelationId.ToString(), _data["relation"]);
            Assert.AreEqual(ConsumerId.ToString(), _data["consumer"]);
            Assert.AreEqual(ProviderId.ToString(), _data["provider"]);
            Assert.AreEqual(Type, _data["type"]);
            Assert.AreEqual(Weight.ToString(), _data["weight"]);
        }
Пример #4
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);
        }
Пример #5
0
        public void CreateRelation(IDsmElement consumer, IDsmElement provider, string type, int weight)
        {
            RelationCreateAction action = new RelationCreateAction(_dsmModel, consumer.Id, provider.Id, type, weight);

            _actionManager.Execute(action);
        }