public static HtmlFile ( string path ) : |
||
path | string | |
Результат |
public void SaveAsHTM_HasEmptyParagraphs_RetainsEmptyParagraphs() { var pattern = "<p></p><p></p><p>a</p><p></p><p>b</p><p/>"; var dom = new XmlDocument(); dom.LoadXml("<!DOCTYPE html><html><body>" + pattern + "</body></html>"); using (var temp = new TempFile()) { XmlHtmlConverter.SaveDOMAsHtml5(dom, temp.Path); var r = new Regex("<p"); var text = File.ReadAllText(temp.Path); var matches = r.Matches(text); Assert.AreEqual(6, matches.Count, text); //this one also exercises XmlHtmlConverter.GetXmlDomFromHtmlFile, so we're not really testing anymore AssertThatXmlIn.HtmlFile(temp.Path).HasSpecifiedNumberOfMatchesForXpath("//p", 6); } }
public void SaveDOMAsHtml5_DoesNotMessUpPaths() { var pattern = "<svg whatever='whatever'><path something='rubbish' /></svg>"; var dom = new XmlDocument(); dom.LoadXml("<!DOCTYPE html><html><body>" + pattern + "</body></html>"); using (var temp = new TempFile()) { XmlHtmlConverter.SaveDOMAsHtml5(dom, temp.Path); // This is a regression test guarding against a problem where something we were trying // to do to <p whatever /> that converted it to <p whatever ></p> was also converting // <path whatever /> to <path whatever></p> (note the non-matching closing tag!) // That causes the parser to throw on invalid XML, so the main point here is just that we ended up // with valid XML. The further test that the <path> element survived is a bonus. AssertThatXmlIn.HtmlFile(temp.Path).HasSpecifiedNumberOfMatchesForXpath("//path", 1); } }