Example #1
0
        public async Task GetNonExistentTypeByIdDoesNotLog()
        {
            tlkpType type = await _pokedexRepository.GetTypeById(-333);

            Assert.IsNull(type);

            _pokedexDBContextMock.Verify(m => m.tlkpType, Times.Once);
        }
Example #2
0
        /// <summary>
        /// Get the type entity from a given typeId.
        /// </summary>
        /// <param name="typeId">the typeId to find</param>
        /// <returns>the found type entity</returns>
        public async Task <tlkpType> GetTypeById(int typeId)
        {
            tlkpType type = await _context.tlkpType.FindAsync(typeId);

            if (type != null)
            {
                _logger.LogInformation(string.Format(InfoMessageWithId, Constants.Retrieved, Constants.Type, Constants.From, typeId));
            }

            return(type);
        }
Example #3
0
        public async Task GetTypeByIdIsSuccessfulAndLogsInformation()
        {
            tlkpType type = await _pokedexRepository.GetTypeById(1);

            Assert.AreEqual(1, type.Id);
            Assert.AreEqual("Name1", type.Name);

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

            VerifyLoggerMockLogsInformation("Retrieved Type from DBContext with Id: 1");
        }
Example #4
0
        public async Task <GenericLookupResult> GetTypeById(int id)
        {
            tlkpType type = await _pokedexRepository.GetTypeById(id);

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

            return(type == null ? null : new GenericLookupResult()
            {
                Id = type.Id,
                Name = type.Name
            });
        }