Exemplo n.º 1
0
        public void Test_OnPostAsync(int idImpedimentoTarefa, int idImpedimento, int idTarefa, string descricao)
        {
            // Arrange
            var impedimentoTarefaMock = new ImpedimentoTarefaModel {
                IdImpedimentoTarefa = idImpedimentoTarefa, IdImpedimento = idImpedimento, IdTarefa = idTarefa, Descricao = descricao
            };
            var listaMock = new List <ImpedimentoModel> {
            };

            _impedimentoTarefaRepository.Setup(x => x.AlterarAsync(impedimentoTarefaMock));
            _impedimentoRepository.Setup(x => x.ListarAsync()).ReturnsAsync(listaMock);

            var pageModel = new AlterarModel(_impedimentoTarefaRepository.Object, _impedimentoRepository.Object);

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

            // Act
            pageTester
            .Action(x => () => x.OnPostAsync(idImpedimentoTarefa))

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

            // Act
            pageTester
            .Action(x => () => x.OnPostAsync(idImpedimentoTarefa))

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

            // Assert
            Validation.For(impedimentoTarefaMock).ShouldReturn.NoErrors();
        }
Exemplo n.º 2
0
        public void Test_OnGetAsync(int idImpedimentoTarefa, int idTarefa)
        {
            // Arrange
            var impedimentoTarefaMock = new ImpedimentoTarefaModel {
            };
            var listaMock             = new List <ImpedimentoModel> {
            };
            var tarefaMock            = new TarefaModel {
            };

            _impedimentoTarefaRepository.Setup(x => x.ConsultarAsync(idImpedimentoTarefa)).ReturnsAsync(impedimentoTarefaMock);
            _impedimentoRepository.Setup(x => x.ListarAsync()).ReturnsAsync(listaMock);
            _tarefaRepository.Setup(x => x.ConsultarAsync(idTarefa)).ReturnsAsync(tarefaMock);

            var pageModel = new IncluirModel(_impedimentoTarefaRepository.Object, _impedimentoRepository.Object, _tarefaRepository.Object);

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

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

            // Assert
            .TestPage();
        }
Exemplo n.º 3
0
        public override async Task <ImpedimentoTarefaModel> Consultar(BaseRequest request, ServerCallContext context)
        {
            Guid id = new Guid(request.Id);
            ImpedimentoTarefaModel result = _mapper.Map <ImpedimentoTarefaModel>(_impedimentoTarefaAppService.Consultar(id));

            return(await Task.FromResult(result));
        }
Exemplo n.º 4
0
 public override async Task <BaseReply> Alterar(ImpedimentoTarefaModel request, ServerCallContext context)
 {
     return(await Task.FromResult(new BaseReply
     {
         Sucesso = _impedimentoTarefaAppService.Alterar(_mapper.Map <ImpedimentoTarefaViewModel>(request))
     }));
 }
Exemplo n.º 5
0
 public override async Task <BaseReply> Incluir(ImpedimentoTarefaModel request, ServerCallContext context)
 {
     return(await Task.FromResult(new BaseReply
     {
         Id = _impedimentoTarefaAppService.Incluir(_mapper.Map <ImpedimentoTarefaViewModel>(request)).ToString()
     }));
 }