Esempio n. 1
0
        public void Clean_SimpleTag_TagDeleted()
        {
            const string html = "<p>Text in html</p>";

            var cleanedText = HtmlCleaner.Clean(html);

            Assert.Equal("Text in html", cleanedText);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
 private static string MarkdownFormatContent(string text)
 {
     return(HtmlCleaner.Clean(CommonMarkConverter.Convert(BbCodeFormatComment(text))));
 }
Esempio n. 13
0
        public void CleanTestNullUrlExc()
        {
            var cleaner = new HtmlCleaner(Enumerable.Empty <ISiteHtmlCleaner>());

            cleaner.Clean(null, string.Empty);
        }