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 GetWorkflowQuery_Handle()
    {
        // Arrange
        IUnitOfWork unitOfWork = DbContextHelper.GetContext();
        IMapper     mapper     = AutoMapperHelper.GetMappings();

        Guid workflowId = Guid.NewGuid();

        await unitOfWork.WorkflowRepository.AddAsync(MockEntityHelper.GetNewWorkflow(workflowId));

        await unitOfWork.SaveChangesAsync();

        GetWorkflowQuery request = new()
        {
            Id = workflowId
        };

        // Act
        WorkflowHandler   handler  = new(unitOfWork, mapper);
        WorkflowViewModel 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 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 ListWorkflowQuery_Handle()
    {
        // Arrange
        IUnitOfWork unitOfWork = DbContextHelper.GetContext();
        IMapper     mapper     = AutoMapperHelper.GetMappings();

        Guid workflowId = Guid.NewGuid();

        await unitOfWork.WorkflowRepository.AddAsync(MockEntityHelper.GetNewWorkflow(workflowId));

        await unitOfWork.WorkflowRepository.AddAsync(MockEntityHelper.GetNewWorkflow());

        await unitOfWork.WorkflowRepository.AddAsync(MockEntityHelper.GetNewWorkflow());

        await unitOfWork.SaveChangesAsync();

        ListWorkflowQuery request = new();

        // Act
        WorkflowHandler handler = new(unitOfWork, mapper);
        IEnumerable <WorkflowViewModel> response = await handler.Handle(request, CancellationToken.None);

        // Assert
        Assert.True(response != null);
        Assert.True(response.Any());
        Assert.True(response.FirstOrDefault(x => x.Id == workflowId) != null);
        Assert.True(response.FirstOrDefault(x => x.TamanhoColuna != null) != null);
    }
    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);
    }
예제 #6
0
    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);
    }
}
예제 #7
0
    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 ListTipoTarefaQuery_Handle()
    {
        // Arrange
        IUnitOfWork unitOfWork = DbContextHelper.GetContext();
        IMapper     mapper     = AutoMapperHelper.GetMappings();

        Guid tipoTarefaId = Guid.NewGuid();

        await unitOfWork.TipoTarefaRepository.AddAsync(MockEntityHelper.GetNewTipoTarefa(tipoTarefaId));

        await unitOfWork.TipoTarefaRepository.AddAsync(MockEntityHelper.GetNewTipoTarefa());

        await unitOfWork.TipoTarefaRepository.AddAsync(MockEntityHelper.GetNewTipoTarefa());

        await unitOfWork.SaveChangesAsync();

        ListTipoTarefaQuery request = new();

        // Act
        TipoTarefaHandler handler = new(unitOfWork, mapper);
        IEnumerable <TipoTarefaViewModel> response = await handler.Handle(request, CancellationToken.None);

        // Assert
        Assert.True(response != null);
        Assert.True(response.Any());
        Assert.True(response.FirstOrDefault(x => x.Id == tipoTarefaId) != null);
    }
    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 ListRecursoQuery_Handle()
    {
        // Arrange
        IUnitOfWork          unitOfWork = DbContextHelper.GetContext();
        IMapper              mapper     = AutoMapperHelper.GetMappings();
        ICryptographyManager manager    = CryptographyHelper.GetInstance();

        Guid recursoId = Guid.NewGuid();

        await unitOfWork.RecursoRepository.AddAsync(MockEntityHelper.GetNewRecurso(recursoId));

        await unitOfWork.RecursoRepository.AddAsync(MockEntityHelper.GetNewRecurso());

        await unitOfWork.RecursoRepository.AddAsync(MockEntityHelper.GetNewRecurso());

        await unitOfWork.SaveChangesAsync();

        ListRecursoQuery request = new();

        // Act
        RecursoHandler handler = new(unitOfWork, mapper, manager);
        IEnumerable <RecursoViewModel> response = await handler.Handle(request, CancellationToken.None);

        // Assert
        Assert.True(response != null);
        Assert.True(response.Any());
        Assert.True(response.FirstOrDefault(x => x.Id == recursoId) != null);
    }
    public async Task GetRecursoQuery_Handle()
    {
        // Arrange
        IUnitOfWork          unitOfWork = DbContextHelper.GetContext();
        IMapper              mapper     = AutoMapperHelper.GetMappings();
        ICryptographyManager manager    = CryptographyHelper.GetInstance();

        Guid recursoId = Guid.NewGuid();

        await unitOfWork.RecursoRepository.AddAsync(MockEntityHelper.GetNewRecurso(recursoId));

        await unitOfWork.SaveChangesAsync();

        GetRecursoQuery request = new()
        {
            Id = recursoId
        };

        // Act
        RecursoHandler   handler  = new(unitOfWork, mapper, manager);
        RecursoViewModel response = await handler.Handle(request, CancellationToken.None);

        // Assert
        Assert.True(response != null);
        Assert.True(response.Id != Guid.Empty);
        Assert.True(response.DataInclusao.Ticks != 0);
        Assert.True(response.Senha == null);
        Assert.True(response.Salt == null);
    }
예제 #12
0
    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]
예제 #13
0
    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 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);
    }
}
예제 #17
0
    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 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 RemoveTipoTarefaCommand_Handle()
    {
        // Arrange
        IUnitOfWork unitOfWork = DbContextHelper.GetContext();
        IMapper     mapper     = AutoMapperHelper.GetMappings();

        Guid tipoTarefaId = Guid.NewGuid();

        TipoTarefa tipoTarefa = MockEntityHelper.GetNewTipoTarefa(tipoTarefaId);

        await unitOfWork.TipoTarefaRepository.AddAsync(tipoTarefa);

        await unitOfWork.SaveChangesAsync();

        unitOfWork.TipoTarefaRepository.Detatch(tipoTarefa);

        RemoveTipoTarefaCommand request = new()
        {
            Id = tipoTarefaId
        };

        GetTipoTarefaQuery request2 = new()
        {
            Id = tipoTarefaId
        };

        // Act
        TipoTarefaHandler handler  = new(unitOfWork, mapper);
        OperationResult   response = await handler.Handle(request, CancellationToken.None);

        TipoTarefaViewModel response2 = await handler.Handle(request2, CancellationToken.None);

        // Assert
        Assert.True(response == OperationResult.Success);
        Assert.True(response2 == null);
    }

    [Fact]
예제 #20
0
    public async Task RemoveImpedimentoCommand_Handle()
    {
        // Arrange
        IUnitOfWork unitOfWork = DbContextHelper.GetContext();
        IMapper     mapper     = AutoMapperHelper.GetMappings();

        Guid impedimentoId = Guid.NewGuid();

        Impedimento impedimento = MockEntityHelper.GetNewImpedimento(impedimentoId);

        await unitOfWork.ImpedimentoRepository.AddAsync(impedimento);

        await unitOfWork.SaveChangesAsync();

        unitOfWork.ImpedimentoRepository.Detatch(impedimento);

        RemoveImpedimentoCommand request = new()
        {
            Id = impedimentoId
        };

        GetImpedimentoQuery request2 = new()
        {
            Id = impedimentoId
        };

        // Act
        ImpedimentoHandler handler  = new(unitOfWork, mapper);
        OperationResult    response = await handler.Handle(request, CancellationToken.None);

        ImpedimentoViewModel response2 = await handler.Handle(request2, CancellationToken.None);

        // Assert
        Assert.True(response == OperationResult.Success);
        Assert.True(response2 == null);
    }

    [Fact]
    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);
    }