Ejemplo n.º 1
0
        public void GivenMultipleElementAreInTheModelWhenAnElementIsRemovedThenAllRelationUsingThisElementAreRemoved()
        {
            DsiRelationModel model = new DsiRelationModel(_elementsDataModel);

            Assert.AreEqual(0, model.TotalRelationCount);

            IDsiRelation relation1 = model.AddRelation("a", "b", "type1", 1, "");

            Assert.IsNotNull(relation1);
            IDsiRelation relation2 = model.AddRelation("b", "c", "type2", 2, "");

            Assert.IsNotNull(relation2);
            IDsiRelation relation3 = model.AddRelation("a", "c", "type3", 3, "");

            Assert.IsNotNull(relation3);
            Assert.AreEqual(3, model.TotalRelationCount);

            _elementsDataModel.RemoveElement(_b);
            Assert.AreEqual(1, model.TotalRelationCount);

            List <IDsiRelation> relations = model.GetRelations().OrderBy(x => x.Weight).ToList();

            Assert.AreEqual(1, relations.Count);

            Assert.AreEqual(_a.Id, relations[0].ConsumerId);
            Assert.AreEqual(_c.Id, relations[0].ProviderId);
            Assert.AreEqual("type3", relations[0].Type);
            Assert.AreEqual(3, relations[0].Weight);
        }
Ejemplo n.º 2
0
        public void GivenAnElementIsInTheModelWhenRemoveElementIsCalledThenElementIsNotFoundAnymoreByItName()
        {
            DsiElementModel model = new DsiElementModel();
            Assert.AreEqual(0, model.TotalElementCount);

            model.ImportElement(1, "name", "type", "source");
            IDsiElement foundElementBefore = model.FindElementByName("name");
            Assert.IsNotNull(foundElementBefore);

            model.RemoveElement(foundElementBefore);

            IDsiElement foundElementAfter = model.FindElementByName("name");
            Assert.IsNull(foundElementAfter);
        }