public async Task Deve_Incluir_Log_Valido() { var logCommand = CreateLogCommandTest.CommandValido(); _projectRepository.GetByApiKey(Arg.Any <Guid>()).Returns(ProjectTest.GetProject()); var result = await _handler.Handle(logCommand, CancellationToken.None); Assert.True(result == Guid.Empty); await _logRepository.Received().CreateAsync(Arg.Any <Log>()); await _uow.Received().CommitAsync(); }
public async Task Deve_Alterar_Projeto_Com_Dominio_Invalido() { _projectRepository.GetByIDAsync(Arg.Any<Guid>()).Returns(await Task.FromResult(ProjectTest.GetProject())); var service = new ProjectService(_validationService, _uow, _projectRepository); var model = Substitute.For<ProjectModel>(); model.IsValid().ReturnsForAnyArgs(true); await service.Update(model, Guid.NewGuid()); Assert.False(_validationService.IsValid()); await _projectRepository.DidNotReceive().UpdateAsync(Arg.Any<Project>()); await _uow.DidNotReceive().CommitAsync(); }
public async Task Deve_Alterar_Projeto_Valido() { _projectRepository.GetByIDAsync(Arg.Any<Guid>()).Returns(await Task.FromResult(ProjectTest.GetProject())); var service = new ProjectService(_validationService, _uow, _projectRepository); var project = ProjectModelTest.GetProject(); await service.Update(project, Guid.NewGuid()); await _projectRepository.Received().UpdateAsync(Arg.Any<Project>()); await _uow.Received().CommitAsync(); Assert.True(_validationService.IsValid()); }
public async Task Deve_Validar_Log_Com_Command_Invalido() { var logCommand = CreateLogCommandTest.CommandValido(); logCommand.Description = ""; _projectRepository.GetByIDAsync(Arg.Any <Guid>()).Returns(await Task.FromResult(ProjectTest.GetProject())); var result = await _handler.Handle(logCommand, CancellationToken.None); Assert.False(_validationService.IsValid(), "O validation service deve ser invalido"); Assert.True(result == Guid.Empty, "O ID do log deve retornar vazio."); await _logRepository.DidNotReceive().CreateAsync(Arg.Any <Log>()); await _uow.DidNotReceive().CommitAsync(); }