public void TestParentToChild() { var model = new MutableModel(); var factory = new PropertiesTestFactory(model); var parent = factory.ParentList(); var child = factory.ChildList(); parent.Children.Add(child); Assert.Equal(parent, child.Parent); Assert.Contains(child, parent.Children); Assert.True(parent.Children.Count == 1); 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); }
public void TestChildToParentReset() { var model = new MutableModel(); var factory = new PropertiesTestFactory(model); var parent = factory.ParentList(); var child = factory.ChildList(); child.Parent = parent; Assert.Equal(parent, child.Parent); Assert.Contains(child, parent.Children); Assert.True(parent.Children.Count == 1); 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); }