public void TestListParentChildStatic1() { ListParent p1 = new ListParent(); ListChild c1 = new ListChild(); ListChild c2 = new ListChild(); c1.Parent = p1; c2.Parent = p1; Assert.AreEqual(c1.Parent, p1); Assert.AreEqual(c2.Parent, p1); Assert.AreEqual(p1.Children.Count, 2); Assert.AreEqual(p1.Children[0], c1); Assert.AreEqual(p1.Children[1], c2); }
public void TestListChildParentStatic2() { ListParent p1 = new ListParent(); ListChild c1 = new ListChild(); ListChild c2 = new ListChild(); p1.Children.Add(c1); p1.Children.Add(c2); Assert.AreEqual(c1.Parent, p1); Assert.AreEqual(c2.Parent, p1); Assert.AreEqual(p1.Children.Count, 2); Assert.AreEqual(p1.Children[0], c1); Assert.AreEqual(p1.Children[1], c2); p1.Children.Remove(c1); Assert.AreEqual(c1.Parent, null); Assert.AreEqual(c2.Parent, p1); Assert.AreEqual(p1.Children.Count, 1); Assert.AreEqual(p1.Children[0], c2); }