Exemplo n.º 1
0
        public void CanRemoveChild()
        {
            var parent = new TestTreeEntry {Name = "parent"};
            var child = new TestTreeEntry {Name = "child", Parent = parent};

            parent.RemoveChild(child);

            parent.IsNotParentOf(child);
            Assert.Null(child.Parent);
        }
Exemplo n.º 2
0
        public void CanSwitchParent()
        {
            var parent1 = new TestTreeEntry {Name = "parent1"};
            var parent2 = new TestTreeEntry {Name = "parent1"};
            var child = new TestTreeEntry {Name = "child", Parent = parent1};
            child.Parent = parent2;

            parent1.IsNotParentOf(child);

            parent2.IsParentOf(child);
        }
Exemplo n.º 3
0
        public void WhenRemovingGrandChild()
        {
            var parent = new TestTreeEntry {Name = "parent"};
            var child = new TestTreeEntry {Name = "child", Parent = parent};
            var grandChild = new TestTreeEntry {Name = "grandChild", Parent = child};

            child.RemoveChild(grandChild);

            parent.IsParentOf(child);
            child.IsNotParentOf(grandChild);
            parent.IsNotAncestorOf(grandChild);
        }
Exemplo n.º 4
0
        public void CanSetParentToNull()
        {
            var parent = new TestTreeEntry {Name = "parent"};
            var child = new TestTreeEntry {Name = "child", Parent = parent};
            child.Parent = null;

            parent.IsNotParentOf(child);
            Assert.Null(child.Parent);
        }