public void GivenInValidLink_WhenIsValidLinkExecuted_ShouldReturnFalse() { //Arrange var scrapper = new MockHtmlScrapper(); var htmlLinkHandler = new HtmlLinkHandler(scrapper) { }; //Act var validlink = "/unknown/thisisatest"; var result = htmlLinkHandler.IsValidLink(validlink); //Assert Assert.False(result); }
private void AddUrlsToQueue(string webcontent) { MatchCollection matchs = Regex.Matches(webcontent, @"(<a.*?>.*?</a>)", RegexOptions.Singleline); foreach (var m in matchs) { string value = ((Match)m).Groups[1].Value; Match matchHrefAttribute = Regex.Match(value, @"href=\""(.*?)\""", RegexOptions.Singleline); if (matchHrefAttribute.Success) { string href = _htmlLinkHandler.CleanQueryStringUrl(matchHrefAttribute.Groups[1].Value); if (_htmlLinkHandler.IsValidLink(href)) { if (_links.Add(href)) { queue.Enqueue(href); } } } } }