Пример #1
0
        public void Execute_FromElement_ValueCorrect()
        {
            var from    = "//PurchaseOrder/Items/Item/ProductName";
            var selects = new List <ElementSelect>()
            {
                new ElementSelect(".")
            };

            using (var reader = GetResourceReader())
            {
                var engine = new XPathStreamEngine(reader, from, selects);
                var result = engine.Execute();
                Assert.That((result.ElementAt(0) as IEnumerable <object>).ElementAt(0), Is.EqualTo("Lawnmower"));
            }
        }
Пример #2
0
        public void Execute_ChildElement_ValueCorrect()
        {
            var from    = "//PurchaseOrder/Items/Item";
            var selects = new List <ElementSelect>()
            {
                new ElementSelect("//PurchaseOrder/Items/Item/ProductName")
            };

            using (var reader = GetResourceReader())
            {
                var engine = new XPathStreamEngine(reader, from, selects);
                var result = engine.Execute();
                Assert.That(result.Rows[0].ItemArray[0], Is.EqualTo("Lawnmower"));
            }
        }
Пример #3
0
        public void Execute_MissingAttribute_ValueCorrect()
        {
            var from    = "//PurchaseOrder/Items/Item";
            var selects = new List <ElementSelect>()
            {
                new AttributeSelect("//PurchaseOrder", "Missing")
            };

            using (var reader = GetResourceReader())
            {
                var engine = new XPathStreamEngine(reader, from, selects);
                var result = engine.Execute();
                Assert.That((result.ElementAt(0) as IEnumerable <object>).ElementAt(0), Is.EqualTo("(null)"));
            }
        }
Пример #4
0
        public void Execute_MissingAttribute_ValueCorrect()
        {
            var from    = "//PurchaseOrder/Items/Item";
            var selects = new List <ElementSelect>()
            {
                new AttributeSelect("//PurchaseOrder", "Missing")
            };

            using (var reader = GetResourceReader())
            {
                var engine = new XPathStreamEngine(reader, from, selects);
                var result = engine.Execute();
                Assert.That(result.Rows[0].ItemArray[0], Is.EqualTo(DBNull.Value));
            }
        }
Пример #5
0
        public void Execute_ChildElement_ValueCorrect()
        {
            var from = "//PurchaseOrder/Items/Item";
            var selects = new List<ElementSelect>()
            {
                new ElementSelect("//PurchaseOrder/Items/Item/ProductName")
            };

            using (var reader = GetResourceReader())
            {
                var engine = new XPathStreamEngine(reader, from, selects);
                var result = engine.Execute();
                Assert.That(result.Rows[0].ItemArray[0], Is.EqualTo("Lawnmower"));
            }
        }
Пример #6
0
        public void Execute_ChildAttribute_ValueCorrect()
        {
            var from = "//PurchaseOrder/Items";
            var selects = new List<ElementSelect>()
            {
                new AttributeSelect("//PurchaseOrder/Items/Item","PartNumber")
            };

            using (var reader = GetResourceReader())
            {
                var engine = new XPathStreamEngine(reader, from, selects);
                var result = engine.Execute();
                Assert.That(result.Rows[0].ItemArray[0], Is.EqualTo("872-AA"));
            }
        }
Пример #7
0
        public void Execute_Example_RowCount(string from, int rowCount)
        {
            var selects = new List <ElementSelect>()
            {
                new ElementSelect("//PurchaseOrder/PurchaseOrderNumber")
                , new AttributeSelect(".", "PartNumber")
                , new ElementSelect("//PurchaseOrder/Address[@Type=\"Shiping\"]/City")
            };

            using (var reader = GetResourceReader())
            {
                var engine = new XPathStreamEngine(reader, from, selects);
                var result = engine.Execute();
                Assert.That(result.Count, Is.EqualTo(rowCount));
            }
        }
Пример #8
0
        public void Execute_ParentElement_ValueCorrect()
        {
            var from    = "//PurchaseOrder/Items/Item";
            var selects = new List <ElementSelect>()
            {
                new ElementSelect("//PurchaseOrder")
            };

            using (var reader = GetResourceReader())
            {
                var engine = new XPathStreamEngine(reader, from, selects);
                var result = engine.Execute();
                Assert.That((result.ElementAt(0) as IEnumerable <object>).ElementAt(0), Is.StringStarting("Ellen Adams"));
                Assert.That((result.ElementAt(0) as IEnumerable <object>).ElementAt(0), Is.StringContaining("Maple Street"));
            }
        }
Пример #9
0
        public void Execute_Example_ColumnCount()
        {
            var from    = "//PurchaseOrder/Items/Item";
            var selects = new List <ElementSelect>()
            {
                new ElementSelect("//PurchaseOrder/PurchaseOrderNumber")
                , new AttributeSelect(".", "PartNumber")
                , new ElementSelect("//PurchaseOrder/Address[@Type=\"Shiping\"]/City")
            };

            using (var reader = GetResourceReader())
            {
                var engine = new XPathStreamEngine(reader, from, selects);
                var result = engine.Execute();
                Assert.That((result.ElementAt(0) as IEnumerable <object>).Count, Is.EqualTo(3));
            }
        }
Пример #10
0
        public void Execute_Example_ColumnCount()
        {
            var from = "//PurchaseOrder/Items/Item";
            var selects = new List<ElementSelect>()
            {
                new ElementSelect("//PurchaseOrder/PurchaseOrderNumber")
                , new AttributeSelect(".", "PartNumber")
                , new ElementSelect("//PurchaseOrder/Address[@Type=\"Shiping\"]/City")
            };

            using (var reader = GetResourceReader())
            {
                var engine = new XPathStreamEngine(reader, from, selects);
                var result = engine.Execute();
                Assert.That(result.Columns.Count, Is.EqualTo(3));
            }
        }
Пример #11
0
        public void Execute_ParentElement_ValueCorrect()
        {
            var from = "//PurchaseOrder/Items/Item";
            var selects = new List<ElementSelect>()
            {
                new ElementSelect("//PurchaseOrder")
            };

            using (var reader = GetResourceReader())
            {
                var engine = new XPathStreamEngine(reader, from, selects);
                var result = engine.Execute();
                Assert.That(result.Rows[0].ItemArray[0], Is.StringStarting("Ellen Adams"));
                Assert.That(result.Rows[0].ItemArray[0], Is.StringContaining("Maple Street"));
            }
        }
Пример #12
0
        public void Execute_MissingElement_Null()
        {
            var from = "//PurchaseOrder/Items/Item";
            var selects = new List<ElementSelect>()
            {
                new ElementSelect("//PurchaseOrder/Missing")
            };

            using (var reader = GetResourceReader())
            {
                var engine = new XPathStreamEngine(reader, from, selects);
                var result = engine.Execute();
                Assert.That(result.Rows[0].ItemArray[0], Is.EqualTo(DBNull.Value));
            }
        }