コード例 #1
0
        public void BaseUrls_DoesNotBaseEmailAddress()
        {
            // Arrange
            var parser = new HtmlAgilityPackParser(Uri);

            // Act
            var result = parser.BaseUrls("<a href=\"mailto:" + ObjectMother.TestAddress + "\">email address</a>");

            //Assert
            Assert.That(result, Is.Not.StringContaining(Uri.Host));
        }
コード例 #2
0
        public void BaseUrls_DoesBaseRelativeUrls()
        {
            // Arrange
            var parser = new HtmlAgilityPackParser(Uri);

            // Act
            var result = parser.BaseUrls("<a href=\"/test.html\"><img src=\"/image.jpg\" /></a>");

            //Assert
            Assert.That(result, Is.StringContaining(Uri.Host + "/test.html"));
            Assert.That(result, Is.StringContaining(Uri.Host + "/image.jpg"));
        }
コード例 #3
0
        public void StripHtml_DoesRemoveAllHtml()
        {
            // Arrange
            var parser = new HtmlAgilityPackParser(Uri);

            // Act
            var result = parser.StripHtml("<html><head><style>.css { padding: 10px; }</style></head><body><h1>Heading</h1><div class=\"css\">This is a test.</div>With an image.<img src=\"image.jpg\" alt=\"image\" /></body></html>");

            //Assert
            Assert.That(result, Is.EqualTo("Heading\r\nThis is a test.\r\nWith an image."));
        }