示例#1
0
        public void SimpleElement()
        {
            HtmlPathElement e = new HtmlPathElement( "Tr", 3 );

            Assert.AreEqual( "TR", e.TagName );
            Assert.AreEqual( 3, e.Position );
            Assert.IsFalse( e.IsTableOrTBody );
            Assert.AreEqual( "TR[3]", e.ToString() );
        }
示例#2
0
        /// <summary/>
        public static HtmlPath Parse(string pathStr)
        {
            if (string.IsNullOrEmpty(pathStr))
            {
                throw new ArgumentException("value is null or empty string", "pathStr");
            }

            var pathElements = pathStr.Split(PathSeparator)
                               .Where(token => !token.IsNullOrTrimmedEmpty())
                               .Select(token => HtmlPathElement.Parse(token));

            return(new HtmlPath(pathElements));
        }
示例#3
0
        public void PathElementWithWrongInput()
        {
            try
            {
                HtmlPathElement e = new HtmlPathElement( null, 0 );
                Assert.Fail( "It should not possible to create a HtmlPathElement with empty TagName" );
            }
            catch { }

            try
            {
                HtmlPathElement e = new HtmlPathElement( "  ", 0 );
                Assert.Fail( "It should not possible to create a HtmlPathElement with empty TagName" );
            }
            catch { }

            try
            {
                HtmlPathElement e = new HtmlPathElement( "TR", -1 );
                Assert.Fail( "It should not possible to create a HtmlPathElement with negative position" );
            }
            catch { }
        }
示例#4
0
        public void TableElement()
        {
            HtmlPathElement e = new HtmlPathElement( "Table", 3 );

            Assert.IsTrue( e.IsTableOrTBody );

            e = new HtmlPathElement( "Tbody", 3 );

            Assert.IsTrue( e.IsTableOrTBody );
        }