public void Scrape_Normal()
        {
            var url = "https://www.quirky.com/invent/244110/design";
            var scraper = new ContributorsScraper(url);
            var results = scraper.Scrape();

            Assert.IsNotNull(results);
            Assert.IsInstanceOfType(results, typeof(List<IContribution>));

            var list = results as List<IContribution>;
            Assert.IsTrue(list.Count == 5);
            Assert.AreEqual(list[0].Contributor, "Andrew Erlick");
            Assert.AreEqual(list[1].Contributor, "Andrew Erlick");
            Assert.AreEqual(list[2].Contributor, "Andrew Erlick");
            Assert.AreEqual(list[3].Contributor, "Andrew Erlick");
            Assert.AreEqual(list[4].Contributor, "Andrew Erlick");
            Assert.IsTrue(list[0].Selected);
        }
Пример #2
0
 private List<ICategory> FillParticipantsInCategories(List<ICategory> projectCategories)
 {
     List<ICategory> categories = new List<ICategory>();
     foreach (var category in projectCategories.OrderBy(x => x.ContributionNum))
     {
         if (category.ContributionNum > 0)
         {
             try
             {
                 IScraper contScraper = new ContributorsScraper(category.URL);
                 var results = contScraper.Scrape();
                 category.AddContributions(results.Cast<IContribution>().ToArray());
             }
             catch (Exception e)
             {
                 Console.WriteLine("Failed. Exception {0}", e);
                 throw e;
             }
         }
         Helper.AppendToFile(category, ParticipantScraper.FILE_PATH);
         categories.Add(category);
     }
     return categories;
 }