コード例 #1
0
ファイル: HolidayHaveTo.cs プロジェクト: QTruffart/OsteoYoga
        public void InitializeCorrectlyInitialize()
        {
            DateTime day = new DateTime();
            TimeSpan begin = new TimeSpan();
            TimeSpan end = new TimeSpan();

            Holiday holiday = new Holiday {Day = day, BeginHour = begin, EndHour = end};

            Assert.AreEqual(day, holiday.Day);
            Assert.AreEqual(begin, holiday.BeginHour);
            Assert.AreEqual(end, holiday.EndHour);
        }
コード例 #2
0
        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));
        }
コード例 #3
0
ファイル: HolidayHaveTo.cs プロジェクト: QTruffart/OsteoYoga
 public void RenderToString()
 {
     DateTime day = new DateTime(2013, 07, 18);
     TimeSpan begin = new TimeSpan(8, 0, 0);
     TimeSpan end = new TimeSpan(16, 0, 0);
     Holiday holiday = new Holiday
     {
         Day = day,
         BeginHour = begin,
         EndHour = end
     };
     Assert.AreEqual(day.ToString("dd/MM/yyyy") +
                     LoginResource.From + new DateTime(begin.Ticks).ToString("HH:mm") +
                     HolidayResource.To + new DateTime(end.Ticks).ToString("HH:mm"), holiday.ToString());
 }
コード例 #4
0
        public void ReturnsFutureHolidays()
        {
            DateTime dateTime = new DateTime(2013,07,12);
            Holiday holiday1 = new Holiday {Day = dateTime.AddDays(-1)};
            Holiday holiday2 = new Holiday {Day = dateTime};
            Holiday holiday3 = new Holiday {Day = dateTime.AddDays(1)};
            holidayRepository.Save(holiday1);
            holidayRepository.Save(holiday2);
            holidayRepository.Save(holiday3);

            IList<Holiday> slots = holidayRepository.GetFutureHoliday(dateTime);

            Assert.AreEqual(2, slots.Count);
            CollectionAssert.Contains(slots.ToList(), holiday2);
            CollectionAssert.Contains(slots.ToList(), holiday3);
        }
コード例 #5
0
        public PartialViewResult AddAnHoliday(DateTime dateTime, string hours)
        {
            if (!SessionHelper.GetInstance().AdminConnected)
            {
                return PartialView("/Views/Administration/PassAdmin.cshtml");
            }
            IList<Date> datesOfTheDay = DateRepository.GetByDay(dateTime);
            TimeSpan beginHour = ToTimeSpan(hours.Split('-')[0]);
            TimeSpan endHour = ToTimeSpan(hours.Split('-')[1]);

            if (datesOfTheDay.Any(dod => IsContainedBy(beginHour,endHour,dod.TimeSlot.BeginHour, dod.TimeSlot.EndHour)))
            {
                ViewBag.Result = HolidayResource.DateTakenAtThisDate;
            }
            else
            {
                Holiday holiday = new Holiday { Day = dateTime, BeginHour = beginHour, EndHour = endHour};
                HolidayRepository.Save(holiday);
                ViewBag.Result = HolidayResource.HolidayTaken;
            }

            return PartialView("HolidayCreated");
        }
コード例 #6
0
        public void CancelAnHoliday()
        {
            const int id = 1;
            Holiday holiday = new Holiday();
            holidayRepositoryMock.Setup(hrm => hrm.GetById(id)).Returns(holiday);

            PartialViewResult view = Controller.CancelAnHoliday(id);

            holidayRepositoryMock.Verify(hrm => hrm.Delete(holiday), Times.Once());
            Assert.AreEqual("HolidayCancelled", view.ViewName);
            Assert.AreEqual(HolidayResource.HolidayCancelled, view.ViewBag.Result);
            Assert.AreEqual(holiday, view.Model);
        }