public async Task DadosParaInsercaoOK_Executado_RetornaIdProjeto() { // Arrange var projetoRepositoryMock = new Mock <IProjetoRepository>(); var inserirProjetoCommand = new InserirProjetoCommand() { Titulo = "Titulo teste", Descricao = "Descricao teste", CustoTotal = 2000, IdCliente = 1, IdFreelancer = 2 }; var inserirProjetoCommandHandler = new InserirProjetoCommandHandler(projetoRepositoryMock.Object); // Act var id = await inserirProjetoCommandHandler.Handle(inserirProjetoCommand, new CancellationToken()); // Assert Assert.True(id >= 0); projetoRepositoryMock.Verify(pr => pr.InserirAsync(It.IsAny <Projeto>()), Times.Once); }
public async Task <IActionResult> Inserir([FromBody] InserirProjetoCommand command) { var id = await _mediator.Send(command); return(CreatedAtAction(nameof(ObterProjeto), new { id }, command)); }