Esempio n. 1
0
        public void TestAssociationToEndMultiSet2MultiSet()
        {
            var model   = new MutableModel();
            var factory = new PropertiesTestFactory(model);
            var assoc   = factory.Association();
            var end1    = factory.AssociationEndMultiSet();
            var end2    = factory.AssociationEndMultiSet();

            assoc.FirstMultiSet.Add(end1);
            Assert.True(assoc.FirstMultiSet.Count == 1);
            Assert.True(assoc.SecondMultiSet.Count == 0);
            Assert.Contains(end1, assoc.FirstMultiSet);
            Assert.Equal(assoc, end1.Association);
            Assert.Null(end2.Association);
            assoc.SecondMultiSet.Add(end2);
            Assert.True(assoc.FirstMultiSet.Count == 1);
            Assert.True(assoc.SecondMultiSet.Count == 1);
            Assert.Contains(end1, assoc.FirstMultiSet);
            Assert.Contains(end2, assoc.SecondMultiSet);
            Assert.Equal(assoc, end1.Association);
            Assert.Equal(assoc, end2.Association);
            var imodel = model.ToImmutable();
            var iassoc = assoc.ToImmutable(imodel);
            var iend1  = end1.ToImmutable(imodel);
            var iend2  = end2.ToImmutable(imodel);

            Assert.Contains(iend1, iassoc.FirstMultiSet);
            Assert.Contains(iend2, iassoc.SecondMultiSet);
            Assert.Equal(iassoc, iend1.Association);
            Assert.Equal(iassoc, iend2.Association);
        }
Esempio n. 2
0
        public void TestEndToAssociationResetMultiSet2MultiSet()
        {
            var model   = new MutableModel();
            var factory = new PropertiesTestFactory(model);
            var assoc   = factory.Association();
            var end     = factory.AssociationEndMultiSet();

            end.Association = assoc;
            Assert.True(assoc.FirstMultiSet.Count == 1);
            Assert.True(assoc.SecondMultiSet.Count == 1);
            Assert.Contains(end, assoc.FirstMultiSet);
            Assert.Contains(end, assoc.SecondMultiSet);
            Assert.Equal(assoc, end.Association);
            end.Association = null;
            Assert.True(assoc.FirstMultiSet.Count == 0);
            Assert.True(assoc.SecondMultiSet.Count == 0);
            Assert.Null(end.Association);
            var imodel = model.ToImmutable();
            var iassoc = assoc.ToImmutable(imodel);
            var iend   = end.ToImmutable(imodel);

            Assert.Null(iassoc.First);
            Assert.Null(iassoc.Second);
            Assert.Null(iend.Association);
        }