public void Execute_FromElementWithManyNamespacesIgnoringDefaultNamespace_ValueCorrect() { var from = "//PurchaseOrder/Address/Street"; var selects = new List <ElementSelect>() { new ElementSelect(new LiteralScalarResolver <string>(".")) }; using (var reader = GetResourceReader("PurchaseOrdersManyNamespaces")) { var engine = new XPathEngine(new LiteralScalarResolver <string>(from), selects, "prefix", true); var result = engine.Execute(reader); Assert.That((result.ElementAt(0) as IEnumerable <object>).ElementAt(0), Is.EqualTo("123 Maple Street")); } }
public void Execute_FromAttribute_ValueCorrect() { var from = "//PurchaseOrder/Items/Item"; var selects = new List <ElementSelect>() { new AttributeSelect(new LiteralScalarResolver <string>("."), "PartNumber") }; using (var reader = GetResourceReader("PurchaseOrders")) { var engine = new XPathEngine(new LiteralScalarResolver <string>(from), selects, string.Empty, false); var result = engine.Execute(reader); Assert.That((result.ElementAt(0) as IEnumerable <object>).ElementAt(0), Is.EqualTo("872-AA")); } }
public void Execute_FromElementWithDefaultNamespaceAndIgnoreDefaultNamespace_ValueCorrect() { var from = "//PurchaseOrder/Items/Item/ProductName"; var selects = new List <ElementSelect>() { new ElementSelect(new LiteralScalarResolver <string>(".")) }; using (var reader = GetResourceReader("PurchaseOrdersDefaultNamespace")) { var engine = new XPathEngine(new LiteralScalarResolver <string>(from), selects, "prefix", true); var result = engine.Execute(reader); Assert.That((result.ElementAt(0) as IEnumerable <object>).ElementAt(0), Is.EqualTo("Lawnmower")); } }
public void Execute_MissingElement_Null() { var from = "//PurchaseOrder/Items/Item"; var selects = new List <ElementSelect>() { new ElementSelect(new LiteralScalarResolver <string>("//PurchaseOrder/Missing")) }; using (var reader = GetResourceReader("PurchaseOrders")) { var engine = new XPathEngine(new LiteralScalarResolver <string>(from), selects, string.Empty, false); var result = engine.Execute(reader); Assert.That((result.ElementAt(0) as IEnumerable <object>).ElementAt(0), Is.EqualTo("(null)")); } }
public void Execute_Example_RowCount(string from, int rowCount) { var selects = new List <ElementSelect>() { new ElementSelect(new LiteralScalarResolver <string>("//PurchaseOrder/PurchaseOrderNumber")) , new AttributeSelect(new LiteralScalarResolver <string>("."), "PartNumber") , new ElementSelect(new LiteralScalarResolver <string>("//PurchaseOrder/Address[@Type=\"Shiping\"]/City")) }; using (var reader = GetResourceReader("PurchaseOrders")) { var engine = new XPathEngine(new LiteralScalarResolver <string>(from), selects, string.Empty, false); var result = engine.Execute(reader); Assert.That(result.Count, Is.EqualTo(rowCount)); } }
public void Execute_ParentElement_ValueCorrect() { var from = "//PurchaseOrder/Items/Item"; var selects = new List <ElementSelect>() { new ElementSelect(new LiteralScalarResolver <string>("//PurchaseOrder")) }; using (var reader = GetResourceReader("PurchaseOrders")) { var engine = new XPathEngine(new LiteralScalarResolver <string>(from), selects, string.Empty, false); var result = engine.Execute(reader); Assert.That((result.ElementAt(0) as IEnumerable <object>).ElementAt(0), Does.Contain("Ellen Adams")); Assert.That((result.ElementAt(0) as IEnumerable <object>).ElementAt(0), Does.Contain("Maple Street")); } }
public void Execute_Example_ColumnCount() { var from = "//PurchaseOrder/Items/Item"; var selects = new List <ElementSelect>() { new ElementSelect(new LiteralScalarResolver <string>("//PurchaseOrder/PurchaseOrderNumber")) , new AttributeSelect(new LiteralScalarResolver <string>("."), "PartNumber") , new ElementSelect(new LiteralScalarResolver <string>("//PurchaseOrder/Address[@Type=\"Shiping\"]/City")) }; using (var reader = GetResourceReader("PurchaseOrders")) { var engine = new XPathEngine(new LiteralScalarResolver <string>(from), selects, string.Empty, false); var result = engine.Execute(reader); Assert.That((result.ElementAt(0) as IEnumerable <object>).Count, Is.EqualTo(3)); } }