public async Task <ActionResult> GetAsync(string pokemonName) { try { _logger.LogInformation("Pokemon Info started on - " + pokemonName); var description = await _pokeProvider.GetDescriptionAsync(pokemonName); var translation = await _sheakspeareTranslator.GetTranslationAsync(description); var pokeDescription = new PokemonDescription() { description = translation, name = pokemonName }; return(Ok(pokeDescription)); } catch (RequestException re) { if (re.statusCode == HttpStatusCode.NotFound) { return(NotFound(re.Message)); } else { return(BadRequest(re.Message)); } } }
public async Task PokemonExpectOkObjectResultWithObjectFromService() { var expectedPokemonDescription = new PokemonDescription(); const string expectedPokemonName = "expectedPokemonName"; _mockPokemonDescriptionService.Setup(service => service.ShakespearenStyleDescription(expectedPokemonName)) .Returns(Task.FromResult(expectedPokemonDescription)); var actionResult = await _pokemonController.Pokemon(expectedPokemonName); Assert.IsType <OkObjectResult>(actionResult); var okObjectResult = (OkObjectResult)actionResult; Assert.Equal(expectedPokemonDescription, okObjectResult.Value); }
private async void LoadPokemonFlavorText() { PokemonSpecies flavorText = await pokeClient.GetResourceAsync <PokemonSpecies>(SelectedPokemon.Id); try { for (int i = 0; i < flavorText.FlavorTextEntries.Count; i++) { if (flavorText.FlavorTextEntries[i].Language.Name == _language) { PokemonDescription = flavorText.FlavorTextEntries[i].FlavorText; PokemonDescription = String.Join("", PokemonDescription.Where(c => c != '\n' && c != '\r' && c != '\t')); break; } } } catch { // } NotifyOfPropertyChange(() => PokemonDescription); }