public async Task ListProjetoQuery_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)); await unitOfWork.ProjetoRepository.AddAsync(MockEntityHelper.GetNewProjeto(sistemaId)); await unitOfWork.ProjetoRepository.AddAsync(MockEntityHelper.GetNewProjeto(sistemaId)); await unitOfWork.SaveChangesAsync(); ListProjetoQuery request = new(); // Act ProjetoHandler handler = new(unitOfWork, mapper); IEnumerable <ProjetoViewModel> response = await handler.Handle(request, CancellationToken.None); // Assert Assert.True(response != null); Assert.True(response.Any()); Assert.True(response.FirstOrDefault(x => x.Id == projetoId) != null); }
public async Task GetSistemaQuery_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(); await unitOfWork.SistemaRepository.AddAsync(MockEntityHelper.GetNewSistema(sistemaId)); await unitOfWork.SaveChangesAsync(); GetSistemaQuery request = new() { Id = sistemaId }; // Act SistemaHandler handler = new(unitOfWork, mapper, mockServiceBus.Object, mockSignalR.Object); SistemaViewModel response = await handler.Handle(request, CancellationToken.None); // Assert Assert.True(response != null); Assert.True(response.Id != Guid.Empty); Assert.True(response.DataInclusao.Ticks != 0); }
public async Task GetProjetoQuery_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)); await unitOfWork.SaveChangesAsync(); GetProjetoQuery request = new() { Id = projetoId }; // Act ProjetoHandler handler = new(unitOfWork, mapper); ProjetoViewModel response = await handler.Handle(request, CancellationToken.None); // Assert Assert.True(response != null); Assert.True(response.Id != Guid.Empty); Assert.True(response.DataInclusao.Ticks != 0); }
public async Task ListSistemaQuery_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(); await unitOfWork.SistemaRepository.AddAsync(MockEntityHelper.GetNewSistema(sistemaId)); await unitOfWork.SistemaRepository.AddAsync(MockEntityHelper.GetNewSistema()); await unitOfWork.SistemaRepository.AddAsync(MockEntityHelper.GetNewSistema()); await unitOfWork.SaveChangesAsync(); ListSistemaQuery request = new(); // Act SistemaHandler handler = new(unitOfWork, mapper, mockServiceBus.Object, mockSignalR.Object); IEnumerable <SistemaViewModel> response = await handler.Handle(request, CancellationToken.None); // Assert Assert.True(response != null); Assert.True(response.Any()); Assert.True(response.FirstOrDefault(x => x.Id == sistemaId) != null); }
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 RemoveApontamentoCommand_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 apontamentoId = Guid.NewGuid(); Apontamento apontamento = MockEntityHelper.GetNewApontamento(tarefaId, recursoId, apontamentoId); await unitOfWork.ApontamentoRepository.AddAsync(apontamento); await unitOfWork.SaveChangesAsync(); unitOfWork.ApontamentoRepository.Detatch(apontamento); RemoveApontamentoCommand request = new() { Id = apontamentoId }; GetApontamentoQuery request2 = new() { Id = apontamentoId }; // Act ApontamentoHandler handler = new(unitOfWork, mapper); OperationResult response = await handler.Handle(request, CancellationToken.None); ApontamentoViewModel response2 = await handler.Handle(request2, CancellationToken.None); // Assert Assert.True(response == OperationResult.Success); Assert.True(response2 == null); } [Fact]
public async Task ListImpedimentoTarefaQuery_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(); await unitOfWork.ImpedimentoTarefaRepository.AddAsync(MockEntityHelper.GetNewImpedimentoTarefa(tarefaId, impedimentoId, impedimentoTarefaId)); await unitOfWork.ImpedimentoTarefaRepository.AddAsync(MockEntityHelper.GetNewImpedimentoTarefa(tarefaId, impedimentoId)); await unitOfWork.ImpedimentoTarefaRepository.AddAsync(MockEntityHelper.GetNewImpedimentoTarefa(tarefaId, impedimentoId)); await unitOfWork.SaveChangesAsync(); ListImpedimentoTarefaQuery request = new(); // Act ImpedimentoTarefaHandler handler = new(unitOfWork, mapper); IEnumerable <ImpedimentoTarefaViewModel> response = await handler.Handle(request, CancellationToken.None); // Assert Assert.True(response != null); Assert.True(response.Any()); Assert.True(response.FirstOrDefault(x => x.Id == impedimentoTarefaId) != null); }
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 GetRecursoTarefaQuery_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 recursoTarefaId = Guid.NewGuid(); await unitOfWork.RecursoTarefaRepository.AddAsync(MockEntityHelper.GetNewRecursoTarefa(tarefaId, recursoId, recursoTarefaId)); await unitOfWork.SaveChangesAsync(); GetRecursoTarefaQuery request = new() { Id = recursoTarefaId }; // Act RecursoTarefaHandler handler = new(unitOfWork, mapper); RecursoTarefaViewModel response = await handler.Handle(request, CancellationToken.None); // Assert Assert.True(response != null); Assert.True(response.Id != Guid.Empty); Assert.True(response.DataInclusao.Ticks != 0); }
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 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); }