Ejemplo n.º 1
0
        public void GetAllPersonDetials_Success()
        {
            // Arrange
            IQueryable <Person> testData = GetTestData();

            _mockedPersonRepository.Setup(x => x.GetAll()).Returns(testData);

            // Act
            var result = _personDetailsService.GetAllPersonDetials().ToList();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(4, result.Count);
            Assert.AreEqual("AAA", result[0].FirstName);
            Assert.AreEqual(1, result[0].PersonColours.FirstOrDefault().ColourId);
        }
        public IActionResult Get()
        {
            try
            {
                _logger.LogDebug("Getting all People data from service.");

                var entities = _personDetailsService.GetAllPersonDetials();
                var models   = _mapper.Map <IEnumerable <Person> >(entities);

                _logger.LogInformation($"Returning total of {models.Count()} mapped models to caller.");
                return(Ok(models));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Exception occurred in PersonDetailsController.Get: {ex}");
                return(StatusCode(500, ex.ToString()));
            }
        }