public async Task CreateTarefaCommand_Handle() { // Arrange IUnitOfWork unitOfWork = DbContextHelper.GetContext(); IMapper mapper = AutoMapperHelper.GetMappings(); Guid sistemaId = Guid.NewGuid(); await unitOfWork.SistemaRepository.AddAsync(MockEntityHelper.GetNewSistema(sistemaId)); Guid projetoId = Guid.NewGuid(); await unitOfWork.ProjetoRepository.AddAsync(MockEntityHelper.GetNewProjeto(sistemaId, projetoId)); Guid workflowId = Guid.NewGuid(); await unitOfWork.WorkflowRepository.AddAsync(MockEntityHelper.GetNewWorkflow(workflowId)); Guid recursoId = Guid.NewGuid(); await unitOfWork.RecursoRepository.AddAsync(MockEntityHelper.GetNewRecurso(recursoId)); Guid tipoTarefaId = Guid.NewGuid(); await unitOfWork.TipoTarefaRepository.AddAsync(MockEntityHelper.GetNewTipoTarefa(tipoTarefaId)); await unitOfWork.SaveChangesAsync(); CreateTarefaCommand request = new() { Tarefa = MockViewModelHelper.GetNewTarefa(projetoId, workflowId, recursoId, tipoTarefaId) }; // Act TarefaHandler handler = new(unitOfWork, mapper); OperationResult response = await handler.Handle(request, CancellationToken.None); // Assert Assert.True(response == OperationResult.Success); }
public async Task UpdateImpedimentoTarefaCommand_Handle() { // Arrange IUnitOfWork unitOfWork = DbContextHelper.GetContext(); IMapper mapper = AutoMapperHelper.GetMappings(); Guid sistemaId = Guid.NewGuid(); await unitOfWork.SistemaRepository.AddAsync(MockEntityHelper.GetNewSistema(sistemaId)); Guid projetoId = Guid.NewGuid(); await unitOfWork.ProjetoRepository.AddAsync(MockEntityHelper.GetNewProjeto(sistemaId, projetoId)); Guid workflowId = Guid.NewGuid(); await unitOfWork.WorkflowRepository.AddAsync(MockEntityHelper.GetNewWorkflow(workflowId)); Guid recursoId = Guid.NewGuid(); await unitOfWork.RecursoRepository.AddAsync(MockEntityHelper.GetNewRecurso(recursoId)); Guid tipoTarefaId = Guid.NewGuid(); await unitOfWork.TipoTarefaRepository.AddAsync(MockEntityHelper.GetNewTipoTarefa(tipoTarefaId)); Guid tarefaId = Guid.NewGuid(); await unitOfWork.TarefaRepository.AddAsync(MockEntityHelper.GetNewTarefa(projetoId, workflowId, recursoId, tipoTarefaId, tarefaId)); Guid impedimentoId = Guid.NewGuid(); await unitOfWork.ImpedimentoRepository.AddAsync(MockEntityHelper.GetNewImpedimento(impedimentoId)); Guid impedimentoTarefaId = Guid.NewGuid(); DateTime dataInclusao = DateTime.Now; ImpedimentoTarefa impedimentoTarefa = MockEntityHelper.GetNewImpedimentoTarefa(tarefaId, impedimentoId, impedimentoTarefaId); await unitOfWork.ImpedimentoTarefaRepository.AddAsync(impedimentoTarefa); await unitOfWork.SaveChangesAsync(); unitOfWork.ImpedimentoTarefaRepository.Detatch(impedimentoTarefa); UpdateImpedimentoTarefaCommand request = new() { ImpedimentoTarefa = MockViewModelHelper.GetNewImpedimentoTarefa(tarefaId, impedimentoId, impedimentoTarefaId, dataInclusao) }; GetImpedimentoTarefaQuery request2 = new() { Id = impedimentoTarefaId }; // Act ImpedimentoTarefaHandler handler = new(unitOfWork, mapper); OperationResult response = await handler.Handle(request, CancellationToken.None); ImpedimentoTarefaViewModel response2 = await handler.Handle(request2, CancellationToken.None); // Assert Assert.True(response == OperationResult.Success); Assert.True(response2 != null); Assert.True(response2.Id == impedimentoTarefaId); Assert.True(response2.DataInclusao.Ticks == dataInclusao.Ticks); } }
public async Task CreateWorkflowCommand_Handle() { // Arrange IUnitOfWork unitOfWork = DbContextHelper.GetContext(); IMapper mapper = AutoMapperHelper.GetMappings(); CreateWorkflowCommand request = new() { Workflow = MockViewModelHelper.GetNewWorkflow() }; // Act WorkflowHandler handler = new(unitOfWork, mapper); OperationResult response = await handler.Handle(request, CancellationToken.None); // Assert Assert.True(response == OperationResult.Success); }
public async Task UpdateProjetoCommand_Handle() { // Arrange IUnitOfWork unitOfWork = DbContextHelper.GetContext(); IMapper mapper = AutoMapperHelper.GetMappings(); Guid sistemaId = Guid.NewGuid(); await unitOfWork.SistemaRepository.AddAsync(MockEntityHelper.GetNewSistema(sistemaId)); Guid projetoId = Guid.NewGuid(); DateTime dataInclusao = DateTime.Now; Projeto projeto = MockEntityHelper.GetNewProjeto(sistemaId, projetoId); await unitOfWork.ProjetoRepository.AddAsync(projeto); await unitOfWork.SaveChangesAsync(); unitOfWork.ProjetoRepository.Detatch(projeto); UpdateProjetoCommand request = new() { Projeto = MockViewModelHelper.GetNewProjeto(sistemaId, projetoId, dataInclusao) }; GetProjetoQuery request2 = new() { Id = projetoId }; // Act ProjetoHandler handler = new(unitOfWork, mapper); OperationResult response = await handler.Handle(request, CancellationToken.None); ProjetoViewModel response2 = await handler.Handle(request2, CancellationToken.None); // Assert Assert.True(response == OperationResult.Success); Assert.True(response2 != null); Assert.True(response2.Id == projetoId); Assert.True(response2.DataInclusao.Ticks == dataInclusao.Ticks); } }
public async Task UpdateSistemaCommand_Handle() { // Arrange IUnitOfWork unitOfWork = DbContextHelper.GetContext(); IMapper mapper = AutoMapperHelper.GetMappings(); Mock <IEventHandler> mockServiceBus = ServiceBusHelper.GetInstance(); Mock <IHubContext <CpnucleoHub> > mockSignalR = SignalRHelper.GetInstance(); Guid sistemaId = Guid.NewGuid(); DateTime dataInclusao = DateTime.Now; Sistema sistema = MockEntityHelper.GetNewSistema(sistemaId); await unitOfWork.SistemaRepository.AddAsync(sistema); await unitOfWork.SaveChangesAsync(); unitOfWork.SistemaRepository.Detatch(sistema); UpdateSistemaCommand request = new() { Sistema = MockViewModelHelper.GetNewSistema(sistemaId, dataInclusao) }; GetSistemaQuery request2 = new() { Id = sistemaId }; // Act SistemaHandler handler = new(unitOfWork, mapper, mockServiceBus.Object, mockSignalR.Object); OperationResult response = await handler.Handle(request, CancellationToken.None); SistemaViewModel response2 = await handler.Handle(request2, CancellationToken.None); // Assert Assert.True(response == OperationResult.Success); Assert.True(response2 != null); Assert.True(response2.Id == sistemaId); Assert.True(response2.DataInclusao.Ticks == dataInclusao.Ticks); } }
public async Task UpdateRecursoCommand_Handle() { // Arrange IUnitOfWork unitOfWork = DbContextHelper.GetContext(); IMapper mapper = AutoMapperHelper.GetMappings(); ICryptographyManager manager = CryptographyHelper.GetInstance(); Guid recursoId = Guid.NewGuid(); DateTime dataInclusao = DateTime.Now; Recurso recurso = MockEntityHelper.GetNewRecurso(recursoId); await unitOfWork.RecursoRepository.AddAsync(recurso); await unitOfWork.SaveChangesAsync(); unitOfWork.RecursoRepository.Detatch(recurso); UpdateRecursoCommand request = new() { Recurso = MockViewModelHelper.GetNewRecurso(recursoId, dataInclusao) }; GetRecursoQuery request2 = new() { Id = recursoId }; // Act RecursoHandler handler = new(unitOfWork, mapper, manager); OperationResult response = await handler.Handle(request, CancellationToken.None); RecursoViewModel response2 = await handler.Handle(request2, CancellationToken.None); // Assert Assert.True(response == OperationResult.Success); Assert.True(response2 != null); Assert.True(response2.Id == recursoId); Assert.True(response2.DataInclusao.Ticks == dataInclusao.Ticks); Assert.True(response2.Senha == null); Assert.True(response2.Salt == null); } }
public async Task CreateRecursoCommand_Handle() { // Arrange IUnitOfWork unitOfWork = DbContextHelper.GetContext(); IMapper mapper = AutoMapperHelper.GetMappings(); ICryptographyManager manager = CryptographyHelper.GetInstance(); CreateRecursoCommand request = new() { Recurso = MockViewModelHelper.GetNewRecurso() }; // Act RecursoHandler handler = new(unitOfWork, mapper, manager); OperationResult response = await handler.Handle(request, CancellationToken.None); // Assert Assert.True(response == OperationResult.Success); }
public async Task CreateSistemaCommand_Handle() { // Arrange IUnitOfWork unitOfWork = DbContextHelper.GetContext(); IMapper mapper = AutoMapperHelper.GetMappings(); Mock <IEventHandler> mockServiceBus = ServiceBusHelper.GetInstance(); Mock <IHubContext <CpnucleoHub> > mockSignalR = SignalRHelper.GetInstance(); CreateSistemaCommand request = new() { Sistema = MockViewModelHelper.GetNewSistema() }; // Act SistemaHandler handler = new(unitOfWork, mapper, mockServiceBus.Object, mockSignalR.Object); OperationResult response = await handler.Handle(request, CancellationToken.None); // Assert Assert.True(response == OperationResult.Success); }
public async Task UpdateWorkflowCommand_Handle() { // Arrange IUnitOfWork unitOfWork = DbContextHelper.GetContext(); IMapper mapper = AutoMapperHelper.GetMappings(); Guid workflowId = Guid.NewGuid(); DateTime dataInclusao = DateTime.Now; Workflow workflow = MockEntityHelper.GetNewWorkflow(workflowId); await unitOfWork.WorkflowRepository.AddAsync(workflow); await unitOfWork.SaveChangesAsync(); unitOfWork.WorkflowRepository.Detatch(workflow); UpdateWorkflowCommand request = new() { Workflow = MockViewModelHelper.GetNewWorkflow(workflowId, dataInclusao) }; GetWorkflowQuery request2 = new() { Id = workflowId }; // Act WorkflowHandler handler = new(unitOfWork, mapper); OperationResult response = await handler.Handle(request, CancellationToken.None); WorkflowViewModel response2 = await handler.Handle(request2, CancellationToken.None); // Assert Assert.True(response == OperationResult.Success); Assert.True(response2 != null); Assert.True(response2.Id == workflowId); Assert.True(response2.DataInclusao.Ticks == dataInclusao.Ticks); } }
public async Task CreateProjetoCommand_Handle() { // Arrange IUnitOfWork unitOfWork = DbContextHelper.GetContext(); IMapper mapper = AutoMapperHelper.GetMappings(); Guid sistemaId = Guid.NewGuid(); await unitOfWork.SistemaRepository.AddAsync(MockEntityHelper.GetNewSistema(sistemaId)); await unitOfWork.SaveChangesAsync(); CreateProjetoCommand request = new() { Projeto = MockViewModelHelper.GetNewProjeto(sistemaId) }; // Act ProjetoHandler handler = new(unitOfWork, mapper); OperationResult response = await handler.Handle(request, CancellationToken.None); // Assert Assert.True(response == OperationResult.Success); }