public void Test_CreateCartaValidator(int valor, bool valid) { var command = new CreateCartaCommand { Valor = valor }; var validator = new CreateCartaValidator(); var result = validator.Validate(command); Assert.Equal(valid, result.IsValid); }
public async Task Should_Create_Carta() { try { var command = new CreateCartaCommand { Valor = 5 }; var response = await integrationTestServer.PostAsync <DtoCarta>("/api/Cartas", command); Assert.Equal(HttpStatusCode.Created, response.StatusCode); carta = response.Data; } catch (Exception ex) { output.WriteLine(ex.GetType().FullName); output.WriteLine(ex.Message); output.WriteLine(ex.StackTrace); } }
public async Task <ActionResult <DtoCarta> > PostCarta([FromBody] CreateCartaCommand createCarta) { var dtoCarta = await Mediator.Send(createCarta).ConfigureAwait(false); return(CreatedAtAction($"{nameof(CartasController.GetCarta)}", new { id = dtoCarta.Id }, dtoCarta)); }