예제 #1
0
        public void TestJsonToObject()
        {
            string fl  = Path.Combine(Environment.CurrentDirectory, "MockData", "internet1.json");
            var    obj = CrawlHelper.JsonToObject <PagesResponse>(fl);

            Assert.AreEqual(5, obj.Pages.Length);
        }
예제 #2
0
        private List <ResultModel> doCrawl(string loc)
        {
            var obj  = CrawlHelper.JsonToObject <PagesResponse>(loc);
            var rows = Crawler.ProcessCrawl(loc);

            return(rows);
        }
예제 #3
0
        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());
        }
예제 #4
0
        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());
        }