Beispiel #1
0
 public void ForEachAncestor_WithRoot()
 {
     var n = new MapNode(new MapTree(), null);
     n.ForEachAncestor(node => node.Text = "Try update text");
 }
Beispiel #2
0
        public void ForEachAncestor()
        {
            var n = new MapNode(new MapTree(), null);
            for (int i = 0; i < 5; i++)
            {
                n = new MapNode(n, null);
            }

            n.ForEachAncestor(a => a.Text = "Updated");

            Assert.AreEqual(n.Text, null);
            Assert.AreEqual(n.Parent.Text, "Updated");
            Assert.AreEqual(n.Parent.Parent.Text, "Updated");
            Assert.AreEqual(n.Parent.Parent.Parent.Text, "Updated");
            Assert.AreEqual(n.Parent.Parent.Parent.Parent.Text, "Updated");
            Assert.AreEqual(n.Parent.Parent.Parent.Parent.Parent.Text, "Updated");
            Assert.AreEqual(n.Parent.Parent.Parent.Parent.Parent.Parent, null);
        }