Exemple #1
0
        public void Schedule_GetOccurrencesForPeriodStartingDuringMultiDayEvent_DoesNotIncludeInProgressEvent()
        {
            var inProgressEventStartDate = RockDateTime.Today.AddDays(-1);

            // Get a calendar that includes a multi-day event that started yesterday and repeats every 7 days.
            var calendar = ScheduleTestHelper.GetCalendar(ScheduleTestHelper.GetCalendarEvent(inProgressEventStartDate, new TimeSpan(25, 0, 0)),
                                                          ScheduleTestHelper.GetDailyRecurrencePattern(null, null, 7));

            var schedule = ScheduleTestHelper.GetSchedule(calendar);

            // Get events for the next 3 months, starting from today.
            var endRequestDate = RockDateTime.Now.Date.AddMonths(3);

            var scheduleDates = schedule.GetICalOccurrences(RockDateTime.Now, endRequestDate);

            Assert.That.IsNotNull(scheduleDates.FirstOrDefault());

            // Verify that the result does not include the event that started yesterday and is in progress today.
            var firstEvent = scheduleDates.FirstOrDefault();

            Assert.That.AreNotEqualDate(inProgressEventStartDate, firstEvent.Period.StartTime.Date);
        }
Exemple #2
0
        public void Schedule_GetOccurrencesForPeriodEndingDuringMultiDayEvent_IncludesInProgressEvent()
        {
            var eventStartDate = RockDateTime.Now.AddDays(-1);

            // Get a calendar that includes a multi-day event that started yesterday and repeats daily.
            var calendar = ScheduleTestHelper.GetCalendar(ScheduleTestHelper.GetCalendarEvent(eventStartDate, new TimeSpan(25, 0, 0)),
                                                          ScheduleTestHelper.GetDailyRecurrencePattern(null, null, 1));

            var schedule = ScheduleTestHelper.GetSchedule(calendar);

            // Get events for the next 7 days (inclusive), starting from today.
            var lastRequestDate = RockDateTime.Now.Date.AddDays(8).AddMilliseconds(-1);

            // Get occurrences for the schedule from today.
            var scheduleDates = schedule.GetICalOccurrences(RockDateTime.Now, lastRequestDate);

            Assert.That.IsNotNull(scheduleDates.FirstOrDefault());

            var lastEvent = scheduleDates.LastOrDefault();

            // Verify that the result includes the event that starts on the last day of the request period but ends on the following day.
            Assert.That.AreEqualDate(lastRequestDate, lastEvent.Period.StartTime.Date);
        }