Пример #1
0
 public void TestSetChildParentStatic3()
 {
     SetParent p1 = new SetParent();
     SetChild c1 = new SetChild();
     SetChild c2 = new SetChild();
     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.IsTrue(p1.Children.Contains(c1));
     Assert.IsTrue(p1.Children.Contains(c2));
     p1.Children.Remove(c1);
     Assert.AreEqual(c1.Parent, null);
     Assert.AreEqual(c2.Parent, p1);
     Assert.AreEqual(p1.Children.Count, 1);
     Assert.IsFalse(p1.Children.Contains(c1));
     Assert.IsTrue(p1.Children.Contains(c2));
     p1.Children.Remove(c2);
     Assert.AreEqual(c1.Parent, null);
     Assert.AreEqual(c2.Parent, null);
     Assert.AreEqual(p1.Children.Count, 0);
 }
Пример #2
0
 public void TestSetParentChildStatic2()
 {
     SetParent p1 = new SetParent();
     SetChild c1 = new SetChild();
     SetChild c2 = new SetChild();
     c1.Parent = p1;
     c2.Parent = p1;
     Assert.AreEqual(c1.Parent, p1);
     Assert.AreEqual(c2.Parent, p1);
     Assert.AreEqual(p1.Children.Count, 2);
     Assert.IsTrue(p1.Children.Contains(c1));
     Assert.IsTrue(p1.Children.Contains(c2));
     c1.Parent = null;
     Assert.AreEqual(c1.Parent, null);
     Assert.AreEqual(c2.Parent, p1);
     Assert.AreEqual(p1.Children.Count, 1);
     Assert.IsFalse(p1.Children.Contains(c1));
     Assert.IsTrue(p1.Children.Contains(c2));
 }