Example #1
0
        public void RemoveChildrenAfterDisposeThrowsException()
        {
            var node = new DummyNavigable("node");

            using var child = new DummyNavigable("child");
            node.Add(child);
            node.Dispose();
            Assert.That(() => node.RemoveChildren(), Throws.TypeOf <ObjectDisposedException>());
        }
Example #2
0
        public void RemoveChildrenRemovesInnerChildren()
        {
            using DummyNavigable parent    = new DummyNavigable("Parent");
            using DummyNavigable child1    = new DummyNavigable("Child1");
            using DummyNavigable child2    = new DummyNavigable("Child2");
            using DummyNavigable subchild1 = new DummyNavigable("Subchild1");
            child1.Add(subchild1);
            parent.Add(child1);
            parent.Add(child2);

            parent.RemoveChildren();
            Assert.IsEmpty(parent.Children);
            Assert.IsEmpty(child1.Children);
        }
Example #3
0
        public void RemoveChildren()
        {
            var children = new List <DummyNavigable>();

            children.Add(new DummyNavigable("MyChild1"));
            children.Add(new DummyNavigable("MyChild2"));
            children.Add(new DummyNavigable("MyChild3"));
            var parent = new DummyNavigable("MyParent");

            parent.Add(children);
            Assert.AreEqual(3, parent.Children.Count);

            parent.RemoveChildren();
            Assert.IsEmpty(parent.Children);
        }
Example #4
0
        public void RemoveChildrenDisposeChildren()
        {
            using DummyNavigable parent    = new DummyNavigable("Parent");
            using DummyNavigable child1    = new DummyNavigable("Child1");
            using DummyNavigable child2    = new DummyNavigable("Child2");
            using DummyNavigable subchild1 = new DummyNavigable("Subchild1");
            child1.Add(subchild1);
            parent.Add(child1);
            parent.Add(child2);

            Assert.IsFalse(parent.Disposed);
            Assert.IsFalse(child1.Disposed);
            Assert.IsFalse(child2.Disposed);
            Assert.IsFalse(subchild1.Disposed);

            parent.RemoveChildren();
            Assert.IsFalse(parent.Disposed);
            Assert.IsTrue(child1.Disposed);
            Assert.IsTrue(child2.Disposed);
            Assert.IsTrue(subchild1.Disposed);
        }