public void Service_Deve_Excluir_Motorista() { int motoristaId = 1; _service.Delete(motoristaId); _repMotoristaMock.Verify(x => x.Delete(It.IsAny <int>()), Times.Once); var motoristas = _service.GetAll().Result; Assert.True(0 == motoristas.Count()); }
public IActionResult Delete(int id) { var motorista = _motoristaService.Obter(id); if (motorista == null) { return(StatusCode(404, "Motorista não encontrado")); } _motoristaService.Delete(id); return(Ok("deleted")); }
public async Task <IActionResult> Delete(int id) { string sessionId = Guid.NewGuid().ToString(); try { _logger.LogInformation("[{0}][INFO]Wappa.Api.Controllers.MotoristaController.Delete({1})" , sessionId, id); var result = await _service.Delete(id); _logger.LogInformation("[{0}][INFO]Wappa.Api.Controllers.MotoristaController.Delete({1}) {2}" , sessionId, id, JsonConvert.SerializeObject(result)); return(NoContent()); } catch (Exception ex) { _logger.LogError("[{0}][ERROR]Wappa.Api.Controllers.MotoristaController.Delete({1}) {2}" , sessionId, id, ex.Message); return(BadRequest(ex.Message)); } }