public async Task <IActionResult> Get()
        {
            string sessionId = Guid.NewGuid().ToString();

            try
            {
                _logger.LogInformation("[{0}][INFO]Wappa.Api.Controllers.MotoristaController.Get"
                                       , sessionId);

                var result = await _service.GetAll();

                _logger.LogInformation("[{0}][INFO]Wappa.Api.Controllers.MotoristaController.Get {1}"
                                       , sessionId, JsonConvert.SerializeObject(result));

                return(Ok(result));
            }
            catch (Exception ex)
            {
                _logger.LogError("[{0}][ERROR]Wappa.Api.Controllers.MotoristaController.Get {1}"
                                 , sessionId, ex.Message);
                return(BadRequest(ex.Message));
            }
        }
Exemple #2
0
        public void Service_Deve_Salvar_Novo_Motorista()
        {
            var motorista = new Motorista
            {
                PrimeiroNome = "Ned",
                UltimoNome   = "Stark"
            };

            _service.Save(motorista);
            _repMotoristaMock.Verify(x => x.Save(It.IsAny <Motorista>()), Times.Once);
            var motoristas = _service.GetAll().Result;

            Assert.True(2 == motoristas.Count());
        }