Ejemplo n.º 1
0
        public void GivenAnElementIsInTheModelWhenFindByIdIsCalledWithItsNameThenElementIsFound()
        {
            DsmElementModel model = new DsmElementModel();

            Assert.AreEqual(1, model.GetElementCount());

            IDsmElement a = model.ImportElement(1, "a", "type", 10, true, null, false);

            Assert.IsNotNull(a);

            IDsmElement b = model.ImportElement(2, "b", "type", 11, true, a.Id, false);

            Assert.IsNotNull(b);

            IDsmElement foundElement = model.FindElementByFullname("a.b");

            Assert.IsNotNull(foundElement);
            Assert.AreEqual(2, foundElement.Id);
            Assert.AreEqual("b", foundElement.Name);
            Assert.AreEqual("a.b", foundElement.Fullname);
            Assert.AreEqual("type", foundElement.Type);
            Assert.AreEqual(11, foundElement.Order);
            Assert.AreEqual(true, foundElement.IsExpanded);
            Assert.AreEqual(a, foundElement.Parent);
        }
Ejemplo n.º 2
0
        public void WhenChangeElementIsCalledToChangeNameThenItCanBeFoundUnderThatName()
        {
            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 foundElementBefore = model.FindElementByFullname("a.c");

            Assert.IsNull(foundElementBefore);

            model.ChangeElementName(b, "c");

            IDsmElement foundElementAfter = model.FindElementByFullname("a.c");

            Assert.IsNotNull(foundElementAfter);
        }
Ejemplo n.º 3
0
        public void WhenChangeElementIsCalledToChangeTypeThenTypeIsChanged()
        {
            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 foundElementBefore = model.FindElementByFullname("a.b");

            Assert.IsNotNull(foundElementBefore);
            Assert.AreEqual("type", foundElementBefore.Type);

            model.ChangeElementType(b, "type1");

            IDsmElement foundElementAfter = model.FindElementByFullname("a.b");

            Assert.IsNotNull(foundElementAfter);
            Assert.AreEqual("type1", foundElementAfter.Type);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        public void GivenAnElementIsInTheModelWhenFindByIdIsCalledWithAnotherNameThenElementIsNotFound()
        {
            DsmElementModel model = new DsmElementModel();

            Assert.AreEqual(1, model.GetElementCount());

            IDsmElement a = model.ImportElement(1, "a", "type", 10, true, null, false);

            Assert.IsNotNull(a);

            IDsmElement b = model.ImportElement(2, "b", "type", 11, true, a.Id, false);

            Assert.IsNotNull(b);

            IDsmElement foundElement = model.FindElementByFullname("a.c");

            Assert.IsNull(foundElement);
        }