public void ReturnEmptyList_WhenPageContainsNoLinks() { var parser = new sut.SiteParser(); var parentDoc = new HtmlDocument(); var result = parser.GetAllCinemas(parentDoc); Assert.Empty(result); }
public void ReturnsSingleLink_WhenGivenSingleLink() { var input = new List <string> { "/cinema/246/film-info/isle-of-dogs" }; var parser = new sut.SiteParser(); var result = parser.FilterLinks(input); Assert.Single(result); }
public void ReturnsCompleteLink_WhenGivenSingleLink() { var input = new List <string> { "/cinema/246/film-info/isle-of-dogs" }; var parser = new sut.SiteParser(); var result = parser.FilterLinks(input); Assert.Equal("/cinema/246/film-info/isle-of-dogs", result.ElementAt(0)); }
public void ReturnsCompleteLink_WhenGivenOneCorrectOneIgnoreLink() { var input = new List <string> { "/cinema/246/film-info/isle-of-dogs", "https://www.curzonartificialeye.com/" }; var parser = new sut.SiteParser(); var result = parser.FilterLinks(input); Assert.Equal("/cinema/246/film-info/isle-of-dogs", result.ElementAt(0)); }
public void ReturnCinemaLink_WhenPageContainsOneLink() { var parser = new sut.SiteParser(); var parentDoc = new HtmlDocument(); var filmLink = new HtmlNode(HtmlNodeType.Text, parentDoc, 0); filmLink.InnerHtml = @"<a href=""/cinema/7733/film-info//leave-no-trace"" class=""customSelectorListItem"" data-film-list-item-cinema-item=""7733"">Aldgate</a>"; parentDoc.DocumentNode.AppendChild(filmLink); var result = parser.GetAllCinemas(parentDoc); Assert.Single(result); }
public void ReturnsEmptyList_WhenPageHasNoLinks() { var parser = new sut.SiteParser(); var parentDoc = new HtmlDocument(); var filmLink = new HtmlNode(HtmlNodeType.Text, parentDoc, 0); filmLink.InnerHtml = @"<div>Something Else</div>"; parentDoc.DocumentNode.AppendChild(filmLink); var result = parser.GetInitialLinks(parentDoc); Assert.Empty(result); }
public void ReturnsTwoLinks_WhenPageHasTwoCinemasWithTwoFilms() { var parser = new sut.SiteParser(); var parentDoc = new HtmlDocument(); var filmLink = new HtmlNode(HtmlNodeType.Text, parentDoc, 0); filmLink.InnerHtml = @"<a href=""/cinema/123/film-info/film-title"">Link</a> <a href=""/cinema/456/film-info/different-film-title"">Link</a>"; parentDoc.DocumentNode.AppendChild(filmLink); var result = parser.GetInitialLinks(parentDoc); Assert.Equal(2, result.Count()); }
public void ReturnLink_WhenPageHasOneCinemaAndPageLink() { var parser = new sut.SiteParser(); var parentDoc = new HtmlDocument(); var filmLink = new HtmlNode(HtmlNodeType.Text, parentDoc, 0); filmLink.InnerHtml = @"<a href=""/cinema/123/film-info/film-title"">Link</a>"; parentDoc.DocumentNode.AppendChild(filmLink); var result = parser.GetInitialLinks(parentDoc); Assert.Single(result); }
public void ReturnDecodedString_WhenTitleHasEncodedCharacter() { var parser = new sut.SiteParser(); var parentDoc = new HtmlDocument(); var titleElement = new HtmlNode(HtmlNodeType.Text, parentDoc, 0); titleElement.InnerHtml = @"<h1 class=""h2 filmPageTitle"">L'Amant Double</h1>"; parentDoc.DocumentNode.AppendChild(titleElement); var result = parser.GetFilmTitle(parentDoc); Assert.Equal("L'Amant Double", result); }
public void ReturnEmptyString_WhenPageDoesNotHaveTitle() { var parser = new sut.SiteParser(); var parentDoc = new HtmlDocument(); var titleElement = new HtmlNode(HtmlNodeType.Text, parentDoc, 0); titleElement.InnerHtml = @"<h1 class=""h2 not a title"">Blah</h1>"; parentDoc.DocumentNode.AppendChild(titleElement); var result = parser.GetFilmTitle(parentDoc); Assert.Equal("", result); }
public void ReturnTitle_WhenPageContainsIt() { var parser = new sut.SiteParser(); var parentDoc = new HtmlDocument(); var titleElement = new HtmlNode(HtmlNodeType.Text, parentDoc, 0); titleElement.InnerHtml = @"<h1 class=""h2 filmPageTitle"">Ghost Stories</h1>"; parentDoc.DocumentNode.AppendChild(titleElement); var result = parser.GetFilmTitle(parentDoc); Assert.Equal("Ghost Stories", result); }
public void ReturnEmptyString_WhenPageDoesNotHaveCinemaNameAttribute() { var parser = new sut.SiteParser(); var parentDoc = new HtmlDocument(); var body = new HtmlNode(HtmlNodeType.Element, parentDoc, 0); body.Name = "body"; body.Attributes.Add("data-cinema-name", ""); parentDoc.DocumentNode.AppendChild(body); var result = parser.GetCinemaName(parentDoc); Assert.Equal("", result); }
public void ReturnTwoCinemaLinks_WhenPageContainsTwoLinks() { var parser = new sut.SiteParser(); var parentDoc = new HtmlDocument(); var filmLink = new HtmlNode(HtmlNodeType.Text, parentDoc, 0); filmLink.InnerHtml = @"<a href=""/cinema/7733/film-info//leave-no-trace"" class=""customSelectorListItem"" data-film-list-item-cinema-item=""7733"">Aldgate</a>"; parentDoc.DocumentNode.AppendChild(filmLink); var secondLink = new HtmlNode(HtmlNodeType.Text, parentDoc, 0); secondLink.InnerHtml = @"<a href=""/cinema/237/film-info/leave-no-trace"" class=""customSelectorListItem"" data-film-list-item-cinema-item=""237"">Bloomsbury</a>"; parentDoc.DocumentNode.AppendChild(secondLink); var result = parser.GetAllCinemas(parentDoc); Assert.Equal(2, result.Count()); }