public async Task GetNonExistentTypeByIdDoesNotLog() { tlkpType type = await _pokedexRepository.GetTypeById(-333); Assert.IsNull(type); _pokedexDBContextMock.Verify(m => m.tlkpType, Times.Once); }
/// <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); }
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"); }
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 }); }