public async Task InsertClienteAsync_Sucesso()
        {
            repository.InsertClienteAsync(Arg.Any <Cliente>()).Returns(Cliente);
            var controle = mapper.Map <ClienteView>(Cliente);
            var retorno  = await manager.InsertClienteAsync(NovoCliente);

            await repository.Received().InsertClienteAsync(Arg.Any <Cliente>());

            retorno.Should().BeEquivalentTo(controle);
        }
        public async Task Post_Created()
        {
            manager.InsertClienteAsync(Arg.Any <NovoCliente>()).Returns(clienteView.CloneTipado());

            var resultado = (ObjectResult)await controller.Post(novoCliente);

            await manager.Received().InsertClienteAsync(Arg.Any <NovoCliente>());

            resultado.StatusCode.Should().Be(StatusCodes.Status201Created);
            resultado.Value.Should().BeEquivalentTo(clienteView);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Post(NovoCliente novoCliente)
        {
            logger.LogInformation("Objeto recebido {@novoCliente}", novoCliente);

            ClienteView clienteInserido;

            using (Operation.Time("Tempo de adição de um novo cliente."))
            {
                logger.LogInformation("Foi requisitada a inserção de um novo cliente.");
                clienteInserido = await clienteManager.InsertClienteAsync(novoCliente);
            }
            return(CreatedAtAction(nameof(Get), new { id = clienteInserido.Id }, clienteInserido));
        }
        public async Task <IActionResult> Post(NovoCliente novoCliente)
        {
            var clienteInserido = await clienteManager.InsertClienteAsync(novoCliente);

            return(CreatedAtAction(nameof(Get), new { id = clienteInserido.Id }, clienteInserido));
        }