public void FavoritedCountForColourId_Success() { // Arrange var colourId = 1; IQueryable <Person> testData = GetTestData(); _mockedPersonRepository.Setup(x => x.GetAll()).Returns(testData); // Act var result = _personDetailsService.FavoritedCountForColourId(colourId); // Assert Assert.AreEqual(2, result); }
public IActionResult Get() { try { _logger.LogDebug("Getting all Colours from service."); var entities = _colourService.GetColours(); var models = _mapper.Map <IEnumerable <Colour> >(entities).ToList(); // Add Favorited times data models.ForEach(colour => colour.Favorited = _personDetailsService.FavoritedCountForColourId(colour.ColourId)); _logger.LogInformation($"Returning total of {models.Count()} mapped models to caller."); return(Ok(models)); } catch (Exception ex) { _logger.LogError($"Exception occurred in ColoursController.Get: {ex}"); return(StatusCode(500, ex.ToString())); } }