public async Task GetNonExistentCategoryByIdIsDoesNotLog() { tlkpCategory category = await _pokedexRepository.GetCategoryById(-33); Assert.IsNull(category); _pokedexDBContextMock.Verify(m => m.tlkpCategory, Times.Once); }
/// <summary> /// Get the category entity from a given categoryId. /// </summary> /// <param name="categoryId">categoryId to find</param> /// <returns>the found category entity</returns> public async Task <tlkpCategory> GetCategoryById(int categoryId) { tlkpCategory category = await _context.tlkpCategory.FindAsync(categoryId); if (category != null) { _logger.LogInformation(string.Format(InfoMessageWithId, Constants.Retrieved, Constants.Category, Constants.From, categoryId)); } return(category); }
public async Task GetCategoryByIdIsSuccessfulAndLogsInformation() { tlkpCategory category = await _pokedexRepository.GetCategoryById(3); Assert.AreEqual(3, category.Id); Assert.AreEqual("Name3", category.Name); _pokedexDBContextMock.Verify(m => m.tlkpCategory, Times.Once); VerifyLoggerMockLogsInformation("Retrieved Category from DBContext with Id: 3"); }
public async Task <GenericLookupResult> GetCategoryById(int id) { tlkpCategory category = await _pokedexRepository.GetCategoryById(id); _logger.LogInformation(Constants.Mapping + " " + Constants.Category + " " + Results + "."); return(category == null ? null : new GenericLookupResult() { Id = category.Id, Name = category.Name }); }
public override void Load_Header() { try { if (_CtyID > 0 && _CatID > 0) { //Setting Header property to be used in Header tlkpCategory cat = GoProGoDC.ProfileDC.GetCategoryByID(_CatID).SingleOrDefault <tlkpCategory>(); tblCity cit = GoProGoDC.GeoDC.GetCityByID(_CtyID).SingleOrDefault <tblCity>(); _Header = "Service providers in " + cat.Name + " from " + cit.City; //TODO: Set this as header //((ICommon)Master).SetHeader(Header, MyAccountType.None); } } catch (Exception ex) { //TODO: logging here } }