コード例 #1
0
        public void ReattachToParentThrows()
        {
            var parent    = new TransformationNode("parent");
            var newParent = new TransformationNode("newParent");
            var child     = new TransformationNode("child");

            child.AttachToParent(parent);

            Assert.ThrowsException <InvalidOperationException>(() => child.AttachToParent(parent), "original parent");
            Assert.ThrowsException <InvalidOperationException>(() => child.AttachToParent(newParent), "new parent");
        }
コード例 #2
0
        public void AttachToParentStoresParent()
        {
            var parent = new TransformationNode("parent");
            var child  = new TransformationNode("child");

            child.AttachToParent(parent);
            Assert.AreSame(parent, child.Parent);
        }
コード例 #3
0
        public TransformationNode CreateNode(TransformationNode precursor, string word)
        {
            // can remove this restriction if we want (since the other overload allows it, anyway)
            if (precursor == null)
            {
                throw new ArgumentNullException(nameof(precursor));
            }

            var node = new TransformationNode(word);

            node.AttachToParent(precursor);
            return(node);
        }