public void GivenMatrixIsFilledWhenChildElementParentIsChangedThenWeightsAreUpdated() { DsmRelationModel model = new DsmRelationModel(_elementsDataModel); CreateElementRelations(model); Assert.AreEqual(1030, model.GetDependencyWeight(_a1.Id, _b.Id)); Assert.AreEqual(1234, model.GetDependencyWeight(_a.Id, _b.Id)); Assert.AreEqual(5, model.GetDependencyWeight(_a.Id, _c.Id)); _elementsDataModel.ChangeElementParent(_c2, _b); Assert.AreEqual(1035, model.GetDependencyWeight(_a1.Id, _b.Id)); Assert.AreEqual(1239, model.GetDependencyWeight(_a.Id, _b.Id)); Assert.AreEqual(0, model.GetDependencyWeight(_a.Id, _c.Id)); }
public void WhenChangeElementParentIsCalledThenItCanBeFoundAtTheNewLocation() { DsmElementModel model = new DsmElementModel(); Assert.AreEqual(1, model.GetElementCount()); IDsmElement a = model.ImportElement(1, "a", "type", 10, true, null, false); IDsmElement b = model.ImportElement(2, "b", "type", 11, true, a.Id, false); IDsmElement c = model.ImportElement(3, "c", "type", 12, true, null, false); IDsmElement foundElementBefore = model.FindElementByFullname("a.b"); Assert.IsNotNull(foundElementBefore); Assert.AreEqual(a, foundElementBefore.Parent); model.ChangeElementParent(b, c); IDsmElement foundElementAfter = model.FindElementByFullname("c.b"); Assert.IsNotNull(foundElementAfter); Assert.AreEqual(c, foundElementAfter.Parent); }