public void ShouldNotIndicateCheckupAlert()
        {
            // Arrange
            A.CallTo(() => _PokemonRespository.GetPokemon(A <int> .Ignored)).Returns(new Pokemon
            {
                NextCheckup = DateTime.Now.AddDays(29)
            });

            // Act (SUT)
            var PokemonService   = new PokemonService(_PokemonRespository);
            var PokemonViewModel = PokemonService.GetPokemon(1);

            // Assert
            Assert.IsFalse(PokemonViewModel.CheckupAlert);
        }
Exemple #2
0
        public async Task <ServiceResponse <GetPokemonDto> > Handle(PokemonDeleteCommand request, CancellationToken cancellationToken)
        {
            ServiceResponse <GetPokemonDto> serviceResponse = new ServiceResponse <GetPokemonDto>();

            try
            {
                var pokemonDto = await _pokemonRepository.GetPokemon(EnumPokemonSelectOptions.Number,
                                                                     request.Number.ToString());

                if (String.IsNullOrEmpty(pokemonDto.Name))
                {
                    throw new ArgumentException();
                }

                await _pokemonRepository.DeletePokemon(request.Number);

                serviceResponse.Message = $"Pokemon: {pokemonDto.Name}, has been removed.";
            }
            catch (Exception e)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "Sorry, we can't find any info about that pokemon.";
            }

            return(serviceResponse);
        }
Exemple #3
0
        public async Task <ActionResult <Pokemon> > GetPokemon(int id)
        {
            try
            {
                var result = await _pokemonRepository.GetPokemon(id);

                if (result == null)
                {
                    return(NotFound());
                }
                return(result);
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  "Error retrieving data from the database"));
            }
        }
        /// <summary>
        /// Returns Pokemon Description in Shakespears Style
        /// </summary>
        /// <param name="pokemonName">Pokemon to Search</param>
        /// <returns></returns>
        public async Task <string> GetPokemonDescription(string pokemonName)
        {
            if (string.IsNullOrEmpty(pokemonName))
            {
                throw new ArgumentException("Invalid input to read translation");
            }
            var pokemonDetails = await _pokemonRepository.GetPokemon(pokemonName);

            var pokemonDescription = await ReadPokemonDescription(pokemonDetails);

            if (!string.IsNullOrEmpty(pokemonDescription))
            {
                var translatedDescription = await _translatorRepository.ConvertToShakespear(pokemonDescription);

                return(ReadTranslatorText(translatedDescription));
            }
            return(string.Empty);
        }
        public async Task <ServiceResponse <GetPokemonDto> > Handle(PokemonGetByNumberCommand request, CancellationToken cancellationToken)
        {
            ServiceResponse <GetPokemonDto> serviceResponse = new ServiceResponse <GetPokemonDto>();

            var pokemonDto = await _pokemonRepository.GetPokemon(EnumPokemonSelectOptions.Number, request.Number.ToString());

            if (String.IsNullOrEmpty(pokemonDto.Name))
            {
                pokemonDto = await GetPokemonInfoApi(request.Number);
            }

            serviceResponse.Data = pokemonDto;

            if (pokemonDto == null)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "Sorry, we can't find any info about that pokemon.";
            }

            return(serviceResponse);
        }
Exemple #6
0
        public PokemonCharacter GetPokemon(string name)
        {
            var rawPokemon = _pokemonRepository.GetPokemon(name);

            if (rawPokemon == null)
            {
                throw new ApiException(System.Net.HttpStatusCode.NotFound, "No such Pokemon exists!");
            }
            var pokemonCharacteristic = _pokemonRepository.GetCharacteristic(rawPokemon.Id);

            if (pokemonCharacteristic == null)
            {
                throw new ApiException(System.Net.HttpStatusCode.NotFound, "No Pokemon description exists");
            }

            var englishDescription = pokemonCharacteristic.descriptions.FirstOrDefault(d => d.language.name == "en");

            if (englishDescription == null)
            {
                throw new ApiException(System.Net.HttpStatusCode.NotFound, "No English description exists for this Pokemon");
            }

            return(new PokemonCharacter(rawPokemon.Name, englishDescription.description));
        }
        public PokemonViewModel GetPokemon(int id)
        {
            var Pokemon = _repository.GetPokemon(id);

            return(MapToPokemonViewModel(Pokemon));
        }
Exemple #8
0
 public PokemonModel GetPokemon(int id)
 {
     return(_repo.GetPokemon(id));
 }
Exemple #9
0
 public async Task <Stream> GetPokemon(string pokemonName)
 {
     return(await _pokemonRepository.GetPokemon(pokemonName));
 }