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() ); }
/// <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)); }
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 { } }
public void TableElement() { HtmlPathElement e = new HtmlPathElement( "Table", 3 ); Assert.IsTrue( e.IsTableOrTBody ); e = new HtmlPathElement( "Tbody", 3 ); Assert.IsTrue( e.IsTableOrTBody ); }