public void AsBaseNodeReturnsTheSameNode() { var tree = HtmlTree.Create(DocumentFragment(Element("div"))); var div = tree.FirstChild.Value; var baseNode = div.AsBaseNode(); Assert.Same(div.Node, baseNode.Node); Assert.Same(tree.Node, baseNode.Parent.Value.Node); }
public void CastReturnsTheSameNodeTyped() { HtmlElement htmlElement; var tree = HtmlTree.Create(DocumentFragment(htmlElement = Element("div"))); var treeElement = tree.FirstChild.Value.Cast <HtmlElement>(); Assert.Same(htmlElement, treeElement.Node); Assert.Same(tree.Node, treeElement.Parent.Value.Node); }
public void AsWithWrongTypeThrowsInvalidCastException() => Assert.Throws <InvalidCastException>(() => HtmlTree.Create(Element("div")).As <HtmlDocument>());