Example #1
0
        public void GetById()
        {
            TimeSlot expectedEntity = new TimeSlot();
            repository.Save(expectedEntity);

            Entity resultEntity = repository.GetById(expectedEntity.Id);

            Assert.AreEqual(expectedEntity, resultEntity);
        }
Example #2
0
        public void Delete()
        {
            TimeSlot expectedEntity1 = new TimeSlot();
            repository.Save(expectedEntity1);

            repository.Delete(expectedEntity1);

            IList<Entity> resultEntities = repository.GetAll().ToList<Entity>();
            Assert.AreEqual(0, resultEntities.Count);
        }
        public void ReturnsTrueIfThereIsAnHolidayOnHours()
        {
            TimeSlot slot1 = new TimeSlot { BeginHour = new TimeSpan(11,0,0), EndHour = new TimeSpan(13,0,0) };
            TimeSlot slot2 = new TimeSlot { BeginHour = new TimeSpan(13,0,0), EndHour = new TimeSpan(15,0,0) };
            TimeSlot slot3 = new TimeSlot { BeginHour = new TimeSpan(12,30,0), EndHour = new TimeSpan(13,30,0) };
            DateTime dateTime = new DateTime(2013, 07, 12);
            Holiday holiday = new Holiday { Day = dateTime, BeginHour = new TimeSpan(12,0,0), EndHour = new TimeSpan(14,0,0)};
            holidayRepository.Save(holiday);

            Assert.IsTrue(holidayRepository.ThereIsAnHolidayAtTheseHours(dateTime, slot1.BeginHour, slot1.EndHour));
            Assert.IsTrue(holidayRepository.ThereIsAnHolidayAtTheseHours(dateTime, slot2.BeginHour, slot2.EndHour));
            Assert.IsTrue(holidayRepository.ThereIsAnHolidayAtTheseHours(dateTime, slot3.BeginHour, slot3.EndHour));
        }
Example #4
0
 public void InitializeCorrectlyInitialize()
 {
     TimeSpan beginHour = new TimeSpan(0, 9, 30, 0);
     TimeSpan endHour = new TimeSpan(0, 10, 30, 0);
     TimeSlot timeSlot = new TimeSlot()
                             {
                                 BeginHour = beginHour,
                                 EndHour = endHour,
                                 DayOfWeek = DayOfWeek.Monday,
                             };
     Assert.AreEqual(beginHour, timeSlot.BeginHour);
     Assert.AreEqual(endHour, timeSlot.EndHour);
     Assert.AreEqual(DayOfWeek.Monday, timeSlot.DayOfWeek);
 }
        public void CreateADate()
        {
            int timeSlotId = 1;
            int contactId = 2;
            Contact contact = new Contact(){Id = contactId,};
            TimeSlot timeSlot = new TimeSlot(){Id = timeSlotId};
            DateTime dateTime = DateTime.Now;
            contactRepositoryMock.Setup(crm => crm.GetById(contactId)).Returns(contact);
            timeSlotRepositoryMock.Setup(tsrm => tsrm.GetById(timeSlotId)).Returns(timeSlot);
            dateRepositoryMock.Setup(drm => drm.Save(It.Is<Date>(d => d.Contact == contact && d.TimeSlot == timeSlot && d.Day == dateTime)));

            Date date = Controller.CreateDate(timeSlotId, contactId, dateTime);

            contactRepositoryMock.Verify(crm => crm.GetById(contactId), Times.Once());
            timeSlotRepositoryMock.Verify(tsrm => tsrm.GetById(timeSlotId), Times.Once());
            dateRepositoryMock.Verify(drm => drm.Save(It.Is<Date>(d => d.Contact == contact && d.TimeSlot == timeSlot && d.Day == dateTime)), Times.Once());
            Assert.AreEqual(contact, date.Contact);
            Assert.AreEqual(timeSlot, date.TimeSlot);
            Assert.AreEqual(dateTime, date.Day);
            Assert.IsTrue(date.IsConfirmed);
            Assert.IsNotNull(date.ConfirmationId);
        }
 private Date CreateDate(DateTime dateTime, TimeSlot timeSlot)
 {
     Date date = new Date
         {
             ConfirmationId = ConfirmationId,
             Contact = contact,
             IsConfirmed = false,
             Day = dateTime,
             TimeSlot = timeSlot
         };
     dateRepository.Save(date);
     return date;
 }
Example #7
0
        public void Save()
        {
            TimeSlot entity = new TimeSlot();

            repository.Save(entity);

            Assert.IsNotNull(entity.Id);
        }
Example #8
0
        public void Update()
        {
            TimeSlot entity = new TimeSlot();

            repository.Save(entity);

            entity.DayOfWeek = DayOfWeek.Saturday;

            repository.Save(entity);

            Assert.AreEqual(DayOfWeek.Saturday, entity.DayOfWeek);
        }