public async Task <ActionResult> Delete(Guid id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); //400 bad request - solicitacao inválida } try { return(Ok(await _service.Delete(id))); } catch (ArgumentException e) { return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message)); } }
public async Task E_Possivel_Executar_Metodo_Delete() { _serviceMock = new Mock <ICepService>(); _serviceMock.Setup(m => m.Delete(IdCep)).ReturnsAsync(true); _service = _serviceMock.Object; var deletado = await _service.Delete(IdCep); Assert.True(deletado); _serviceMock = new Mock <ICepService>(); _serviceMock.Setup(m => m.Delete(It.IsAny <Guid>())).ReturnsAsync(false); _service = _serviceMock.Object; deletado = await _service.Delete(Guid.NewGuid()); Assert.False(deletado); }