public void OpenGraphDescription() { IDocument doc = CreateDocument(@"<!doctype html> <html> <head> <title>A B C</title> <meta name=""Description"" content=""D E F""> <!-- InstanceBeginEditable name=""head"" --> <!-- InstanceEndEditable --> </head> <body> <main> <article> <header> <h1><!-- InstanceBeginEditable name=""TitleDerived"" -->Title goes here<!-- InstanceEndEditable --></h1> <p><!-- InstanceBeginEditable name=""SubtitleDerived"" -->Subtitle goes here<!-- InstanceEndEditable --></p> </header> <article> <main> </body> </html>"); var pageFixer = new PageFixer(doc); pageFixer.fixDescription(); doc.QuerySelector("head meta[property = 'og:description']").Attributes["content"].Value.Should().Be("D E F"); doc.QuerySelector("header p").TextContent.Should().Be("D E F"); }
public void HeaderTitle() { IDocument doc = CreateDocument(@"<!doctype html> <html> <head> <title>A B C</title> <!-- InstanceBeginEditable name=""head"" --> <!-- InstanceEndEditable --> </head> <body> <main> <article> <header> <h1><!-- InstanceBeginEditable name=""TitleDerived"" -->Title goes here<!-- InstanceEndEditable --></h1> </header> <article> <main> </body> </html>"); var pageFixer = new PageFixer(doc); pageFixer.fixTitle(); doc.QuerySelector("h1").TextContent.Should().Be("A B C"); }
public void FigureImageAlternateText() { IDocument doc = CreateDocument(@"<!doctype html> <html> <head> </head> <body> <main> <article> <section> <figure> <img src=""a/b.jpg"" /> <figcaption>X Y Z</figcaption> </figure> </section> <article> <main> </body> </html>"); var pageFixer = new PageFixer(doc); pageFixer.fixImageAlternateText(); doc.QuerySelector <IHtmlImageElement>("img").AlternativeText.Should().Be("X Y Z"); }
public void OpenGraphTitle() { IDocument doc = CreateDocument(@"<!doctype html> <html> <head> <title>A B C</title> <!-- InstanceBeginEditable name=""head"" --> <!-- InstanceEndEditable --> </head> <body> <main> <article> <header> <h1><!-- InstanceBeginEditable name=""TitleDerived"" -->Title goes here<!-- InstanceEndEditable --></h1> </header> <article> <main> </body> </html>"); var pageFixer = new PageFixer(doc); pageFixer.fixTitle(); doc.QuerySelector("head meta[property = 'og:title']").Attributes["content"].Value.Should().Be("A B C"); }
public void ImageSources() { IDocument doc = CreateDocument(@"<!doctype html> <html> <head> </head> <body> <main> <article> <section> <img src=""a/b.jpg"" id=""relativeImg"" /> <img src=""https://a.b.com/d/e.jpg"" id=""absoluteImg"" /> </section> <article> <main> </body> </html>"); var pageFixer = new PageFixer(doc); pageFixer.fixImageSources(); doc.QuerySelector("#relativeImg").GetAttribute("src").Should() .Be("https://west.aldaviva.com/exhibits/images/a/b.jpg"); doc.QuerySelector("#absoluteImg").GetAttribute("src").Should() .Be("https://a.b.com/d/e.jpg"); }
public void ArticleTime() { var fakeNow = new DateTime(2019, 7, 24, 2, 20, 56, DateTimeKind.Local); IDocument doc = CreateDocument(@"<!doctype html> <html> <head> </head> <body> <main> <article> <time></time> <article> <main> </body> </html>"); var pageFixer = new PageFixer(doc) { currentTimeProvider = () => fakeNow }; pageFixer.fixTime(); const string expectedIsoTimestamp = "2019-07-24T02:20:56.0000000-07:00"; doc.QuerySelector("article > time").Attributes["datetime"].Value.Should().Be(expectedIsoTimestamp); doc.QuerySelector("article > time").Attributes["title"].Value.Should().Be(expectedIsoTimestamp); doc.QuerySelector("article > time").TextContent.Should().Be("Wednesday, July 24, 2019"); }