Esempio n. 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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 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);
        }
Esempio n. 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));
        }
Esempio n. 6
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);
        }