コード例 #1
0
            public void Given_FunctionalTag_Should_Return_EmptyString(string tagName)
            {
                //Arrange
                string html    = $"<{tagName}>it doesn't matter what you put here</{tagName}>";
                var    service = new HtmlParserService();

                //Act
                var result = service.GetVisibleText(html);

                //Assert
                Assert.Equal(string.Empty, result);
            }
コード例 #2
0
            public void Given_MultipleWhitespacesBetweenWords_Should_Return_SingleWhitespaceBetweenWords()
            {
                //Arrange
                string multipleWhitepaces = "french   croissant";
                string singleWhitespace   = "french croissant";
                var    service            = new HtmlParserService();

                //Act
                var result = service.GetVisibleText(multipleWhitepaces);

                //Assert
                Assert.Equal(singleWhitespace, result);
            }
コード例 #3
0
            public void Given_SimpleTag_Should_Return_VisibleText()
            {
                //Arrange
                string visibleText = "The Story";
                string html        = $"<h1>{visibleText}<h1>";
                var    service     = new HtmlParserService();

                //Act
                var result = service.GetVisibleText(html);

                //Assert
                Assert.Equal(visibleText, result);
            }
コード例 #4
0
            public void Given_MultilineHtml_Should_Return_OnelineVisibleText()
            {
                //Arrange
                string visibleText        = "The Story\nbegins long ago\nin a faraway kingdom";
                string onelineVisibleText = "The Story begins long ago in a faraway kingdom";
                string html    = $"<h1>{visibleText}<h1>";
                var    service = new HtmlParserService();

                //Act
                var result = service.GetVisibleText(html);

                //Assert
                Assert.Equal(onelineVisibleText, result);
            }
コード例 #5
0
            public void Given_SimpleTag_With_HtmlEntities_Should_Return_EncodedVisibleText()
            {
                //Arrange
                string encodedVisibleText = "&#165;1234";
                string decodedVisibleText = "¥1234";
                string html    = $"<h1>{encodedVisibleText}<h1>";
                var    service = new HtmlParserService();

                //Act
                var result = service.GetVisibleText(html);

                //Assert
                Assert.Equal(decodedVisibleText, result);
            }