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

            assoc.FirstMultiList.Add(end1);
            Assert.True(assoc.FirstMultiList.Count == 1);
            Assert.True(assoc.SecondMultiList.Count == 0);
            Assert.Contains(end1, assoc.FirstMultiList);
            Assert.Equal(assoc, end1.Association);
            Assert.Null(end2.Association);
            assoc.SecondMultiList.Add(end2);
            Assert.True(assoc.FirstMultiList.Count == 1);
            Assert.True(assoc.SecondMultiList.Count == 1);
            Assert.Contains(end1, assoc.FirstMultiList);
            Assert.Contains(end2, assoc.SecondMultiList);
            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.FirstMultiList);
            Assert.Contains(iend2, iassoc.SecondMultiList);
            Assert.Equal(iassoc, iend1.Association);
            Assert.Equal(iassoc, iend2.Association);
        }
Esempio n. 2
0
        public void TestEndToAssociationResetMultiList2MultiList()
        {
            var model   = new MutableModel();
            var factory = new PropertiesTestFactory(model);
            var assoc   = factory.Association();
            var end     = factory.AssociationEndMultiList();

            end.Association = assoc;
            Assert.True(assoc.FirstMultiList.Count == 1);
            Assert.True(assoc.SecondMultiList.Count == 1);
            Assert.Contains(end, assoc.FirstMultiList);
            Assert.Contains(end, assoc.SecondMultiList);
            Assert.Equal(assoc, end.Association);
            end.Association = null;
            Assert.True(assoc.FirstMultiList.Count == 0);
            Assert.True(assoc.SecondMultiList.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);
        }