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(); }
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(); }
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)); }
public override async Task <BaseReply> Alterar(ImpedimentoTarefaModel request, ServerCallContext context) { return(await Task.FromResult(new BaseReply { Sucesso = _impedimentoTarefaAppService.Alterar(_mapper.Map <ImpedimentoTarefaViewModel>(request)) })); }
public override async Task <BaseReply> Incluir(ImpedimentoTarefaModel request, ServerCallContext context) { return(await Task.FromResult(new BaseReply { Id = _impedimentoTarefaAppService.Incluir(_mapper.Map <ImpedimentoTarefaViewModel>(request)).ToString() })); }