public void Google_ProcessHtml_ExtractPageRank_ExcludeGoogle_Success_Multiple() { string html = @" <div> <a href=""/url?q=https://www.sympli.com.au"">Some Link 2</a> <a href=""/url?q=https://trinitylaw.com.au/100-econveyancing-in-nsw-electronic-settlements/"">Some Link 3</a> <a href=""/url?q=http://nationalconveyancingsolutions.com.au/e-settlements.html"">Some Link 4</a> <a href=""/url?q=http://www.google.com.au"">Some Link 5</a> <a href=""/url?q=https://photos.google.com/"">Some Link 6</a> </div> "; List <PageRank> expected = new List <PageRank> { new PageRank { Rank = 1, Url = "https://www.sympli.com.au" }, new PageRank { Rank = 2, Url = "https://trinitylaw.com.au/100-econveyancing-in-nsw-electronic-settlements/" }, new PageRank { Rank = 3, Url = "http://nationalconveyancingsolutions.com.au/e-settlements.html" } }; IHtmlRankingAnalyser analyser = new GoogleHtmlRankingAnalyser(); List <PageRank> actual = analyser.ProcessHtml(html); CollectionAssert.AreEqual(expected, actual, new PageRankComparer()); }
public async Task Google_ProcessHtml_ExtractPageRank_FormatVerify_Success() { string targetUrl = "https://www.google.com.au/search?q=e-settlements"; HttpClient client = new HttpClient(); HttpRequestMessage fetchRequest = new HttpRequestMessage(HttpMethod.Get, targetUrl); HttpResponseMessage response = await client.SendAsync(fetchRequest); string htmlContent = await response.Content.ReadAsStringAsync(); IHtmlRankingAnalyser analyser = new GoogleHtmlRankingAnalyser(); List <PageRank> actual = analyser.ProcessHtml(htmlContent); //ensure there are results Assert.IsTrue(actual.Count > 0, "No resulting PageRank could be found"); }
public void Google_ProcessHtml_ExtractPageRank_Success_Single() { string html = @" <div> <a href=""/url?q=https://www.sympli.com.au"">Some Link 1</a> </div> "; List <PageRank> expected = new List <PageRank> { new PageRank { Rank = 1, Url = "https://www.sympli.com.au" } }; IHtmlRankingAnalyser analyser = new GoogleHtmlRankingAnalyser(); List <PageRank> actual = analyser.ProcessHtml(html); CollectionAssert.AreEqual(expected, actual, new PageRankComparer()); }