public async Task GetHeroes() { var prismicService = new PrismicGenericService(new NullLogger <PrismicGenericService>(), _fixture.HttpClient, TestCacheFactory.BuildPrismicCacheProvider(), _fixture.Configuration); var prismicHeroService = new PrismicHeroService(prismicService, TestCacheFactory.BuildPrismicCacheProvider()); var result = await prismicHeroService.GetHeroes(); Assert.NotEmpty(result); Assert.Contains(result, x => x.Roles.Any(y => y.RoleCategory != null)); Assert.Contains(result, x => x.InGameCategories.Any()); }
public async Task UtiliseCacheWithHeroData() { var cache = new MemoryCache(new MemoryCacheOptions()); var cacheProvider = new CacheProvider(cache); var prismicCacheProvider = new PrismicCacheProvider(cacheProvider); var prismicService = new PrismicGenericService(new NullLogger <PrismicGenericService>(), _fixture.HttpClient, TestCacheFactory.BuildPrismicCacheProvider(), _fixture.Configuration); var prismicHeroService = new PrismicHeroService(prismicService, prismicCacheProvider); var timer = new Stopwatch(); timer.Start(); var result1 = await prismicHeroService.GetHeroes(); timer.Stop(); _outputHelper.WriteLine($"Time for first result: { timer.Elapsed }"); timer.Restart(); var result2 = await prismicHeroService.GetHeroes(); timer.Stop(); _outputHelper.WriteLine($"Time for second result: {timer.Elapsed}"); var roles = await prismicHeroService.GetRoles(); var roleCategories = await prismicHeroService.GetRoleCategories(); var universes = await prismicHeroService.GetUniverses(); var inGameCategories = await prismicHeroService.GetInGameCategories(); var firstHero = result1.FirstOrDefault(); Assert.Same(result1, result2); var category = firstHero?.InGameCategories?.FirstOrDefault(); Assert.NotNull(category); Assert.Same(category, inGameCategories.SingleOrDefault(x => x.Id == category.Id)); var role = firstHero?.Roles?.FirstOrDefault(); Assert.NotNull(role); Assert.Same(role, roles.SingleOrDefault(x => x.Id == role.Id)); var roleCategory = firstHero?.Roles?.FirstOrDefault()?.RoleCategory; Assert.NotNull(roleCategory); Assert.Same(roleCategory, roleCategories.SingleOrDefault(x => x.Id == roleCategory.Id)); var universe = firstHero?.Universe; Assert.NotNull(universe); Assert.Same(universe, universes.SingleOrDefault(x => x.Id == universe.Id)); var inGameCategory = firstHero?.InGameCategories?.FirstOrDefault(); Assert.NotNull(inGameCategory); Assert.Same(inGameCategory, inGameCategories.SingleOrDefault(x => x.Id == inGameCategory.Id)); }
public async Task GetPaginatedResult() { var prismicService = new PrismicGenericService(new NullLogger <PrismicGenericService>(), _fixture.HttpClient, TestCacheFactory.BuildPrismicCacheProvider(), _fixture.Configuration); var result = await prismicService.QueryApi <PrismicUniverse>("[[at(document.type, \"universe\")]]", 1); Assert.NotNull(result); Assert.NotEmpty(result); Assert.True((result?.Count ?? 0) > 1); }
public async Task GetApiRef() { var prismicService = new PrismicGenericService(new NullLogger <PrismicGenericService>(), _fixture.HttpClient, TestCacheFactory.BuildPrismicCacheProvider(), _fixture.Configuration); var result = await prismicService.GetMasterRef(); Assert.NotNull(result); }