public void XPath1SchemeNoSelectedNodeTest() { string xptr = "xpath1(no-such-node/foo)"; XmlReader reader = new XmlTextReader(Globals.GetResource(Globals.PubsNsResource)); XPointerReader xpr = new XPointerReader(reader, xptr); while (xpr.Read()) {} }
public void XPath1SchemeScalarResultTest() { string xptr = "xpath1(2+2)"; XmlReader reader = new XmlTextReader(Globals.GetResource(Globals.PubsNsResource)); XPointerReader xpr = new XPointerReader(reader, xptr); while (xpr.Read()) {} }
public void XPath1SchemeWithoutXmlnsTest() { string xptr = "xpath1(m:dsPubs/m:publishers[m:pub_id='1389']/m:pub_name)"; XmlReader reader = new XmlTextReader(Globals.GetResource(Globals.PubsNsResource)); XPointerReader xpr = new XPointerReader(reader, xptr); StringBuilder sb = new StringBuilder(); while (xpr.Read()) { sb.Append(xpr.ReadOuterXml()); } string expected = @"<pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name>"; Assert.AreEqual(sb.ToString(), expected); }
public void XSDDefnedIDTest() { string xptr = "element(id1389/1)"; XmlReader reader = new XmlTextReader("../../pubsNS.xml"); XPointerReader xpr = new XPointerReader(reader, xptr, true); string expected = @"<pub_name>Algodata Infosystems</pub_name>"; while (xpr.Read()) { Assert.AreEqual(xpr.ReadOuterXml(), expected); return; } throw new InvalidOperationException("This means XPointer didn't work as expected."); }
public void UnknownSchemeTest3() { string xptr = "xmlns(foo=http://foo.com/schemas)foo:dummy(bar) element(/1/1/2)"; XmlReader reader = new XmlTextReader("../../northwind.xml"); XPointerReader xpr = new XPointerReader(reader, xptr); string expected = @"<CompanyName> Alfreds Futterkiste</CompanyName>"; while (xpr.Read()) { Assert.AreEqual(xpr.ReadOuterXml(), expected); return; } throw new InvalidOperationException("This means XPointer didn't work as expected."); }
public void CompoundPointerTest() { string xptr = "xmlns(p=12345)xpath1(/no/such/node) xpointer(/and/such) element(/1/1/2) element(o10535/1)"; XmlReader reader = new XmlTextReader("../../northwind.xml"); XPointerReader xpr = new XPointerReader(reader, xptr); string expected = @"<CompanyName> Alfreds Futterkiste</CompanyName>"; while (xpr.Read()) { Assert.AreEqual(xpr.ReadOuterXml(), expected); return; } throw new InvalidOperationException("This means XPointer didn't work as expected."); }
public void ElementSchemeTest2() { string xptr = "element(o10535/1)"; XmlReader reader = new XmlTextReader("../../northwind.xml"); XPointerReader xpr = new XPointerReader(reader, xptr); string expected = @"<OrderDate> 6/13/95</OrderDate>"; while (xpr.Read()) { Assert.AreEqual(xpr.ReadOuterXml(), expected); return; } throw new InvalidOperationException("This means XPointer didn't work as expected."); }
public void ShorthandViaStreamTest() { string xptr = "o10535"; FileInfo file = new FileInfo("../../northwind.xml"); using (FileStream fs = file.OpenRead()) { XPointerReader xpr = new XPointerReader( new XmlTextReader(file.FullName, fs), xptr); string expected = @"<Item orderID=""o10535""> <OrderDate> 6/13/95</OrderDate> <ShipAddress> Mataderos 2312</ShipAddress> </Item>"; while (xpr.Read()) { Assert.AreEqual(xpr.ReadOuterXml(), expected); return; } throw new InvalidOperationException("This means shorthand XPointer didn't work as expected."); } }
public void XPointerSchemeScalarResultTest() { string xptr = "xpointer(2+2)"; using (XmlReader reader = XmlReader.Create( Globals.GetResource(Globals.PubsNsResource), readerSettings)) { XPointerReader xpr = new XPointerReader(reader, xptr); while (xpr.Read()) { } } }
public void NamespaceRedefinitionTest() { string xptr = "xmlns(m=mvp-xml)xmlns(m=http://foo.com)xmlns(m=mvp-xml)xpointer(m:dsPubs/m:publishers[m:pub_id='1389']/m:pub_name)"; XmlReader reader = new XmlTextReader(Globals.GetResource(Globals.PubsNsResource)); XPointerReader xpr = new XPointerReader(reader, xptr); StringBuilder sb = new StringBuilder(); while (xpr.Read()) { sb.Append(xpr.ReadOuterXml()); } string expected = @"<pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name>"; Assert.AreEqual(sb.ToString(), expected); }
public void XmlnsAfterTest() { string xptr = "xpointer(m:dsPubs/m:publishers[m:pub_id='1389']/m:pub_name)xmlns(m=mvp-xml)"; XmlReader reader = new XmlTextReader(Globals.GetResource(Globals.PubsNsResource)); XPointerReader xpr = new XPointerReader(reader, xptr); while (xpr.Read()) {} }
public void SuperfluousXmlNsSchemeTest() { string xptr = "xmlns(m=mvp-xml)xpointer(dsPubs/publishers[pub_id='1389']/pub_name)"; XmlReader reader = new XmlTextReader(Globals.GetResource(Globals.PubsResource)); XPointerReader xpr = new XPointerReader(reader, xptr); StringBuilder sb = new StringBuilder(); while (xpr.Read()) { sb.Append(xpr.ReadOuterXml()); } string expected = @"<pub_name>Algodata Infosystems</pub_name>"; Assert.AreEqual(sb.ToString(), expected); }
public void XPath1SchemeNoSelectedNodeTest() { string xptr = "xpath1(no-such-node/foo)"; using (XmlReader reader = XmlReader.Create( Globals.GetResource(Globals.PubsNsResource), readerSettings)) { XPointerReader xpr = new XPointerReader(reader, xptr); while (xpr.Read()) { } } }
public void UnknownSchemeTest2() { string xptr = "foo:dummy(bar) element(/1/1/2)"; using (XmlReader reader = XmlReader.Create( "../../XPointer/northwind.xml", readerSettings)) { XPointerReader xpr = new XPointerReader(reader, xptr); string expected = @"<CompanyName> Alfreds Futterkiste</CompanyName>"; while (xpr.Read()) { Assert.AreEqual(xpr.ReadOuterXml(), expected); return; } throw new InvalidOperationException("This means XPointer didn't work as expected."); } }
public void ElementSchemeTest() { string xptr = "element(o10535)"; using (XmlReader reader = XmlReader.Create( "../../XPointer/northwind.xml", readerSettings)) { XPointerReader xpr = new XPointerReader(reader, xptr); string expected = @"<Item orderID=""o10535""><OrderDate> 6/13/95</OrderDate><ShipAddress> Mataderos 2312</ShipAddress></Item>"; while (xpr.Read()) { Assert.AreEqual(xpr.ReadOuterXml(), expected); return; } throw new InvalidOperationException("This means XPointer didn't work as expected."); } }
public void XmlnsAfterTest() { string xptr = "xpointer(m:dsPubs/m:publishers[m:pub_id='1389']/m:pub_name)xmlns(m=mvp-xml)"; using (XmlReader reader = XmlReader.Create( Globals.GetResource(Globals.PubsNsResource), readerSettings)) { XPointerReader xpr = new XPointerReader(reader, xptr); while (xpr.Read()) { } } }
public void ShorthandTest() { string xptr = "o10535"; XmlReader reader = new XmlTextReader("../../northwind.xml"); XPointerReader xpr = new XPointerReader(reader, xptr); string expected = @"<Item orderID=""o10535""> <OrderDate> 6/13/95</OrderDate> <ShipAddress> Mataderos 2312</ShipAddress> </Item>"; while (xpr.Read()) { Assert.AreEqual(xpr.ReadOuterXml(), expected); return; } throw new InvalidOperationException("This means shorthand XPointer didn't work as expected."); }
public void XmlNsXPointerSchemeTest() { string xptr = "xmlns(m=mvp-xml)xpointer(m:dsPubs/m:publishers[m:pub_id='1389']/m:pub_name)"; using (XmlReader reader = XmlReader.Create( Globals.GetResource(Globals.PubsNsResource), readerSettings)) { XPointerReader xpr = new XPointerReader(reader, xptr); StringBuilder sb = new StringBuilder(); while (xpr.Read()) { sb.Append(xpr.ReadOuterXml()); } string expected = @"<pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name>"; Assert.AreEqual(sb.ToString(), expected); } }