예제 #1
0
        public void Service_Conta_Delete_DevePassar()
        {
            //Arrange
            var contaCmd = ContaObjectMother.GetContaValidaParaDeletar();
            var removido = true;

            _repositoryFake.Setup(pr => pr.Delete(contaCmd.Id)).Returns(removido);
            //Action
            var contaRemovido = _service.Delete(contaCmd);

            //Assert
            _repositoryFake.Verify(pr => pr.Delete(contaCmd.Id), Times.Once);
            contaRemovido.Should().BeTrue();
        }
예제 #2
0
 public IActionResult Delete(string id)
 {
     try
     {
         contaService.Delete(id);
         return(Ok());
     }
     catch (Exception ex)
     {
         logger.LogError(ex.Message);
         return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
     }
 }
예제 #3
0
        public IHttpActionResult Delete(ContaRemoveCommand conta)
        {
            TraceLogManager.Info("Deletando Conta!");
            TraceLogManager.Info("Validando dados da Conta!");
            var validator = conta.Validar();

            if (!validator.IsValid)
            {
                TraceLogManager.Error("Dado invalido: " + validator.Errors[0]);
                return(HandleValidationFailure(validator.Errors));
            }
            TraceLogManager.Info("Dados da conta válidos.");
            TraceLogManager.Info("Deletando conta");
            return(HandleCallback(() => _contaService.Delete(conta)));
        }
 public async Task <ActionResult> Delete(Guid id)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState)); // 400 bad request
         }
         return(Ok(await _service.Delete(id)));
     }
     catch (ArgumentException ex)
     {
         return(StatusCode((int)HttpStatusCode.InternalServerError, ex.Message));
     }
 }
예제 #5
0
        public async Task QuandoExecutarDelete()
        {
            _serviceMock = new Mock <IContaService>();
            _serviceMock.Setup(m => m.Delete(Id))
            .ReturnsAsync(true);
            _service = _serviceMock.Object;

            var deletado = await _service.Delete(Id);

            Assert.True(deletado);

            _serviceMock = new Mock <IContaService>();
            _serviceMock.Setup(m => m.Delete(It.IsAny <Guid>()))
            .ReturnsAsync(false);
            _service = _serviceMock.Object;

            deletado = await _service.Delete(Guid.NewGuid());

            Assert.False(deletado);
        }
예제 #6
0
 public void Delete(int Num_Conta)
 {
     _contaService.Delete(Num_Conta);
 }