public void ShouldThrowIfNodeIsNotInInitialList() { Assert.Throws <KeyNotFoundException>(() => { ChildNodeXPathContextProvider p = new ChildNodeXPathContextProvider(ctx, elements); p.Map(doc.CreateElement("foo")); }); }
public void ShouldReturnACopyOfOriginalXPathContext() { ChildNodeXPathContextProvider p = new ChildNodeXPathContextProvider(ctx, elements); XPathContext provided = p.Map(elements[0]); Assert.AreNotSame(ctx, provided); }
public void ShouldFindCorrectChildIndex() { ChildNodeXPathContextProvider p = new ChildNodeXPathContextProvider(ctx, elements); XPathContext provided = p.Map(elements[1]); Assert.AreEqual("/foo[2]", provided.XPath); }
private XPathContext GetXPathForNonAttribute(XmlNode n) { XmlNode parent = n.ParentNode; if (parent == null || parent is XmlDocument) { return(new XPathContext(prefix2uri, n)); } XPathContext parentContext = GetXPathForNonAttribute(parent); IEnumerable <XmlNode> children = parent.ChildNodes.Cast <XmlNode>(); parentContext.SetChildren(children.Select <XmlNode, XPathContext.INodeInfo>(ElementSelectors.TO_NODE_INFO)); ChildNodeXPathContextProvider cn = new ChildNodeXPathContextProvider(parentContext, children); return(cn.Map(n)); }