public async Task ShouldInvalidateCadastrarProjetoCommandWhenAlreadyProjectWithSameName() { var projeto = new Projeto { Id = 1, Nome = "Teste", Status = StatusDeCadastro.Normal }; _repositoryMock.Setup(r => r.Projeto.GetProjetoByNameAsync("Teste")).Returns(Task.FromResult(projeto)); var command = new CadastrarProjetoCommand("Teste", StatusDeCadastro.Normal); var result = await _projetoHandler.Handler(command); Assert.AreEqual("Já existe um projeto com mesmo nome cadastrado", ((CommandResult)result).Message); }
public async Task <IResult> AtualizarAsync(ProjetoForUpdateViewModel projetoForUpdateVireModel) { var alterarProjetoCommand = _mapper.Map <AlterarProjetoCommand>(projetoForUpdateVireModel); var projetoHandler = new ProjetoHandler(_mapper, _repository); var result = await projetoHandler.Handler(alterarProjetoCommand); return(result); }
public async Task <IResult> InserirAsync(ProjetoForCreationViewModel projetoForCreationViewModel) { var cadastrarProjetoCommand = _mapper.Map <CadastrarProjetoCommand>(projetoForCreationViewModel); var projetoHandler = new ProjetoHandler(_mapper, _repository); var result = await projetoHandler.Handler(cadastrarProjetoCommand); return(result); }