コード例 #1
0
        public void Schedule_CreatedWithInfiniteRecurrence_EffectiveEndDateIsNull()
        {
            // Create a daily recurring calendar that has no end date.
            var schedule = ScheduleTestHelper.GetScheduleWithDailyRecurrence(null, null, new TimeSpan(1, 0, 0), null);

            schedule.EnsureEffectiveStartEndDates();

            Assert.That.AreEqualDate(null, schedule.EffectiveEndDate);
        }
コード例 #2
0
        public void Schedule_CreatedWithFiniteDateRecurrence_EffectiveEndDateMatchesRecurrenceEndDate()
        {
            // Create a daily recurring calendar that has an end date of today +3 months.
            var endDate = RockDateTime.Now.AddMonths(3);

            var schedule = ScheduleTestHelper.GetScheduleWithDailyRecurrence(endDate: endDate, eventDuration: null);

            Assert.That.AreEqualDate(schedule.EffectiveEndDate, endDate.Date);
        }
コード例 #3
0
        public void Schedule_CreatedWithExcessiveFiniteCountRecurrence_EffectiveEndDateIsUndefined()
        {
            var occurrences = 1000;

            // Create a daily recurring calendar that has X occurrences, including today.
            var schedule = ScheduleTestHelper.GetScheduleWithDailyRecurrence(startDateTime: null, occurrenceCount: occurrences);

            Assert.That.AreEqualDate(null, schedule.EffectiveEndDate);
        }
コード例 #4
0
        public void Schedule_CreatedWithFiniteCountRecurrence_EffectiveEndDateMatchesNthOccurrence()
        {
            var occurrences = 10;

            // Create a daily recurring calendar that has X occurrences, including today.
            var endDate = RockDateTime.Now.AddDays(occurrences - 1);

            var schedule = ScheduleTestHelper.GetScheduleWithDailyRecurrence(startDateTime: null, occurrenceCount: occurrences);

            Assert.That.AreEqualDate(schedule.EffectiveEndDate, endDate.Date);
        }
コード例 #5
0
        public void Schedule_SingleDayEventWithInfiniteRecurrencePattern_GetOccurrencesObservesRequestedEndDate()
        {
            var schedule = ScheduleTestHelper.GetScheduleWithDailyRecurrence(endDate: null, eventDuration: null);

            var endDate = RockDateTime.Now.Date.AddMonths(3);

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

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

            // End date is at 12am, so the last occurrence of the event will land on the preceding day.
            Assert.That.AreEqualDate(endDate, scheduleDates.LastOrDefault().Period.StartTime.Date.AddDays(1));
        }
コード例 #6
0
        public void Schedule_WithOneTimeMultiDayEvent_HasEffectiveEndDateOnLastDayOfEvent()
        {
            var singleDayEvent = ScheduleTestHelper.GetCalendarEvent(GetFirstTestScheduleDate(), new TimeSpan(24, 0, 0));

            var schedule = ScheduleTestHelper.GetSchedule(ScheduleTestHelper.GetCalendar(singleDayEvent));

            var endDateExpected = _specificDates.FirstOrDefault().AddDays(1);

            var endDateReturned = schedule.EffectiveEndDate;

            Assert.That.IsNotNull(endDateReturned);
            Assert.That.AreEqualDate(endDateExpected, endDateReturned.Value.Date, "Unexpected value for EffectiveEndDate.");
        }
コード例 #7
0
        public void Schedule_UpdatedWithSpecificDates_EffectiveEndDateIsLastSpecifiedDate()
        {
            // Create a daily recurring calendar that has an end date of today +3 months.
            var scheduleEndDate = RockDateTime.Now.AddMonths(3);

            var schedule = ScheduleTestHelper.GetScheduleWithDailyRecurrence(endDate: scheduleEndDate, eventDuration: null);

            Assert.That.AreEqualDate(scheduleEndDate, schedule.EffectiveEndDate);

            // Modify the Schedule to use a set of discrete dates and verify that the EffectiveEndDate is adjusted correctly.
            var serializer = new CalendarSerializer(_calendarSpecificDates);

            schedule.iCalendarContent = serializer.SerializeToString();

            schedule.EnsureEffectiveStartEndDates();

            var specificEndDate = _specificDates.Last();

            Assert.That.AreEqualDate(specificEndDate, schedule.EffectiveEndDate);
        }
コード例 #8
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);
        }
コード例 #9
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);
        }