public async Task ClearResourceCacheOfAllTypes() { // assemble Berry berry = new Berry { Name = "test", Id = 1 }; Machine machine = new Machine { Id = 1 }; PokeApiClient sut = CreateSut(); mockHttp.Expect("*machine*") .Respond("application/json", JsonConvert.SerializeObject(machine)); mockHttp.Expect("*berry*") .Respond("application/json", JsonConvert.SerializeObject(berry)); mockHttp.Expect("*machine*") .Respond("application/json", JsonConvert.SerializeObject(machine)); mockHttp.Expect("*berry*") .Respond("application/json", JsonConvert.SerializeObject(berry)); // act await sut.GetResourceAsync <Machine>(machine.Id); await sut.GetResourceAsync <Berry>(berry.Id); sut.ClearResourceCache(); await sut.GetResourceAsync <Machine>(machine.Id); await sut.GetResourceAsync <Berry>(berry.Id); // assert mockHttp.VerifyNoOutstandingExpectation(); }
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(); } }
public async Task ClearResourceCacheOfSpecificType() { // assemble Berry returnedBerry = new Berry { Id = 1 }; MockHttpMessageHandler mockHttp = new MockHttpMessageHandler(); mockHttp.Expect("*").Respond("application/json", JsonConvert.SerializeObject(returnedBerry)); PokeApiClient client = new PokeApiClient(mockHttp); Berry berry = await client.GetResourceAsync <Berry>(1); mockHttp.ResetExpectations(); // act client.ClearResourceCache <Berry>(); mockHttp.Expect("*").Respond("application/json", JsonConvert.SerializeObject(returnedBerry)); berry = await client.GetResourceAsync <Berry>(1); // assert mockHttp.VerifyNoOutstandingExpectation(); }