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"); }
public void AttachToParentStoresParent() { var parent = new TransformationNode("parent"); var child = new TransformationNode("child"); child.AttachToParent(parent); Assert.AreSame(parent, child.Parent); }
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); }