/// <summary> /// 调用此方法通知预热 JumonyParser /// </summary> public static void WarmUp() { if (!_isWarmedUp) { JumonyReader.WarmUp(); HtmlSpecification.WarmUp(); _isWarmedUp = true; } }
//[TestMethod] 这个测试已经过时。 public void SpecificationTest3() { //测试各种异常标签是否不被识别 var str = File.ReadAllText( Path.Combine( Environment.CurrentDirectory, "SpecificationTest3.html" ) ); var contents = new JumonyReader( str ).EnumerateContent().ToArray(); var tag = contents.OfType<HtmlBeginTag>().FirstOrDefault(); Assert.IsNull( tag, string.Format( "找到不应当解析出来的标签 {0}", tag ) ); }
public void SpecificationTest4() { //测试中文标签和中文属性是否能够被识别 var str = File.ReadAllText( Path.Combine( Environment.CurrentDirectory, "SpecificationTest4.html" ) ); var contents = new JumonyReader( str ).EnumerateContent().ToArray(); var beginTags = contents.OfType<HtmlBeginTag>().ToArray(); var endTags = contents.OfType<HtmlEndTag>().ToArray(); Assert.IsTrue( beginTags.Length >= 1, "无法解析中文名称标签" ); Assert.IsTrue( beginTags.Length == 2, "无法解析中文名称属性" ); Assert.AreEqual( endTags.Length, 2, "无法解析中文名称结束标签" ); }
public void SpecificationTest4() { //测试中文标签和中文属性是否能够被识别 var str = File.ReadAllText( Path.Combine( Environment.CurrentDirectory, "SpecificationTest4.html" ) ); var contents = new JumonyReader( str ).EnumerateContent().ToArray(); var beginTags = contents.OfType<HtmlBeginTag>().ToArray(); var endTags = contents.OfType<HtmlEndTag>().ToArray(); Assert.AreEqual( beginTags.Length, 1, "无法解析中文名称属性" ); Assert.AreEqual( beginTags[0].Attributes.Count(), 1, "无法解析中文名称属性" ); Assert.AreEqual( beginTags[0].Attributes.First().Name, "中文", "无法解析中文名称属性" ); }