public void DadoUmaContainvalida_IsInvalid() { var command = new CreateContaCommand(""); command.Validate(); Assert.AreEqual(command.Invalid, true); }
public void DadoUmaContaValida_IsValid() { var command = new CreateContaCommand("123456"); command.Validate(); Assert.AreEqual(command.Valid, true); }
public void DadoUmaContaVazia_IsInvalid() { var command = new CreateContaCommand(""); var handler = new CreateContaHandler(new FakeRepositoryConta()); var result = handler.Handle(command).Result; Assert.AreNotEqual(0, result.Notifications.Count); Assert.AreEqual(true, result.Invalid); }
public async Task <IActionResult> CreateConta([FromBody] CreateContaCommand command) { var result = await _createContaHandler.Handle(command); if (result.Notifications.Any()) { return(BadRequest(result.Notifications)); } return(Ok(result)); }
public async Task <IActionResult> Post(CreateContaCommand command) { try { await contaApplicationService.Add(command); return(Ok(new { message = "Conta cadastrada com sucesso!" })); } catch (ValidationException e) { return(BadRequest(ValidationAdapter.Parse(e.Errors))); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public async Task Add(CreateContaCommand command) { await mediator.Send(command); }