예제 #1
0
        public void ApplyCollectionInsertionAssociation()
        {
            var parent   = railway.Routes[0].DefinedBy[0].Elements[0];
            var toInsert = railway.Routes[0].DefinedBy[1].Elements[0];

            var change = new AssociationCollectionInsertion
            {
                AffectedElement = parent,
                Feature         = TrackElement.ClassInstance.LookupReference("connectsTo"),
                AddedElement    = toInsert
            };

            change.Apply();

            Assert.AreSame(toInsert, parent.ConnectsTo[parent.ConnectsTo.Count - 1]);
        }
예제 #2
0
        public void InvertCollectionInsertionAssociation()
        {
            var parent1  = railway1.Routes[0].DefinedBy[0].Elements[0];
            var parent2  = railway1.Routes[0].DefinedBy[0].Elements[0];
            var toInsert = railway1.Routes[0].DefinedBy[1].Elements[0];

            var change = new AssociationCollectionInsertion
            {
                AffectedElement = parent1,
                Feature         = TrackElement.ClassInstance.LookupReference("connectsTo"),
                AddedElement    = toInsert
            };

            change.Apply();
            foreach (var inverted in change.Invert())
            {
                inverted.Apply();
            }

            Assert.AreNotSame(toInsert, parent1.ConnectsTo[parent1.ConnectsTo.Count - 1]);
            Assert.AreEqual(parent2.ConnectsTo.Count, parent1.ConnectsTo.Count);
        }