예제 #1
0
        public void ShouldGetNewNameOnMultipleTargets()
        {
            DataContract source = new DataContract(Store);

            source.Name = "Source";
            DataContract target = new DataContract(Store);

            target.Name = "Target";
            DataContractBaseCanBeContainedOnContracts link = new DataContractBaseCanBeContainedOnContracts(source, target);
            ModelElementReference dataElement = new ModelElementReference(Store);

            dataElement.Name = "DcdeName";
            dataElement.SetLinkedElement(link.Id);
            source.DataMembers.Add(dataElement);
            AggregationConnectionBuilder.Connect(source, target);

            Assert.AreEqual(1, target.DataMembers.Count);
            dataElement = (ModelElementReference)target.DataMembers[0];
            Assert.AreEqual("Source", dataElement.Name);

            AggregationConnectionBuilder.Connect(source, target);

            Assert.AreEqual(2, target.DataMembers.Count);
            dataElement = (ModelElementReference)target.DataMembers[1];
            Assert.AreEqual("Source1", dataElement.Name);

            AggregationConnectionBuilder.Connect(source, target);

            Assert.AreEqual(3, target.DataMembers.Count);
            dataElement = (ModelElementReference)target.DataMembers[2];
            Assert.AreEqual("Source2", dataElement.Name);
        }
예제 #2
0
        public void ShouldNotRejectSameLink()
        {
            DataContract source = new DataContract(Store);
            DataContract target = new DataContract(Store);
            DataContractBaseCanBeContainedOnContracts link = new DataContractBaseCanBeContainedOnContracts(source, target);
            ModelElementReference dataElement = new ModelElementReference(Store);

            dataElement.SetLinkedElement(link.Id);
            source.DataMembers.Add(dataElement);
            bool result = AggregationConnectionBuilder.CanAcceptSourceAndTarget(source, target);

            Assert.IsTrue(result);
        }
예제 #3
0
        public void ShouldGetNewNameOnSelfReference()
        {
            DataContract source = new DataContract(Store);

            source.Name = "DC";
            AggregationConnectionBuilder.Connect(source, source);

            Assert.AreEqual(1, source.DataMembers.Count);
            ModelElementReference dataElement = (ModelElementReference)source.DataMembers[0];

            Assert.AreEqual("DC", source.Name);
            Assert.AreNotEqual(source.Name, dataElement.Name);
            Assert.AreEqual("DC1", dataElement.Name);
        }
예제 #4
0
        private List <DataMember> LoadLinkedElements(DataContractBase sourceElement)
        {
            DataContract targetElement = new DataContract(Store);

            targetElement.Name = DataContractLinkedElementType;
            DataContractBaseCanBeContainedOnContracts link = new DataContractBaseCanBeContainedOnContracts(sourceElement, targetElement);

            List <DataMember>     dataElements = new List <DataMember>();
            ModelElementReference element1     = new ModelElementReference(Store);

            element1.Name = sourceElement.Name;
            element1.Type = sourceElement.Name;
            element1.SetLinkedElement(link.Id);

            dataElements.Add(element1);
            return(dataElements);
        }