public void ReturnTwoCinemas_GivenTwoDifferentInputLinks() { var parentDoc = new HtmlDocument(); var film = new HtmlNode(HtmlNodeType.Element, parentDoc, 3); film.Name = "a"; film.AddClass("customSelectorListItem"); film.Attributes.Add("data-film-list-item-cinema-item", "7733"); film.Attributes.Add("href", "/cinema/7733/film-info/leave-no-trace"); film.InnerHtml = "Aldgate"; var film2 = new HtmlNode(HtmlNodeType.Element, parentDoc, 3); film2.Name = "a"; film2.AddClass("customSelectorListItem"); film2.Attributes.Add("data-film-list-item-cinema-item", "237"); film2.Attributes.Add("href", "/cinema/237/film-info/leave-no-trace"); film2.InnerHtml = "Bloomsbury"; //<a href="/cinema/237/film-info/leave-no-trace" class="customSelectorListItem" data-film-list-item-cinema-item="237">Bloomsbury</a> var inputList = new List <HtmlNode> { film, film2 }; var sut = new sut.CinemaBuilder(); var result = sut.FromInitialLinks(inputList); Assert.Equal(2, result.Count()); }
public void ReturnOneCinemas_GivenTwoMatchingInputLinks() { var parentDoc = new HtmlDocument(); var film = new HtmlNode(HtmlNodeType.Element, parentDoc, 3); film.Name = "a"; film.AddClass("customSelectorListItem"); film.Attributes.Add("data-film-list-item-cinema-item", "7733"); film.Attributes.Add("href", "/cinema/7733/film-info/leave-no-trace"); film.InnerHtml = "Aldgate"; var film2 = new HtmlNode(HtmlNodeType.Element, parentDoc, 3); film2.Name = "a"; film2.AddClass("customSelectorListItem"); film2.Attributes.Add("data-film-list-item-cinema-item", "7733"); film2.Attributes.Add("href", "/cinema/7733/film-info/leave-no-trace"); film2.InnerHtml = "Aldgate"; var inputList = new List <HtmlNode> { film, film2 }; var sut = new sut.CinemaBuilder(); var result = sut.FromInitialLinks(inputList); Assert.Single(result); }
public IEnumerable <Cinema> GetCinemas() { var initialPage = _siteReader.GetInitialPage(); //parser gets links var initialLinks = _siteParser.GetAllCinemas(initialPage); var cinemaBuilder = new CinemaBuilder(); return(cinemaBuilder.FromInitialLinks(initialLinks)); }
public void ReturnEmptyList_GivenNullInput() { var sut = new sut.CinemaBuilder(); var result = sut.FromInitialLinks(null); Assert.NotNull(result); Assert.Empty(result); }