public void TestJsonToObject() { string fl = Path.Combine(Environment.CurrentDirectory, "MockData", "internet1.json"); var obj = CrawlHelper.JsonToObject <PagesResponse>(fl); Assert.AreEqual(5, obj.Pages.Length); }
private List <ResultModel> doCrawl(string loc) { var obj = CrawlHelper.JsonToObject <PagesResponse>(loc); var rows = Crawler.ProcessCrawl(loc); return(rows); }
public void TestToPageModelList() { string fl = Path.Combine(Environment.CurrentDirectory, "MockData", "internet1.json"); var obj = CrawlHelper.JsonToObject <PagesResponse>(fl); var rows = (from m in obj.Pages select new PageModel { Address = m.Address, IsSeedURL = true }).ToList(); Assert.AreEqual(5, rows.Count()); }
public void TestPageModelLinksList() { string fl = Path.Combine(Environment.CurrentDirectory, "MockData", "internet1.json"); var obj = CrawlHelper.JsonToObject <PagesResponse>(fl); var rows = (from m in obj.Pages.SelectMany(x => x.Links.Select( s => new PageModel { Address = s, IsSeedURL = false }).ToList()) group m by m.Address into g select g.First()).ToList(); Assert.AreEqual(7, rows.Count()); }