public void SelectById(int id)
        {
            var source = new TestSource5();
            var nav = new NavigableNavigator(source);

            var iter = nav.Select(string.Format("//* [@id={0}]", id));
            Assert.IsTrue(iter.MoveNext());
            var current = iter.Current as NavigableNavigator;
            Assert.AreEqual(NavigableNavigator.StatePosition.Element, current.InternalState.Position);
            Assert.AreEqual(id, (current.UnderlyingObject as TestContent).Id);
        }
 public void SelectByIdWithVariable(int id)
 {
     var source = new TestSource5();
     var nav = new NavigableNavigator(source);
     
     var iter = nav.Select("//* [@id=$id]", new XPathVariable("id", id.ToString(CultureInfo.InvariantCulture)));
     Assert.IsTrue(iter.MoveNext());
     var current = iter.Current as NavigableNavigator;
     Assert.AreEqual(NavigableNavigator.StatePosition.Element, current.InternalState.Position);
     Assert.AreEqual(id, (current.UnderlyingObject as TestContent).Id);
 }
        public void XmlNodeList()
        {
            var source = new TestSource1();
            var nav = new NavigableNavigator(source);

            var iterator = nav.Select("/*");

            // but, that requires that the underlying navigator implements IHasXmlNode
            // so it is possible to obtain nodes from the navigator - not possible yet
            var nodes = XmlNodeListFactory.CreateNodeList(iterator);

            Assert.AreEqual(nodes.Count, 1);
            var node = nodes[0];

            Assert.AreEqual(3, node.Attributes.Count);
            Assert.AreEqual("1", node.Attributes["id"].Value);
            Assert.AreEqual("1:p1", node.Attributes["prop1"].Value);
            Assert.AreEqual("1:p2", node.Attributes["prop2"].Value);
            Assert.AreEqual(1, node.ChildNodes.Count);
            Assert.AreEqual("prop3", node.FirstChild.Name);
            Assert.AreEqual("1:p3", node.FirstChild.Value);
        }
        public void QueryMixedWithVariables()
        {
            var source = new TestSource2();
            var nav = new NavigableNavigator(source);

            var iterator = nav.Select("//item2 [@xx=$var]", new XPathVariable("var", "33"));
            Assert.AreEqual(1, iterator.Count);
            iterator.MoveNext();
            Assert.AreEqual("item2", iterator.Current.Name);
        }
        public void QueryWithVariables()
        {
            var source = new TestSource1();
            var nav = new NavigableNavigator(source);

            var iterator = nav.Select("//* [@prop1=$var]", new XPathVariable("var", "1:p1"));
            Assert.AreEqual(1, iterator.Count);
            iterator.MoveNext();
            Assert.AreEqual("type1", iterator.Current.Name);
        }
        public void QueryMixed()
        {
            var source = new TestSource2();
            var nav = new NavigableNavigator(source);

            var doc = XmlHelper.CreateXPathDocument("<data><item1>poo</item1><item2 xx=\"33\" /><item2 xx=\"34\" /></data>");
            var docNav = doc.CreateNavigator();
            var docIter = docNav.Select("//item2 [@xx=33]");
            Assert.AreEqual(1, docIter.Count);
            Assert.AreEqual("", docIter.Current.Name);
            docIter.MoveNext();
            Assert.AreEqual("item2", docIter.Current.Name);

            var iterator = nav.Select("//item2 [@xx=33]");
            Assert.AreEqual(1, iterator.Count);
            Assert.AreEqual("", iterator.Current.Name);
            iterator.MoveNext();
            Assert.AreEqual("item2", iterator.Current.Name);
        }
        public void Query()
        {
            var source = new TestSource1();
            var nav = new NavigableNavigator(source);

            var iterator = nav.Select("//type1");
            Assert.AreEqual(1, iterator.Count);
            iterator.MoveNext();
            Assert.AreEqual("type1", iterator.Current.Name);

            iterator = nav.Select("//* [@prop1='1:p1']");
            Assert.AreEqual(1, iterator.Count);
            iterator.MoveNext();
            Assert.AreEqual("type1", iterator.Current.Name);
        }