Exemplo n.º 1
0
        public async void LoadPokemonInfo()
        {
            PokemonSpecies pokemonNameLang = await pokeClient.GetResourceAsync <PokemonSpecies>(SelectedPokemon.Id);

            Pokemon pokemonInfo = await pokeClient.GetResourceAsync <Pokemon>(SelectedPokemon.PokeNameOriginal);

            // Banner on top: Name of Pokemon in selected language
            for (int i = 0; i < pokemonNameLang.Names.Count; i++)
            {
                if (pokemonNameLang.Names[i].Language.Name == _language)
                {
                    PokemonName = pokemonNameLang.Names[i].Name;
                }
            }

            //await LoadPokemonImage(pokemonInfo);
            await LoadPokemonImage(pokemonInfo);

            LoadPokemonType(pokemonInfo);

            LoadPokemonStatLanguage(pokemonInfo);

            LoadPokemonAbility(pokemonInfo);

            NotifyOfPropertyChange(() => PokemonName);

            if (SelectedPokemon != null)
            {
                pokeClient.ClearResourceCache();
                pokeClient.ClearCache();
            }
        }
Exemplo n.º 2
0
        public async Task ClearCacheWipesAllCachedData()
        {
            // assemble
            PokeApiClient sut   = CreateSut();
            Berry         berry = new Berry {
                Name = "test", Id = 1
            };

            mockHttp.Expect($"*berry/{berry.Id}*")
            .Respond("application/json", JsonConvert.SerializeObject(CreateFakeNamedResourceList <Berry>()));
            mockHttp.Expect("*berry")
            .Respond("application/json", JsonConvert.SerializeObject(CreateFakeNamedResourceList <Berry>()));
            mockHttp.Expect($"*berry/{berry.Id}*")
            .Respond("application/json", JsonConvert.SerializeObject(CreateFakeNamedResourceList <Berry>()));
            mockHttp.Expect("*berry")
            .Respond("application/json", JsonConvert.SerializeObject(CreateFakeNamedResourceList <Berry>()));

            // act
            await sut.GetResourceAsync <Berry>(berry.Id);

            await sut.GetNamedResourcePageAsync <Berry>();

            sut.ClearCache();
            await sut.GetResourceAsync <Berry>(berry.Id);

            await sut.GetNamedResourcePageAsync <Berry>();

            // assert
            mockHttp.VerifyNoOutstandingExpectation();
        }
 public void ClearCache()
 {
     pokeApiClient?.ClearCache();
 }