public void MixedWithNoValue()
        {
            var source = new TestSource4();
            var nav = new NavigableNavigator(source);

            var doc = XmlHelper.CreateXPathDocument(@"<root id=""-1"">
                        <type1 id=""1""><prop1><data value=""value""/></prop1><prop2>dang</prop2></type1>
                        <type1 id=""2""><prop1 /><prop2></prop2></type1>
                        <type1 id=""3""><prop1 /><prop2 /></type1>
                    </root>");
            var docNav = doc.CreateNavigator();

            docNav.MoveToRoot();
            Assert.IsTrue(docNav.MoveToFirstChild());
            Assert.AreEqual("root", docNav.Name);
            Assert.IsTrue(docNav.MoveToFirstChild());
            Assert.AreEqual("type1", docNav.Name);
            Assert.IsTrue(docNav.MoveToNext());
            Assert.AreEqual("type1", docNav.Name);
            Assert.IsTrue(docNav.MoveToNext());
            Assert.AreEqual("type1", docNav.Name);
            Assert.IsFalse(docNav.MoveToNext());

            docNav.MoveToRoot();
            var docOuter = docNav.OuterXml;

            nav.MoveToRoot();
            Assert.IsTrue(nav.MoveToFirstChild());
            Assert.AreEqual("root", nav.Name);
            Assert.IsTrue(nav.MoveToFirstChild());
            Assert.AreEqual("type1", nav.Name);
            Assert.IsTrue(nav.MoveToNext());
            Assert.AreEqual("type1", nav.Name);
            Assert.IsTrue(nav.MoveToNext());
            Assert.AreEqual("type1", nav.Name);
            Assert.IsFalse(nav.MoveToNext());

            nav.MoveToRoot();
            var outer = nav.OuterXml;

            Assert.AreEqual(docOuter, outer);
        }
        public void NavigateMixed()
        {
            var source = new TestSource2();
            var nav = new NavigableNavigator(source);

            nav.MoveToRoot();
            nav.MoveToFirstChild();
            Assert.AreEqual("root", nav.Name);
            nav.MoveToFirstChild();
            Assert.AreEqual("type1", nav.Name); // our content
            nav.MoveToFirstChild();
            Assert.AreEqual("prop1", nav.Name); // our property
            Assert.AreEqual(XPathNodeType.Element, nav.NodeType);
            nav.MoveToFirstChild();

            // "<data><item1>poo</item1><item2 xx=\"33\" /><item2 xx=\"34\" /></data>"

            Assert.AreEqual(XPathNodeType.Element, nav.NodeType);
            Assert.AreEqual("data", nav.Name);

            nav.MoveToFirstChild();
            Assert.AreEqual(XPathNodeType.Element, nav.NodeType);
            Assert.AreEqual("item1", nav.Name);

            nav.MoveToNext();
            Assert.AreEqual(XPathNodeType.Element, nav.NodeType);
            Assert.AreEqual("item2", nav.Name);

            nav.MoveToParent();
            Assert.AreEqual(XPathNodeType.Element, nav.NodeType);
            Assert.AreEqual("data", nav.Name);

            nav.MoveToParent();
            Assert.AreEqual(XPathNodeType.Element, nav.NodeType);
            Assert.AreEqual("prop1", nav.Name);
        }
        public void OuterXmlMixed()
        {
            var source = new TestSource2();
            var nav = new NavigableNavigator(source);

            nav.MoveToRoot();

            const string outerXml = @"<root id=""-1"">
  <type1 id=""1"">
    <prop1>
      <data>
        <item1>poo</item1>
        <item2 xx=""33"" />
        <item2 xx=""34"" />
      </data>
    </prop1>
  </type1>
</root>";

            Assert.AreEqual(outerXml.Lf(), nav.OuterXml.Lf());
        }
        public void Navigate()
        {
            var source = new TestSource1();
            var nav = new NavigableNavigator(source);

            nav.MoveToRoot();
            Assert.AreEqual("", nav.Name); // because we're at root
            nav.MoveToFirstChild();
            Assert.AreEqual("root", nav.Name);
            nav.MoveToFirstChild();
            Assert.AreEqual("type1", nav.Name); // our first content
            nav.MoveToFirstAttribute();
            Assert.AreEqual("id", nav.Name);
            Assert.AreEqual("1", nav.Value);
            nav.MoveToNextAttribute();
            Assert.AreEqual("prop1", nav.Name);
            Assert.AreEqual("1:p1", nav.Value);
            nav.MoveToNextAttribute();
            Assert.AreEqual("prop2", nav.Name);
            Assert.AreEqual("1:p2", nav.Value);
            Assert.IsFalse(nav.MoveToNextAttribute());
            nav.MoveToParent();
            nav.MoveToFirstChild();
            Assert.AreEqual("prop3", nav.Name);
            Assert.AreEqual("1:p3", nav.Value);

            Assert.IsFalse(nav.MoveToNext());
        }