コード例 #1
0
        public async Task GetNonExistentPokeballByIdDoesNotLog()
        {
            tlkpPokeball pokeball = await _pokedexRepository.GetPokeballById(-333);

            Assert.IsNull(pokeball);

            _pokedexDBContextMock.Verify(m => m.tlkpPokeball, Times.Once);
        }
コード例 #2
0
        /// <summary>
        /// Get the pokeball entity from a given pokeballId.
        /// </summary>
        /// <param name="pokeballId">the pokeballId to find</param>
        /// <returns>the found pokeball entity</returns>
        public async Task <tlkpPokeball> GetPokeballById(int pokeballId)
        {
            tlkpPokeball pokeball = await _context.tlkpPokeball.FindAsync(pokeballId);

            if (pokeball != null)
            {
                _logger.LogInformation(string.Format(InfoMessageWithId, Constants.Retrieved, Constants.Pokeball, Constants.From, pokeballId));
            }

            return(pokeball);
        }
コード例 #3
0
        public async Task <GenericLookupResult> GetPokeballById(int id)
        {
            tlkpPokeball pokeball = await _pokedexRepository.GetPokeballById(id);

            _logger.LogInformation(Constants.Mapping + " " + Constants.Pokeball + " " + Results + ".");

            return(pokeball == null ? null : new GenericLookupResult()
            {
                Id = pokeball.Id,
                Name = pokeball.Name
            });
        }
コード例 #4
0
        public async Task GetPokeballByIdIsSuccessfulAndLogsInformation()
        {
            tlkpPokeball pokeball = await _pokedexRepository.GetPokeballById(1);

            Assert.AreEqual(1, pokeball.Id);
            Assert.AreEqual("http://1.com", pokeball.ImageURL);
            Assert.AreEqual("Name1", pokeball.Name);

            _pokedexDBContextMock.Verify(m => m.tlkpPokeball, Times.Once);

            VerifyLoggerMockLogsInformation("Retrieved Pokéball from DBContext with Id: 1");
        }