Ejemplo n.º 1
0
        public void GivenElementIsInModelWhenElementIsImportedThenElementIsNotAddedAgainToModel()
        {
            IDsmElement foundElement = _existingElement.Object;

            _dsmModel.Setup(x => x.GetElementByFullname(ElementFullName)).Returns(foundElement);

            CreateNewModelPolicy policy  = new CreateNewModelPolicy(_dsmModel.Object);
            IDsmElement          element = policy.ImportElement(ElementFullName, ElementName, ElementType, _elementParent.Object);

            Assert.AreEqual(_existingElement.Object, element);

            _dsmModel.Verify(x => x.AddElement(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int?>()), Times.Never());
        }
Ejemplo n.º 2
0
        public void GivenElementIsNotInModelWhenElementIsImportedThenElementIsAddedToModel()
        {
            IDsmElement foundElement = null;

            _dsmModel.Setup(x => x.GetElementByFullname(ElementFullName)).Returns(foundElement);
            _dsmModel.Setup(x => x.AddElement(ElementName, ElementType, ElementParentId)).Returns(_createdElement.Object);

            CreateNewModelPolicy policy  = new CreateNewModelPolicy(_dsmModel.Object);
            IDsmElement          element = policy.ImportElement(ElementFullName, ElementName, ElementType, _elementParent.Object);

            Assert.AreEqual(_createdElement.Object, element);

            _dsmModel.Verify(x => x.AddElement(ElementName, ElementType, ElementParentId), Times.Once());
        }