Beispiel #1
0
        public void TestParentToManyChildrenReset()
        {
            var model   = new MutableModel();
            var factory = new PropertiesTestFactory(model);
            var parent  = factory.ParentMultiList();
            var child   = factory.ChildMultiList();

            parent.Children.Add(child);
            parent.Children.Add(child);
            Assert.Equal(parent, child.Parent);
            Assert.Contains(child, parent.Children);
            Assert.True(parent.Children.Count == 2);
            Assert.Equal(child, parent.Children[0]);
            Assert.Equal(child, parent.Children[1]);
            parent.Children.Remove(child);
            Assert.Equal(parent, child.Parent);
            Assert.Contains(child, parent.Children);
            Assert.True(parent.Children.Count == 1);
            Assert.Equal(child, parent.Children[0]);
            var imodel  = model.ToImmutable();
            var iparent = parent.ToImmutable(imodel);
            var ichild  = child.ToImmutable(imodel);

            Assert.Equal(iparent, ichild.Parent);
            Assert.Contains(ichild, iparent.Children);
            Assert.True(iparent.Children.Count == 1);
            Assert.Equal(ichild, iparent.Children[0]);
        }
Beispiel #2
0
        public void TestChildToParentReset()
        {
            var model   = new MutableModel();
            var factory = new PropertiesTestFactory(model);
            var parent  = factory.ParentMultiList();
            var child   = factory.ChildMultiList();

            child.Parent = parent;
            Assert.Equal(parent, child.Parent);
            Assert.Contains(child, parent.Children);
            Assert.True(parent.Children.Count == 1);
            Assert.Equal(child, parent.Children[0]);
            child.Parent = null;
            Assert.Null(child.Parent);
            Assert.True(parent.Children.Count == 0);
            var imodel  = model.ToImmutable();
            var iparent = parent.ToImmutable(imodel);
            var ichild  = child.ToImmutable(imodel);

            Assert.Null(ichild.Parent);
            Assert.True(iparent.Children.Count == 0);
        }