コード例 #1
0
        public void CanUnlinkTwice()
        {
            var parent = new ConfigurableDictionaryNode {
                Children = new List <ConfigurableDictionaryNode>(), Parent = null
            };
            var node = new ConfigurableDictionaryNode {
                Children = new List <ConfigurableDictionaryNode>(), Parent = parent
            };

            parent.Children.Add(node);
            node.UnlinkFromParent();
            Assert.That(node.Parent, Is.Null);             // node is now at the root of a hierarchy
            // SUT
            Assert.DoesNotThrow(() => node.UnlinkFromParent());
        }
コード例 #2
0
        public void CanUnlink()
        {
            var parent = new ConfigurableDictionaryNode {
                Children = new List <ConfigurableDictionaryNode>(), Parent = null
            };
            var node = new ConfigurableDictionaryNode {
                Children = new List <ConfigurableDictionaryNode>(), Parent = parent
            };

            parent.Children.Add(node);
            // SUT
            node.UnlinkFromParent();
            Assert.That(parent.Children.Count, Is.EqualTo(0), "Parent should not link to unlinked child");
            Assert.That(node.Parent, Is.Null, "Node should not still claim the original parent");
        }