Beispiel #1
0
        public void TestaCreateComAgendamentoDuplicado()
        {
            var agendamentoId  = 1;
            var agendamentoDto = new AgendamentoDtoBuilder().ComID(agendamentoId).Build();

            _agendamentoRepository.Setup(x => x.ValidaAgendamentoDuplicados(agendamentoDto.EstabelecimentoId, agendamentoId, agendamentoDto.DataAgendamento, agendamentoDto.DataFinalAgendamento)).ReturnsAsync(true);

            var retorno = _agendamentoService.Create(agendamentoDto);

            Assert.IsTrue(retorno.Result.StatusCode == (int)EStatusCode.ERRO_VALIDACAO);
            Assert.IsTrue(retorno.Result.Errors.Contains("Horário já possui agendamento!"));
            Assert.IsTrue(retorno.Result.Errors.Count == 1);
        }
Beispiel #2
0
        public void TestaCreateValido()
        {
            var agendamentoDto = new AgendamentoDtoBuilder().Build();

            _agendamentoRepository.Setup(x => x.ValidaAgendamentoDuplicados(agendamentoDto.EstabelecimentoId, agendamentoDto.AgendamentoId, agendamentoDto.DataAgendamento, agendamentoDto.DataFinalAgendamento)).ReturnsAsync(false);

            var retorno = _agendamentoService.Create(agendamentoDto);

            Assert.IsTrue(retorno.Result.StatusCode == (int)EStatusCode.OK);
            Assert.IsTrue(retorno.Result.Errors.Count == 0);
            Assert.IsNotNull(retorno.Result.Data);
            Assert.IsTrue(retorno.Result.Data.SituacaoId == (int)ESituacao.ATIVO);
        }
Beispiel #3
0
        public void TestaUpdateValido()
        {
            var agendamentoId  = 1;
            var agendamentoDto = new AgendamentoDtoBuilder().ComID(agendamentoId).Build();
            var agendamento    = new AgendamentoBuilder().ComID(agendamentoId).Build();

            _agendamentoRepository.Setup(x => x.ObterPorId(agendamentoId)).ReturnsAsync(agendamento);

            var retorno = _agendamentoService.Update(agendamentoDto);

            Assert.IsTrue(retorno.Result.StatusCode == (int)EStatusCode.OK);
            Assert.IsTrue(retorno.Result.Errors.Count == 0);
            Assert.IsNotNull(retorno.Result.Data);
        }