public async Task Exclude_Test() { var scraper = new TrivialScraper(); var exclude = new ExcludeScraper(); var scrapeJob = new GameScrapeContext(new SeedContent[] {}, new IScraper[] { scraper, exclude }, new ICuller[] { }); Assert.True(await scrapeJob.Proceed(Enumerable.Empty <SeedContent>())); Assert.False(await scrapeJob.Proceed(new SeedContent[] { ("ExcludeTest", "Test") }));
public async Task Trivial_Test() { var scraper = new TrivialScraper(); var scrapeJob = new GameScrapeContext(new[] { scraper }, new ICuller[] { }); Assert.True(await scrapeJob.Proceed(Enumerable.Empty <SeedContent>())); Assert.NotEmpty(scrapeJob.Context.GetAllOfType("Test")); Assert.False(await scrapeJob.Proceed(Enumerable.Empty <SeedContent>())); }
public async Task <Guid> CreateGameScrapeContext(Guid gameGuid, IEnumerable <string> scraperNames, IEnumerable <string> cullerNames) { var scrapers = this.Scrapers.Where(s => scraperNames.Contains(s.Name, StringComparer.OrdinalIgnoreCase)); var cullers = this.Cullers.Where(s => cullerNames.Contains(s.Name, StringComparer.OrdinalIgnoreCase)); var game = this.GameLibrary.GetGame(gameGuid); var context = new GameScrapeContext(game, scrapers.ToList(), cullers.ToList()); return(await this.GameScrapeContextJobQueue.QueueJob(context)); }
public async Task TrivialAsync_Test() { var scraper = new TrivialScraper(); var scrapeJob = new GameScrapeContext(new[] { scraper }, new ICuller[] { }); await foreach (var s in scrapeJob) { Assert.NotEmpty(s); Assert.NotEmpty(s.Where(se => se.Content.Type == "Test")); } }
public async Task Group_Test() { var scraper = new GroupScraper(); var scrapeJob = new GameScrapeContext(new IScraper[] { scraper }, new ICuller[] { }); Assert.True(await scrapeJob.Proceed(Enumerable.Empty <SeedContent>())); Assert.False(await scrapeJob.Proceed(Enumerable.Empty <SeedContent>())); Assert.NotEmpty(scrapeJob.Context.GetAllOfType("MyGroup")); Assert.NotEmpty(scrapeJob.Context.GetAllOfType("Test")); Assert.NotEmpty(scrapeJob.Context.GetAllOfType("TestTwo")); Assert.Equal(scrapeJob.Context.GetAllOfType("MyGroup").First().Content.Value, scrapeJob.Context.GetAllOfType("Test").First().Content.Value); Assert.NotEmpty(scrapeJob.Context.GetChildren(scrapeJob.Context.GetAllOfType("MyGroup").First())); }
public async Task Dependent_Test() { var scraper = new TrivialScraper(); var dependent = new DependentScraper(); // we make dependent before scraper to allow scrapeJob to resolve // all items after 3 iterations. var scrapeJob = new GameScrapeContext(new IScraper[] { dependent, scraper }, new ICuller[] { }); Assert.True(await scrapeJob.Proceed(Enumerable.Empty <SeedContent>())); Assert.NotEmpty(scrapeJob.Context.GetAllOfType("Test")); Assert.True(await scrapeJob.Proceed(Enumerable.Empty <SeedContent>())); Assert.NotEmpty(scrapeJob.Context.GetAllOfType("TestDependent")); Assert.False(await scrapeJob.Proceed(Enumerable.Empty <SeedContent>())); }