コード例 #1
0
        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);
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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));
        }