예제 #1
0
        public void DeveLancaExceptionDoPrazoParaAlteracaoDoAgendamento()
        {
            var lista = new List <Agenda>();

            lista.Add(new Agenda()
            {
                Id         = 1,
                Cliente    = repositoryCliente.Find(1),
                Data       = DateTime.Now,
                Modalidade = 60,
                Obs        = ""
            });


            queryAgendas = lista.AsQueryable();
            mockDbSetAgenda.As <IQueryable <Agenda> >().Setup(m => m.Provider).Returns(queryAgendas.Provider);
            mockDbSetAgenda.As <IQueryable <Agenda> >().Setup(m => m.Expression).Returns(queryAgendas.Expression);
            mockDbSetAgenda.As <IQueryable <Agenda> >().Setup(m => m.ElementType).Returns(queryAgendas.ElementType);
            mockDbSetAgenda.As <IQueryable <Agenda> >().Setup(m => m.GetEnumerator()).Returns(queryAgendas.GetEnumerator());

            mockRepositoryAgenda.Setup(m => m.Get).Returns(mockDbSetAgenda.Object);
            mockRepositoryAgenda.Setup(m => m.Find(It.IsAny <int>(), true)).Returns(queryAgendas.FirstOrDefault);



            Agenda agendaPut = new Agenda()
            {
                Id         = 1,
                Cliente    = repositoryCliente.Find(1),
                Data       = UtilsTest.AddDateAndHours(DateTime.Now, 5, 15),
                Modalidade = 30,
                Obs        = ""
            };


            AgendaService service = new AgendaService(mockRepositoryAgenda.Object, repositoryCliente);

            Assert.That(() => service.Put <AgendaValidator>(agendaPut), Throws.TypeOf <FluentValidation.ValidationException>());
        }