Esempio n. 1
0
        public void Select_ShouldNotFindInvalidCswRecordsNodes(Type root, string xpath)
        {
            var navigator          = new XPathTypeNavigator(root, XPathTypeNodeTests.RecordsNamespacesManager);
            XPathNodeIterator xpni = navigator.Select(xpath, XPathTypeNodeTests.RecordsNamespacesManager, true);

            Assert.Equal <int>(0, xpni.Count);
        }
Esempio n. 2
0
        public void Select_ShouldNotFindInvalidCswRecordsNodes(Type root, string xpath)
        {
            var navigator=new XPathTypeNavigator(root, XPathTypeNodeTests.RecordsNamespacesManager);
            XPathNodeIterator xpni=navigator.Select(xpath, XPathTypeNodeTests.RecordsNamespacesManager, true);

            Assert.Equal<int>(0, xpni.Count);
        }
Esempio n. 3
0
        private XPathTypeNavigator GetNavigator(ExpressionBuilderParameters parameters)
        {
            if (_Navigator == null)
            {
                XPathTypeNavigator xptn = parameters.CreateNavigator();
                XPathNodeIterator  xpni = xptn.Select(Untyped.Value, parameters.NamespaceResolver, true);
                while (xpni.MoveNext())
                {
                    _Navigator = xpni.Current as XPathTypeNavigator;
                }

                Debug.Assert(_Navigator != null);
                if (_Navigator == null)
                {
                    throw new InvalidOperationException(
                              string.Format(
                                  CultureInfo.CurrentCulture,
                                  SR.InvalidPropertyNameExpressionException,
                                  Untyped.Value
                                  )
                              );
                }
            }

            return(_Navigator);
        }
Esempio n. 4
0
        public void Select_ShouldFindCswRecordsNodes(Type root, string xpath)
        {
            var navigator          = new XPathTypeNavigator(root, XPathTypeNodeTests.RecordsNamespacesManager);
            XPathNodeIterator xpni = navigator.Select(xpath, XPathTypeNodeTests.RecordsNamespacesManager, true);

            Assert.Equal <int>(1, xpni.Count);
            Assert.True(xpni.MoveNext());
            Assert.NotNull(xpni.Current);
            Assert.IsType <XPathTypeNavigator>(xpni.Current);
        }
Esempio n. 5
0
        public void Select_ShouldFindCswRecordsNodes(Type root, string xpath)
        {
            var navigator=new XPathTypeNavigator(root, XPathTypeNodeTests.RecordsNamespacesManager);
            XPathNodeIterator xpni=navigator.Select(xpath, XPathTypeNodeTests.RecordsNamespacesManager, true);

            Assert.Equal<int>(1, xpni.Count);
            Assert.True(xpni.MoveNext());
            Assert.NotNull(xpni.Current);
            Assert.IsType<XPathTypeNavigator>(xpni.Current);
        }
Esempio n. 6
0
        public void Select_ShouldSimpleNodeHaveValidProperties()
        {
            var navigator=new XPathTypeNavigator(typeof(TestRecordType), XPathTypeNodeTests.RecordsNamespacesManager);
            XPathNodeIterator xpni=navigator.Select("/csw:Record/dc:identifier", XPathTypeNodeTests.RecordsNamespacesManager, true);

            Assert.True(xpni.MoveNext());

            var current=(XPathTypeNavigator)xpni.Current;
            Assert.False(current.HasAttributes);
            Assert.False(current.HasChildren);
            Assert.False(current.IsEmptyElement);
            Assert.False(current.IsList);
            Assert.True(current.IsNode);
            Assert.Equal<string>("identifier", current.LocalName);
            Assert.Equal<string>("dc:identifier", current.Name);
            Assert.Equal<string>(Namespaces.DublinCoreElementsV11, current.NamespaceURI);
            Assert.Equal<XPathNodeType>(XPathNodeType.Element, current.NodeType);
            Assert.Equal<string>("dc", current.Prefix);
            Assert.Equal<Type>(typeof(string), current.Type);
        }
Esempio n. 7
0
        public void Select_ShouldCollectionNodeHaveValidProperties()
        {
            var navigator          = new XPathTypeNavigator(typeof(TestRecordType), XPathTypeNodeTests.RecordsNamespacesManager);
            XPathNodeIterator xpni = navigator.Select("/csw:Record/dc:subject", XPathTypeNodeTests.RecordsNamespacesManager, true);

            Assert.True(xpni.MoveNext());

            var current = (XPathTypeNavigator)xpni.Current;

            Assert.False(current.HasAttributes);
            Assert.False(current.HasChildren);
            Assert.False(current.IsEmptyElement);
            Assert.True(current.IsList);
            Assert.True(current.IsNode);
            Assert.Equal <string>("subject", current.LocalName);
            Assert.Equal <string>("dc:subject", current.Name);
            Assert.Equal <string>(Namespaces.DublinCoreElementsV11, current.NamespaceURI);
            Assert.Equal <XPathNodeType>(XPathNodeType.Element, current.NodeType);
            Assert.Equal <string>("dc", current.Prefix);
            Assert.Equal <Type>(typeof(string), current.Type);
        }