示例#1
0
        public void Test_OnGet()
        {
            // Arrange
            Guid id       = Guid.NewGuid();
            Guid idTarefa = Guid.NewGuid();

            ImpedimentoTarefaViewModel impedimentoTarefaMock = new ImpedimentoTarefaViewModel {
            };
            List <ImpedimentoViewModel> listaMock            = new List <ImpedimentoViewModel> {
            };
            TarefaViewModel tarefaMock = new TarefaViewModel {
            };

            IncluirModel pageModel = new IncluirModel(_impedimentoTarefaAppService.Object, _impedimentoAppService.Object, _tarefaAppService.Object)
            {
                PageContext = PageContextManager.CreatePageContext()
            };

            _impedimentoTarefaAppService.Setup(x => x.Consultar(id)).Returns(impedimentoTarefaMock);
            _impedimentoAppService.Setup(x => x.Listar()).Returns(listaMock);
            _tarefaAppService.Setup(x => x.Consultar(idTarefa)).Returns(tarefaMock);

            PageModelTester <IncluirModel> pageTester = new PageModelTester <IncluirModel>(pageModel);

            // Act
            pageTester
            .Action(x => () => x.OnGet(idTarefa))

            // Assert
            .TestPage();
        }
示例#2
0
        public void Test_OnGet()
        {
            // Arrange
            List <ProjetoViewModel> listaProjetosMock      = new List <ProjetoViewModel> {
            };
            List <SistemaViewModel> listaSistemasMock      = new List <SistemaViewModel> {
            };
            List <WorkflowViewModel> listaWorkflowMock     = new List <WorkflowViewModel> {
            };
            List <TipoTarefaViewModel> listaTipoTarefaMock = new List <TipoTarefaViewModel> {
            };

            IncluirModel pageModel = new IncluirModel(_tarefaAppService.Object, _projetoAppService.Object, _sistemaAppService.Object, _workflowAppService.Object, _tipoTarefaAppService.Object)
            {
                PageContext = PageContextManager.CreatePageContext()
            };

            _projetoAppService.Setup(x => x.Listar()).Returns(listaProjetosMock);
            _sistemaAppService.Setup(x => x.Listar()).Returns(listaSistemasMock);
            _workflowAppService.Setup(x => x.Listar()).Returns(listaWorkflowMock);
            _tipoTarefaAppService.Setup(x => x.Listar()).Returns(listaTipoTarefaMock);

            PageModelTester <IncluirModel> pageTester = new PageModelTester <IncluirModel>(pageModel);

            // Act
            pageTester
            .Action(x => x.OnGet)

            // Assert
            .TestPage();
        }
示例#3
0
        public void Test_OnPost()
        {
            // Arrange
            Guid id       = Guid.NewGuid();
            Guid idTarefa = Guid.NewGuid();

            RemoverModel pageModel = new RemoverModel(_recursoTarefaAppService.Object)
            {
                RecursoTarefa = new RecursoTarefaViewModel {
                    Id = id, IdTarefa = idTarefa
                },
                PageContext = PageContextManager.CreatePageContext()
            };

            _recursoTarefaAppService.Setup(x => x.Remover(id));

            PageModelTester <RemoverModel> pageTester = new PageModelTester <RemoverModel>(pageModel);

            // Act
            pageTester
            .Action(x => x.OnPost)

            // Assert
            .TestRedirectToPage("Listar");
        }
示例#4
0
        public void Test_OnGet()
        {
            // Arrange
            Guid id = Guid.NewGuid();

            ProjetoViewModel projetoMock      = new ProjetoViewModel {
            };
            List <SistemaViewModel> listaMock = new List <SistemaViewModel> {
            };

            AlterarModel pageModel = new AlterarModel(_projetoAppService.Object, _sistemaAppService.Object)
            {
                PageContext = PageContextManager.CreatePageContext()
            };

            _projetoAppService.Setup(x => x.Consultar(id)).Returns(projetoMock);
            _sistemaAppService.Setup(x => x.Listar()).Returns(listaMock);

            PageModelTester <AlterarModel> pageTester = new PageModelTester <AlterarModel>(pageModel);

            // Act
            pageTester
            .Action(x => () => x.OnGet(id))

            // Assert
            .TestPage();
        }
示例#5
0
        public void Test_OnPost(string nome, string descricao)
        {
            // Arrange
            SistemaViewModel sistemaMock = new SistemaViewModel {
                Nome = nome, Descricao = descricao
            };

            IncluirModel pageModel = new IncluirModel(_sistemaAppService.Object)
            {
                PageContext = PageContextManager.CreatePageContext()
            };

            _sistemaAppService.Setup(x => x.Incluir(sistemaMock));

            PageModelTester <IncluirModel> pageTester = new PageModelTester <IncluirModel>(pageModel);

            // Act
            pageTester
            .Action(x => x.OnPost)

            // Assert
            .WhenModelStateIsValidEquals(false)
            .TestPage();

            // Act
            pageTester
            .Action(x => x.OnPost)

            // Assert
            .WhenModelStateIsValidEquals(true)
            .TestRedirectToPage("Listar");

            // Assert
            Validation.For(sistemaMock).ShouldReturn.NoErrors();
        }
示例#6
0
        public void Test_OnPost(string nome, string login, string senha, string confirmarSenha, bool ativo)
        {
            // Arrange
            RecursoViewModel recursoMock = new RecursoViewModel {
                Nome = nome, Login = login, Senha = senha, ConfirmarSenha = confirmarSenha, Ativo = ativo
            };

            IncluirModel pageModel = new IncluirModel(_recursoAppService.Object)
            {
                PageContext = PageContextManager.CreatePageContext()
            };

            _recursoAppService.Setup(x => x.Incluir(recursoMock));

            PageModelTester <IncluirModel> pageTester = new PageModelTester <IncluirModel>(pageModel);

            // Act
            pageTester
            .Action(x => x.OnPost)

            // Assert
            .WhenModelStateIsValidEquals(false)
            .TestPage();

            // Act
            pageTester
            .Action(x => x.OnPost)

            // Assert
            .WhenModelStateIsValidEquals(true)
            .TestRedirectToPage("Listar");

            // Assert
            Validation.For(recursoMock).ShouldReturn.NoErrors();
        }
示例#7
0
        public void Test_OnGet()
        {
            // Arrange
            Guid idProjeto = Guid.NewGuid();

            ProjetoViewModel projetoMock      = new ProjetoViewModel {
            };
            List <RecursoViewModel> listaMock = new List <RecursoViewModel> {
            };

            IncluirModel pageModel = new IncluirModel(_recursoProjetoAppService.Object, _recursoAppService.Object, _projetoAppService.Object)
            {
                PageContext = PageContextManager.CreatePageContext()
            };

            _projetoAppService.Setup(x => x.Consultar(idProjeto)).Returns(projetoMock);
            _recursoAppService.Setup(x => x.Listar()).Returns(listaMock);

            PageModelTester <IncluirModel> pageTester = new PageModelTester <IncluirModel>(pageModel);

            // Act
            pageTester
            .Action(x => () => x.OnGet(idProjeto))

            // Assert
            .TestPage();
        }
示例#8
0
        public void Test_OnPost()
        {
            // Arrange
            Guid id = Guid.NewGuid();

            ProjetoViewModel projetoMock = new ProjetoViewModel {
            };

            RemoverModel pageModel = new RemoverModel(_projetoAppService.Object)
            {
                Projeto = new ProjetoViewModel {
                    Id = id
                },
                PageContext = PageContextManager.CreatePageContext()
            };

            _projetoAppService.Setup(x => x.Remover(id));

            PageModelTester <RemoverModel> pageTester = new PageModelTester <RemoverModel>(pageModel);

            // Act
            pageTester
            .Action(x => x.OnPost)

            // Assert
            .TestRedirectToPage("Listar");
        }
示例#9
0
        public void Test_OnPost(string nome, int ordem)
        {
            // Arrange
            WorkflowViewModel workflowMock = new WorkflowViewModel {
                Nome = nome, Ordem = ordem
            };

            IncluirModel pageModel = new IncluirModel(_workflowAppService.Object)
            {
                PageContext = PageContextManager.CreatePageContext()
            };

            _workflowAppService.Setup(x => x.Incluir(workflowMock));

            PageModelTester <IncluirModel> pageTester = new PageModelTester <IncluirModel>(pageModel);

            // Act
            pageTester
            .Action(x => x.OnPost)

            // Assert
            .WhenModelStateIsValidEquals(false)
            .TestPage();

            // Act
            pageTester
            .Action(x => x.OnPost)

            // Assert
            .WhenModelStateIsValidEquals(true)
            .TestRedirectToPage("Listar");

            // Assert
            Validation.For(workflowMock).ShouldReturn.NoErrors();
        }
示例#10
0
        public void Test_OnGet()
        {
            // Arrange
            Guid id        = Guid.NewGuid();
            Guid idProjeto = Guid.NewGuid();

            RecursoTarefaViewModel recursoTarefaMock = new RecursoTarefaViewModel {
                Tarefa = new TarefaViewModel {
                }
            };
            List <RecursoProjetoViewModel> listaRecursoProjetoMock = new List <RecursoProjetoViewModel> {
            };

            AlterarModel pageModel = new AlterarModel(_recursoTarefaAppService.Object, _recursoProjetoAppService.Object, _tarefaAppService.Object)
            {
                PageContext = PageContextManager.CreatePageContext()
            };

            _recursoTarefaAppService.Setup(x => x.Consultar(id)).Returns(recursoTarefaMock);
            _recursoProjetoAppService.Setup(x => x.ListarPorProjeto(idProjeto)).Returns(listaRecursoProjetoMock);

            PageModelTester <AlterarModel> pageTester = new PageModelTester <AlterarModel>(pageModel);

            // Act
            pageTester
            .Action(x => () => x.OnGet(id))

            // Assert
            .TestPage();
        }
示例#11
0
        public void Test_OnGet()
        {
            // Arrange
            Guid idRecurso = Guid.NewGuid();

            string retorno = "e91df56a-09b1-4f14-abf4-5b098f4e404b";
            List <ApontamentoViewModel> listaMock = new List <ApontamentoViewModel> {
            };
            List <RecursoTarefaViewModel> listaRecursoTarefaMock = new List <RecursoTarefaViewModel> {
            };

            ListarModel pageModel = new ListarModel(_claimsManager.Object, _apontamentoAppService.Object, _recursoTarefaAppService.Object)
            {
                PageContext = PageContextManager.CreatePageContext()
            };

            _claimsManager.Setup(x => x.ReadClaimsPrincipal(pageModel.HttpContext.User, ClaimTypes.PrimarySid)).Returns(retorno);
            _apontamentoAppService.Setup(x => x.ListarPorRecurso(idRecurso)).Returns(listaMock);
            _recursoTarefaAppService.Setup(x => x.ListarPorRecurso(idRecurso)).Returns(listaRecursoTarefaMock);

            PageModelTester <ListarModel> pageTester = new PageModelTester <ListarModel>(pageModel);

            // Act
            pageTester

            // Assert
            .Action(x => x.OnGet)
            .TestPage();
        }
示例#12
0
        public void Test_OnPost(string nome)
        {
            // Arrange
            Guid idProjeto    = Guid.NewGuid();
            Guid IdWorkflow   = Guid.NewGuid();
            Guid IdRecurso    = Guid.NewGuid();
            Guid IdTipoTarefa = Guid.NewGuid();

            DateTime dataInicio  = DateTime.Now;
            DateTime dataTermino = DateTime.Now.AddDays(5);

            TarefaViewModel tarefaMock = new TarefaViewModel
            {
                Nome         = nome,
                IdProjeto    = idProjeto,
                DataInicio   = dataInicio,
                DataTermino  = dataTermino,
                IdWorkflow   = IdWorkflow,
                IdRecurso    = IdRecurso,
                IdTipoTarefa = IdTipoTarefa
            };

            IncluirModel pageModel = new IncluirModel(_tarefaAppService.Object, _projetoAppService.Object, _sistemaAppService.Object, _workflowAppService.Object, _tipoTarefaAppService.Object)
            {
                PageContext = PageContextManager.CreatePageContext()
            };

            _tarefaAppService.Setup(x => x.Incluir(tarefaMock));

            PageModelTester <IncluirModel> pageTester = new PageModelTester <IncluirModel>(pageModel);

            // Act
            pageTester
            .Action(x => x.OnPost)

            // Assert
            .WhenModelStateIsValidEquals(false)
            .TestPage();

            // Act
            pageTester
            .Action(x => x.OnPost)

            // Assert
            .WhenModelStateIsValidEquals(true)
            .TestRedirectToPage("Listar");

            // Assert
            Validation.For(tarefaMock).ShouldReturn.NoErrors();
        }
示例#13
0
        public void Test_OnPost(int percentualTarefa)
        {
            // Arrange
            Guid idTarefa  = Guid.NewGuid();
            Guid idProjeto = Guid.NewGuid();

            List <RecursoProjetoViewModel> listaMock = new List <RecursoProjetoViewModel> {
            };
            TarefaViewModel tarefaMock = new TarefaViewModel {
            };
            RecursoTarefaViewModel recursoTarefaMock = new RecursoTarefaViewModel {
                IdTarefa = idTarefa, PercentualTarefa = percentualTarefa, Tarefa = new TarefaViewModel()
            };

            AlterarModel pageModel = new AlterarModel(_recursoTarefaAppService.Object, _recursoProjetoAppService.Object, _tarefaAppService.Object)
            {
                RecursoTarefa = new RecursoTarefaViewModel {
                    IdTarefa = idTarefa
                },
                Tarefa = new TarefaViewModel {
                    IdProjeto = idProjeto
                },
                PageContext = PageContextManager.CreatePageContext()
            };

            _tarefaAppService.Setup(x => x.Consultar(idTarefa)).Returns(tarefaMock);
            _recursoProjetoAppService.Setup(x => x.ListarPorProjeto(idProjeto)).Returns(listaMock);
            _recursoTarefaAppService.Setup(x => x.Incluir(recursoTarefaMock));

            PageModelTester <AlterarModel> pageTester = new PageModelTester <AlterarModel>(pageModel);

            // Act
            pageTester
            .Action(x => x.OnPost)

            // Assert
            .WhenModelStateIsValidEquals(false)
            .TestPage();

            // Act
            pageTester
            .Action(x => x.OnPost)

            // Assert
            .WhenModelStateIsValidEquals(true)
            .TestRedirectToPage("Listar");

            // Assert
            Validation.For(recursoTarefaMock).ShouldReturn.NoErrors();
        }
示例#14
0
        public void Test_OnPost(string descricao, int qtdHoras, int percentualConcluido)
        {
            // Arrange
            Guid idRecurso = Guid.NewGuid();
            Guid idTarefa  = Guid.NewGuid();

            DateTime dataApontamento = DateTime.Now;

            ApontamentoViewModel apontamentoMock = new ApontamentoViewModel {
                Descricao = descricao, DataApontamento = dataApontamento, QtdHoras = qtdHoras, PercentualConcluido = percentualConcluido, IdTarefa = idTarefa
            };

            string retorno = "e91df56a-09b1-4f14-abf4-5b098f4e404b";
            List <ApontamentoViewModel> listaMock = new List <ApontamentoViewModel> {
            };
            List <RecursoTarefaViewModel> listaRecursoTarefaMock = new List <RecursoTarefaViewModel> {
            };

            ListarModel pageModel = new ListarModel(_claimsManager.Object, _apontamentoAppService.Object, _recursoTarefaAppService.Object)
            {
                PageContext = PageContextManager.CreatePageContext()
            };

            _claimsManager.Setup(x => x.ReadClaimsPrincipal(pageModel.HttpContext.User, ClaimTypes.PrimarySid)).Returns(retorno);
            _apontamentoAppService.Setup(x => x.ListarPorRecurso(idRecurso)).Returns(listaMock);
            _recursoTarefaAppService.Setup(x => x.ListarPorRecurso(idRecurso)).Returns(listaRecursoTarefaMock);

            PageModelTester <ListarModel> pageTester = new PageModelTester <ListarModel>(pageModel);

            // Act
            pageTester
            .Action(x => x.OnPost)

            // Assert
            .WhenModelStateIsValidEquals(false)
            .TestPage();

            // Act
            pageTester
            .Action(x => x.OnPost)

            // Assert
            .WhenModelStateIsValidEquals(true)
            .TestRedirectToPage("Listar");

            // Assert
            Validation.For(apontamentoMock).ShouldReturn.NoErrors();
        }
示例#15
0
        public void Test_OnPost(string descricao)
        {
            // Arrange
            Guid id            = Guid.NewGuid();
            Guid idImpedimento = Guid.NewGuid();
            Guid idTarefa      = Guid.NewGuid();

            ImpedimentoTarefaViewModel impedimentoTarefaMock = new ImpedimentoTarefaViewModel {
                Id = id, IdImpedimento = idImpedimento, IdTarefa = idTarefa, Descricao = descricao
            };
            List <ImpedimentoViewModel> listaMock = new List <ImpedimentoViewModel> {
            };

            AlterarModel pageModel = new AlterarModel(_impedimentoTarefaAppService.Object, _impedimentoAppService.Object)
            {
                ImpedimentoTarefa = new ImpedimentoTarefaViewModel {
                    IdTarefa = idTarefa
                },
                PageContext = PageContextManager.CreatePageContext()
            };

            _impedimentoTarefaAppService.Setup(x => x.Alterar(impedimentoTarefaMock));
            _impedimentoAppService.Setup(x => x.Listar()).Returns(listaMock);

            PageModelTester <AlterarModel> pageTester = new PageModelTester <AlterarModel>(pageModel);

            // Act
            pageTester
            .Action(x => x.OnPost)

            // Assert
            .WhenModelStateIsValidEquals(false)
            .TestPage();

            // Act
            pageTester
            .Action(x => x.OnPost)

            // Assert
            .WhenModelStateIsValidEquals(true)
            .TestRedirectToPage("Listar");

            // Assert
            Validation.For(impedimentoTarefaMock).ShouldReturn.NoErrors();
        }
示例#16
0
        public void Test_OnPost()
        {
            // Arrange
            Guid idProjeto = Guid.NewGuid();

            RecursoProjetoViewModel recursoProjetoMock = new RecursoProjetoViewModel {
                IdProjeto = idProjeto
            };
            ProjetoViewModel projetoMock      = new ProjetoViewModel {
            };
            List <RecursoViewModel> listaMock = new List <RecursoViewModel> {
            };

            IncluirModel pageModel = new IncluirModel(_recursoProjetoAppService.Object, _recursoAppService.Object, _projetoAppService.Object)
            {
                PageContext = PageContextManager.CreatePageContext()
            };

            _recursoProjetoAppService.Setup(x => x.Incluir(recursoProjetoMock));
            _projetoAppService.Setup(x => x.Consultar(idProjeto)).Returns(projetoMock);
            _recursoAppService.Setup(x => x.Listar()).Returns(listaMock);

            PageModelTester <IncluirModel> pageTester = new PageModelTester <IncluirModel>(pageModel);

            // Act
            pageTester
            .Action(x => () => x.OnPost(idProjeto))

            // Assert
            .WhenModelStateIsValidEquals(false)
            .TestPage();

            // Act
            pageTester
            .Action(x => () => x.OnPost(idProjeto))

            // Assert
            .WhenModelStateIsValidEquals(true)
            .TestRedirectToPage("Listar");

            // Assert
            Validation.For(recursoProjetoMock).ShouldReturn.NoErrors();
        }
示例#17
0
        public void Test_OnPost(string nome)
        {
            // Arrange
            Guid id        = Guid.NewGuid();
            Guid idSistema = Guid.NewGuid();

            ProjetoViewModel projetoMock = new ProjetoViewModel {
                Id = id, Nome = nome, IdSistema = idSistema
            };
            List <SistemaViewModel> listaMock = new List <SistemaViewModel> {
            };

            AlterarModel pageModel = new AlterarModel(_projetoAppService.Object, _sistemaAppService.Object)
            {
                PageContext = PageContextManager.CreatePageContext()
            };

            _projetoAppService.Setup(x => x.Alterar(projetoMock));
            _sistemaAppService.Setup(x => x.Listar()).Returns(listaMock);

            PageModelTester <AlterarModel> pageTester = new PageModelTester <AlterarModel>(pageModel);

            // Act
            pageTester
            .Action(x => x.OnPost)

            // Assert
            .WhenModelStateIsValidEquals(false)
            .TestPage();

            // Act
            pageTester
            .Action(x => x.OnPost)

            // Assert
            .WhenModelStateIsValidEquals(true)
            .TestRedirectToPage("Listar");

            // Assert
            Validation.For(projetoMock).ShouldReturn.NoErrors();
        }
示例#18
0
        public void Test_OnGet()
        {
            // Arrange
            List <SistemaViewModel> listaMock = new List <SistemaViewModel> {
            };

            ListarModel pageModel = new ListarModel(_sistemaAppService.Object)
            {
                PageContext = PageContextManager.CreatePageContext()
            };

            _sistemaAppService.Setup(x => x.Listar()).Returns(listaMock);

            PageModelTester <ListarModel> pageTester = new PageModelTester <ListarModel>(pageModel);

            // Act
            pageTester

            // Assert
            .Action(x => x.OnGet)
            .TestPage();
        }
示例#19
0
        public void Test_OnPost(string nome)
        {
            // Arrange
            Guid id = Guid.NewGuid();

            ImpedimentoViewModel impedimentoMock = new ImpedimentoViewModel {
                Id = id, Nome = nome
            };

            AlterarModel pageModel = new AlterarModel(_impedimentoAppService.Object)
            {
                PageContext = PageContextManager.CreatePageContext()
            };

            _impedimentoAppService.Setup(x => x.Alterar(impedimentoMock));

            PageModelTester <AlterarModel> pageTester = new PageModelTester <AlterarModel>(pageModel);

            // Act
            pageTester
            .Action(x => x.OnPost)

            // Assert
            .WhenModelStateIsValidEquals(false)
            .TestPage();

            // Act
            pageTester
            .Action(x => x.OnPost)

            // Assert
            .WhenModelStateIsValidEquals(true)
            .TestRedirectToPage("Listar");

            // Assert
            Validation.For(impedimentoMock).ShouldReturn.NoErrors();
        }
示例#20
0
        public void Test_OnGet()
        {
            // Arrange
            Guid id = Guid.NewGuid();

            ImpedimentoViewModel impedimentoMock = new ImpedimentoViewModel {
            };

            AlterarModel pageModel = new AlterarModel(_impedimentoAppService.Object)
            {
                PageContext = PageContextManager.CreatePageContext()
            };

            _impedimentoAppService.Setup(x => x.Consultar(id)).Returns(impedimentoMock);

            PageModelTester <AlterarModel> pageTester = new PageModelTester <AlterarModel>(pageModel);

            // Act
            pageTester
            .Action(x => () => x.OnGet(id))

            // Assert
            .TestPage();
        }
示例#21
0
        public void Test_OnGet()
        {
            // Arrange
            Guid id = Guid.NewGuid();

            RecursoTarefaViewModel recursoTarefaMock = new RecursoTarefaViewModel {
            };

            RemoverModel pageModel = new RemoverModel(_recursoTarefaAppService.Object)
            {
                PageContext = PageContextManager.CreatePageContext()
            };

            _recursoTarefaAppService.Setup(x => x.Consultar(id)).Returns(recursoTarefaMock);

            PageModelTester <RemoverModel> pageTester = new PageModelTester <RemoverModel>(pageModel);

            // Act
            pageTester
            .Action(x => () => x.OnGet(id))

            // Assert
            .TestPage();
        }
示例#22
0
        public void Test_OnGet()
        {
            // Arrange
            Guid idTarefa = Guid.NewGuid();

            List <ImpedimentoTarefaViewModel> listaMock = new List <ImpedimentoTarefaViewModel> {
            };

            _impedimentoTarefaAppService.Setup(x => x.ListarPorTarefa(idTarefa)).Returns(listaMock);

            ListarModel pageModel = new ListarModel(_impedimentoTarefaAppService.Object)
            {
                PageContext = PageContextManager.CreatePageContext()
            };

            PageModelTester <ListarModel> pageTester = new PageModelTester <ListarModel>(pageModel);

            // Act
            pageTester
            .Action(x => () => x.OnGet(idTarefa))

            // Assert
            .TestPage();
        }