Exemplo n.º 1
0
 public void SpecificationTest1()
 {
     //测试孤立的'<'能否被正确解析
       var document = new JumonyParser().LoadDocument( Path.Combine( Environment.CurrentDirectory, "SpecificationTest1.html" ) );
       var element = document.FindSingle( "a" );//需要找到一个<a>元素
       Assert.AreEqual( element.InnerHtml(), "abc" );//并且内容是"abc"
       Assert.AreEqual( element.Attributes().Count(), 1 );//有且只有一个属性
       Assert.AreEqual( element.Attribute( "abc" ).AttributeValue, "abc" );//属性值为"abc"
       var textNode = document.Nodes().ElementAt( 0 ) as IHtmlTextNode;
       Assert.IsNotNull( textNode );
       Assert.IsTrue( textNode.HtmlText.Contains( '<' ) );//第一个文本节点包含了那个孤立的 '<'
 }