Ejemplo n.º 1
0
        public void WhenAddElementIsCalledUsingTwoDifferentTypesThenTwoElementTypesAreFound()
        {
            DsiElementModel model = new DsiElementModel();
            Assert.AreEqual(0, model.TotalElementCount);

            IDsiElement element1 = model.AddElement("name1", "type1", "source1");
            Assert.IsNotNull(element1);
            Assert.AreEqual(1, model.TotalElementCount);

            IDsiElement element2 = model.AddElement("name2", "type2", "source2");
            Assert.IsNotNull(element2);
            Assert.AreEqual(2, model.TotalElementCount);

            IDsiElement element3 = model.AddElement("name3", "type2", "source3");
            Assert.IsNotNull(element3);
            Assert.AreEqual(3, model.TotalElementCount);

            List<string> elementTypes = model.GetElementTypes().ToList();
            Assert.AreEqual(2, elementTypes.Count);
            Assert.AreEqual("type1", elementTypes[0]);
            Assert.AreEqual("type2", elementTypes[1]);

            Assert.AreEqual(1, model.GetElementTypeCount("type1"));
            Assert.AreEqual(2, model.GetElementTypeCount("type2"));
        }
Ejemplo n.º 2
0
 public void TestInitialize()
 {
     _elementsDataModel = new DsiElementModel();
     _a = _elementsDataModel.AddElement("a", "", "");
     _b = _elementsDataModel.AddElement("b", "", "");
     _c = _elementsDataModel.AddElement("c", "", "");
 }
Ejemplo n.º 3
0
        public void GivenAnElementIsInTheModelWhenAddElementIsCalledForAnotherElementThenItHasTwoElement()
        {
            DsiElementModel model = new DsiElementModel();
            Assert.AreEqual(0, model.TotalElementCount);

            IDsiElement element1 = model.AddElement("name1", "type", "source");
            Assert.IsNotNull(element1);
            Assert.AreEqual(1, model.TotalElementCount);

            IDsiElement element2 = model.AddElement("name2", "type", "source");
            Assert.IsNotNull(element2);
            Assert.AreEqual(2, model.TotalElementCount);
        }
Ejemplo n.º 4
0
        public void GivenAnElementIsInTheModelWhenAddElementIsCalledAgainForThatElementThenItStillHasOneElement()
        {
            DsiElementModel model = new DsiElementModel();
            Assert.AreEqual(0, model.TotalElementCount);

            IDsiElement element1 = model.AddElement("name", "type", "source");
            Assert.IsNotNull(element1);
            Assert.AreEqual(1, model.TotalElementCount);

            IDsiElement element2 = model.AddElement("name", "type", "source");
            Assert.IsNull(element2);
            Assert.AreEqual(1, model.TotalElementCount);
        }
Ejemplo n.º 5
0
        public void GivenModelIsEmptyWhenAddElementIsCalledThenItsHasOneElement()
        {
            DsiElementModel model = new DsiElementModel();
            Assert.AreEqual(0, model.TotalElementCount);

            IDsiElement element = model.AddElement("name", "type", "source");
            Assert.IsNotNull(element);
            Assert.AreEqual(1, model.TotalElementCount);
        }
Ejemplo n.º 6
0
        public void WhenRenameElementIsCalledThenItCanBeFoundUnderThatName()
        {
            DsiElementModel model = new DsiElementModel();
            Assert.AreEqual(0, model.TotalElementCount);

            IDsiElement element = model.AddElement("name", "type", "source");
            Assert.IsNotNull(element);
            Assert.AreEqual(1, model.TotalElementCount);

            model.RenameElement(element, "newname");
            Assert.AreEqual(1, model.TotalElementCount);

            IDsiElement foundElement = model.FindElementByName("newname");
            Assert.IsNotNull(foundElement);
            Assert.AreEqual(1, foundElement.Id);
            Assert.AreEqual("newname", foundElement.Name);
            Assert.AreEqual("type", foundElement.Type);
            Assert.AreEqual("source", foundElement.Source);
        }