public async Task InputDataIsOk_Executed_FinishedProject() { //Arrange var projectRepository = new Mock <IProjectRepository>(); var finishProjectCommand = new FinishProjectCommand(1); var finishProjectCommandHandler = new FinishProjectCommandHandler(projectRepository.Object); //Act await finishProjectCommandHandler.Handle(finishProjectCommand, new CancellationToken()); var project = await projectRepository.Object.GetByIdAsync(finishProjectCommand.Id); //Assert projectRepository.Verify(pr => pr.FinishAndSaveChangesAsync(project), Times.Once); }
public async Task ProjectStatusInProgress_Executed_FinishProject() { //Arrange var project = new Project("Nome do projeto", "descrição do projeto de teste", 1, 2, 50000); var projectRepositoryMock = new Mock <IProjectRepository>(); var id = 9999; var finishProjectCommand = new FinishProjectCommand { Id = id }; var finishProjectCommandHandler = new FinishProjectCommandHandler(projectRepositoryMock.Object); projectRepositoryMock.Setup(p => p.GetByIdAsync(id).Result).Returns(project); //Act await finishProjectCommandHandler.Handle(finishProjectCommand, new CancellationToken()); //Assert projectRepositoryMock.Verify(p => p.SaveChangesAsync(), Times.Once); }