public void Clean_SimpleTag_TagDeleted() { const string html = "<p>Text in html</p>"; var cleanedText = HtmlCleaner.Clean(html); Assert.Equal("Text in html", cleanedText); }
public void Clean_UnorderedList_TextFormatted() { const string html = "<ul><li>Coffee</li><li>Tea</li><li>Milk</li></ul>"; var cleanedText = HtmlCleaner.Clean(html); Assert.Equal("Coffee" + Environment.NewLine + "Tea" + Environment.NewLine + "Milk", cleanedText); }
public void Clean_TextWithDuplivatedSpaces_SpacesTrimmed() { const string html = "<div> Text with many spaces </div>"; var cleanedText = HtmlCleaner.Clean(html); Assert.Equal("Text with many spaces", cleanedText); }
public void Clean_WhenThereAreWhitespaceBetweenTags_SpacesAreRemoved() { string inputString = "<html> <head> </head> </html>"; var cleaner = new HtmlCleaner(); string outputString = cleaner.Clean(inputString); Assert.AreEqual("<html><head></head></html>", outputString); }
public void Clean_InnerTag_TagDeleted() { const string html = "<div>Text before<p>Text in</p>Text after</div>"; var cleanedText = HtmlCleaner.Clean(html); Assert.Equal("Text before" + Environment.NewLine + "Text in" + Environment.NewLine + "Text after", cleanedText); }
public void CleanTestDefaultCleaner() { var cleaner = new HtmlCleaner(Enumerable.Empty <ISiteHtmlCleaner>()); IArticle cleaned = cleaner.Clean("url", @"<body>Some text</body>"); Assert.AreEqual("Some text", cleaned.Text); }
public void Clean_WhenRowEndWithMultipleSpaces_SpacesAreRemoved() { string inputString = "<html> \r\n \r\n<head> \r\n</head>\r\n </html>"; var cleaner = new HtmlCleaner(); string outputString = cleaner.Clean(inputString); Assert.AreEqual("<html>\r\n<head>\r\n</head>\r\n </html>", outputString); }
public void Clean_WhenCalledWithHtmlWithOneComment_CommentIsRemoved() { string inputString = "<html><head><!-- kommentar --></head></html>"; var cleaner = new HtmlCleaner(); string outputString = cleaner.Clean(inputString); Assert.AreEqual("<html><head></head></html>", outputString); }
public void Clean_WhenCalledWithHtmlWithMultiLineBreaks_ReplacedBySingleLineBreaks() { string inputString = "<html>\r\n<head>\r\n\r\n</head>\r\n\r\n\r\n</html>"; var cleaner = new HtmlCleaner(); string outputString = cleaner.Clean(inputString); Assert.AreEqual("<html>\r\n<head>\r\n</head>\r\n</html>", outputString); }
public void Clean_WhenCalledWithHtmlIfBlocks_CommentIsNotRemoved() { string inputString = "<html><head><!--[if lt IE 9]><link rel=\"stylesheet\" href=\"explorer.css\" type=\"text/css\" /><![endif]--></head></html>"; var cleaner = new HtmlCleaner(); string outputString = cleaner.Clean(inputString); Assert.AreEqual(inputString, outputString); }
public void CleanTest() { var siteCleaner = MockRepository.GenerateStub <ISiteHtmlCleaner>(); siteCleaner.Stub(sc => sc.SiteUrl) .Return("url"); var mockArticle = MockRepository.GenerateStub <IArticle>(); mockArticle.Stub(a => a.Text) .Return("!"); siteCleaner.Stub(sc => sc.Clean(Arg <string> .Is.Anything)) .Return(mockArticle); var cleaner = new HtmlCleaner(new[] { siteCleaner }); IArticle cleaned = cleaner.Clean("url", string.Empty); Assert.AreEqual("!", cleaned.Text); }
private static string MarkdownFormatContent(string text) { return(HtmlCleaner.Clean(CommonMarkConverter.Convert(BbCodeFormatComment(text)))); }
public void CleanTestNullUrlExc() { var cleaner = new HtmlCleaner(Enumerable.Empty <ISiteHtmlCleaner>()); cleaner.Clean(null, string.Empty); }