Esempio n. 1
0
        public void CreateAgendaRequestValidator_SalaHorarioNoCollision_ValidationOk()
        {
            var requests = new List <CreateAgendaRequest>();

            requests.Add(new CreateAgendaRequest
            {
                Titulo        = "Agendamento qualquer",
                HorarioInicio = new DateTime(2019, 1, 5),
                HorarioFim    = new DateTime(2019, 1, 11),
                SalaId        = 1
            });

            requests.Add(new CreateAgendaRequest
            {
                Titulo        = "Agendamento qualquer",
                HorarioInicio = new DateTime(2019, 1, 21),
                HorarioFim    = new DateTime(2019, 1, 25),
                SalaId        = 1
            });

            var validator = new CreateAgendaRequestValidator(agendaService, salaService, mapper);

            foreach (var item in requests)
            {
                Assert.IsTrue(validator.Validate(item).IsValid);
            }
        }
Esempio n. 2
0
        public void CreateAgendaRequestValidator_SalaDoesNotExist_ValidationFail()
        {
            var request = new CreateAgendaRequest
            {
                Titulo        = "Agendamento qualquer",
                HorarioInicio = new DateTime(2019, 08, 14),
                HorarioFim    = new DateTime(2019, 08, 19),
                SalaId        = -1
            };

            var validator = new CreateAgendaRequestValidator(agendaService, salaService, mapper);
            var result    = validator.Validate(request);

            Assert.IsFalse(result.IsValid);
        }
Esempio n. 3
0
        public void CreateAgendaRequestValidator_TituloNull_ValidationFail()
        {
            var request = new CreateAgendaRequest
            {
                Titulo        = "",
                HorarioInicio = new DateTime(2019, 08, 14),
                HorarioFim    = new DateTime(2019, 08, 15),
                SalaId        = 1
            };

            var validator = new CreateAgendaRequestValidator(agendaService, salaService, mapper);
            var result    = validator.Validate(request);

            Assert.IsFalse(result.IsValid);
        }