コード例 #1
0
        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") }));
コード例 #2
0
        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>()));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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"));
            }
        }
コード例 #5
0
        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()));
        }
コード例 #6
0
        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>()));
        }