Exemplo n.º 1
0
        public void WeeklyEventOnEveryMonWedFriTest()
        {
            var aEvent = new Event()
            {
                ID = 1,
                Title = "Weekly on Monday, Wednesday, Friday",
                Frequency = 64,        // weekly on Monday, Wednesday, Friday
                DaysOfWeek = 42,      // every Mon, Wed and Fri
                StartDateTime = new DateTime(2013, 8, 2)
            };

            var schedule = new Schedule(aEvent);

            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 8, 2)));

            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 8, 3)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 8, 4)));

            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 8, 5)));

            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 8, 6)));

            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 8, 7)));

            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 8, 8)));

            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 8, 9)));

            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 8, 10)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 8, 11)));
        }
Exemplo n.º 2
0
        public void OneTimeOnlyTest2()
        {
            var laborDay = new DateTime(2012, 9, 1);

            var aEvent = new Event()
            {
                ID = 1,
                Title = "Labor Day Extravaganza",
                Frequency = 0,        // one-time only
                OneTimeOnlyEventDate = laborDay,
                MonthlyInterval = 0,  // not applicable
                DaysOfWeek = 0        // not applicable
            };

            var schedule = new Schedule(aEvent);

            var range = new DateRange()
            {
                StartDateTime = new DateTime(2012, 8, 1),
                EndDateTime = new DateTime(2012, 10, 1)
            };

            var occurrences = schedule.Occurrences(range);
            var count = 0;
            using (var items = occurrences.GetEnumerator())
            {
                while (items.MoveNext())
                    count++;
            }

            Assert.IsTrue(count > 0);
        }
Exemplo n.º 3
0
        public void WeeklyEventFirstDayOfWeekMonday()
        {
            var aEvent = new Event()
            {
                ID = 1,
                Title = "Every 2nd week. First day of week Monday",
                Frequency = 2,        // Weekly
                DaysOfWeek = 127,      // Every day
                RepeatInterval = 2,
                FirstDayOfWeek = Enums.DayOfWeekEnum.Mon,
                StartDateTime = new DateTime(2015, 1, 1)
            };

            var schedule = new Schedule(aEvent);

            Assert.IsTrue(schedule.IsOccurring(new DateTime(2015, 1, 1)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2015, 1, 2)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2015, 1, 3)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2015, 1, 4)));

            Assert.IsFalse(schedule.IsOccurring(new DateTime(2015, 1, 5)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2015, 1, 6)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2015, 1, 7)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2015, 1, 8)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2015, 1, 9)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2015, 1, 10)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2015, 1, 11)));

            Assert.IsTrue(schedule.IsOccurring(new DateTime(2015, 1, 12)));
        }
Exemplo n.º 4
0
        /// <summary>
        /// The canonical Critical Mass monthly bicycle ride
        /// </summary>
        public static void Run()
        {
            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("Running monthly scenario 1.");
            Console.WriteLine(Environment.NewLine);

            var aEvent = new Event()
            {
                ID = 1,
                Title = "Critical Mass",
                FrequencyTypeOptions = FrequencyTypeEnum.Monthly,
                MonthlyIntervalOptions = MonthlyIntervalEnum.Last,
                DaysOfWeekOptions = DayOfWeekEnum.Fri
            };

            var during = new DateRange()
            {
                StartDateTime = new DateTime(2013, 12, 1),
                EndDateTime = new DateTime(2013, 12, 31)
            };

            var schedule = new Schedule(aEvent);
            var dates = schedule.Occurrences(during);
            foreach (var date in dates)
            {
                Console.WriteLine(date.ToShortDateString());
            }

            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("Printed out all dates between {0} and {1}", 
                during.StartDateTime.ToShortDateString(), 
                during.EndDateTime.ToShortDateString());
        }
Exemplo n.º 5
0
        public void YearTest2()
        {
            var aEvent = new Event()
            {
                ID = 1,
                Title = "Event 2",
                FrequencyTypeOptions = FrequencyTypeEnum.Yearly,
                Anniversary = new Anniversary()
                {
                    Month = 9,
                    Day = 27
                }
            };

            var schedule = new Schedule(aEvent);
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2014, 9, 27)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2015, 9, 27)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2016, 9, 27)));

            var range = new DateRange()
            {
                StartDateTime = new DateTime(2012, 1, 1),
                EndDateTime = new DateTime(2016, 12, 31)
            };

            var occurrences = schedule.Occurrences(range);

            Assert.AreEqual(5, occurrences.Count());
            Assert.AreEqual(new DateTime(2012, 9, 27), occurrences.First());
            Assert.AreEqual(new DateTime(2016, 9, 27), occurrences.Last());
        }
Exemplo n.º 6
0
        public void AnniversaryTest2()
        {
            var anniversary = new Anniversary()
            {
                Day = 5,
                Month = 6
            };

            var aEvent = new Event()
            {
                ID = 1,
                Title = "Give Flowers to Wife",
                Frequency = 16, // yearly
                Anniversary = anniversary
            };

            var schedule = new Schedule(aEvent);
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2009, 6, 4)));

            var range = new DateRange()
            {
                StartDateTime = new DateTime(2010, 1, 1),
                EndDateTime = new DateTime(2020, 12, 31)
            };

            var occurrences = schedule.Occurrences(range).ToList();
            Assert.IsTrue(occurrences.Count.Equals(11));
        }
Exemplo n.º 7
0
        public void MonthTest1()
        {
            var aEvent = new Event()
            {
                ID = 1,
                Title = "Event 1",
                FrequencyTypeOptions = FrequencyTypeEnum.Monthly,
                MonthlyIntervalOptions = MonthlyIntervalEnum.EveryWeek,
                DaysOfWeekOptions = DayOfWeekEnum.Mon | DayOfWeekEnum.Fri
            };

            var range = new DateRange()
            {
                StartDateTime = new DateTime(2013, 1, 15),
                EndDateTime = new DateTime(2013, 4, 30)
            };

            var occurringDate = new DateTime(2013, 1, 21);

            var schedule = new Schedule(aEvent);
            Assert.IsTrue(schedule.IsOccurring(occurringDate));

            var previousOccurrence = schedule.PreviousOccurrence(occurringDate, range);
            Assert.AreEqual(new DateTime(2013, 1, 18), previousOccurrence.Value);

            var nextOccurrence = schedule.NextOccurrence(occurringDate, range);
            Assert.AreEqual(new DateTime(2013, 1, 25), nextOccurrence.Value);

            var occurrences = schedule.Occurrences(range);

            Assert.AreEqual(30, occurrences.Count());
            Assert.AreEqual(new DateTime(2013, 1, 18), occurrences.First());
            Assert.AreEqual(new DateTime(2013, 4, 29), occurrences.Last());
        }
        private static ISchedule GetSchedule()
        {
            var schedule = new Schedule();
            var firstExpression = BuildStreetCleaningTemporalExpression();
            var firstScheduledEvent = new Event()
            {
                ID = 1,
                Title = "Street Cleaning",
                DateRange = new DateRange()
                {
                    StartDateTime = new DateTime(2011, 3, 1, 0, 0, 0),
                    EndDateTime = new DateTime(2011, 10, 30, 18, 0, 0)
                }
            };

            var secondExpression = BuildWitchingHourPrepTemporalExpression();
            var secondScheduledEvent = new Event()
            {
                ID = 2,
                Title = "Witching Hour Preparation",
                DateRange = new DateRange()
                {
                    StartDateTime = new DateTime(2012, 10, 1, 0, 0, 0),
                    EndDateTime = new DateTime(2012, 10, 31, 0, 0, 0)
                }
            };

            schedule.Add(firstScheduledEvent, firstExpression);
            schedule.Add(secondScheduledEvent, secondExpression);
            return schedule;
        }
Exemplo n.º 9
0
        public static void Run()
        {
            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("Running daily scenario 1 with a StartDateTime value of 12/1/2013");
            Console.WriteLine(Environment.NewLine);

            var aEvent = new Event()
            {
                ID = 1,
                Title = "Event 1",
                Frequency = 1,        // daily
                MonthlyInterval = 0,  // not applicable
                DaysOfWeek = 127,     // every day of week
                StartDateTime = new DateTime(2013, 12, 1)
            };

            var during = new DateRange()
            {
                StartDateTime = new DateTime(2013, 12, 1),
                EndDateTime = new DateTime(2013, 12, 31)
            };

            var schedule = new Schedule(aEvent);
            var dates = schedule.Occurrences(during);
            foreach (var date in dates)
            {
                Console.WriteLine(date.ToShortDateString());
            }

            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("Printed out all dates between {0} and {1}",
                during.StartDateTime.ToShortDateString(),
                during.EndDateTime.ToShortDateString());
        }
Exemplo n.º 10
0
        public void LastOccurrenceTest1()
        {
            var aEvent = new Event()
            {
                ID = 1,
                Title = "Daily, 3 times",
                FrequencyTypeOptions = FrequencyTypeEnum.Daily,
                NumberOfOccurrences = 3,
                FirstDateTime = new DateTime(2013, 7, 29)
            };

            var schedule = new Schedule(aEvent);
            DateTime? endDate = schedule.GetLastOccurrenceDate();
            Assert.IsTrue(endDate == new DateTime(2013, 7, 31));
        }
Exemplo n.º 11
0
        public void LastOccurrenceTest2()
        {
            var aEvent = new Event()
            {
                ID = 2,
                Title = "Every 2 days, 3 times",
                FrequencyTypeOptions = FrequencyTypeEnum.Daily,
                NumberOfOccurrences = 3,
                DayInterval = 2,
                FirstDateTime = new DateTime(2013, 7, 29)
            };

            var schedule = new Schedule(aEvent);
            DateTime? endDate = schedule.GetLastOccurrenceDate();
            Assert.IsTrue(endDate == new DateTime(2013, 8, 2));
        }
Exemplo n.º 12
0
        public void LastOccurrenceTest3()
        {
            var aEvent = new Event()
            {
                ID = 3,
                Title = "Weekly on Monday, Tuesday, 3 times",
                FrequencyTypeOptions = FrequencyTypeEnum.Weekly,
                DaysOfWeek = 6,
                NumberOfOccurrences = 3,
                FirstDateTime = new DateTime(2013, 7, 29)
            };

            var schedule = new Schedule(aEvent);
            DateTime? endDate = schedule.GetLastOccurrenceDate();
            Assert.IsTrue(endDate == new DateTime(2013, 8, 5));
        }
Exemplo n.º 13
0
        public void LastOccurrenceTest10()
        {
            var aEvent = new Event()
            {
                ID = 10,
                Title = "Annually on July 29, 2 times",
                FrequencyTypeOptions = FrequencyTypeEnum.Yearly,
                Anniversary = new Anniversary { Day = 29, Month = 7 },
                StartDateTime = new DateTime(2013, 7, 29)
            };
            aEvent.SetEndDateWithNumberOfOccurrences(2);

            var schedule = new Schedule(aEvent);
            DateTime? endDate = schedule.GetLastOccurrenceDate();
            Assert.IsTrue(endDate == new DateTime(2014, 7, 29));
        }
Exemplo n.º 14
0
        public void DailyEventTest1()
        {
            var aEvent = new Event()
            {
                ID = 1,
                Title = "Event 1",
                Frequency = 1,        // daily
                MonthlyInterval = 0,  // not applicable
                DaysOfWeek = 127      // every day of week
            };

            var schedule = new Schedule(aEvent);

            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 2, 10)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 4, 29)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 11, 17)));
        }
Exemplo n.º 15
0
        public void OneTimeOnlyTest1()
        {
            var laborDay = new DateTime(2012, 9, 1);

            var aEvent = new Event()
            {
                ID = 1,
                Title = "Labor Day Extravaganza",
                Frequency = 0,        // one-time only
                OneTimeOnlyEventDate = laborDay,
                MonthlyInterval = 0,  // not applicable
                DaysOfWeek = 0        // not applicable
            };

            var schedule = new Schedule(aEvent);
            Assert.IsTrue(schedule.IsOccurring(laborDay));
        }
Exemplo n.º 16
0
        public void DailyEventTest3()
        {
            var aEvent = new Event()
            {
                ID = 1,
                Title = "Event 3",
                FrequencyTypeOptions = FrequencyTypeEnum.Daily,
                RepeatInterval = 4,
                StartDateTime = new DateTime(2013, 1, 3)
            };

            var schedule = new Schedule(aEvent);

            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 1, 7)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 1, 12)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 2, 4)));
        }
Exemplo n.º 17
0
        public void LastOccurrenceTest4()
        {
            var aEvent = new Event()
            {
                ID = 4,
                Title = "Every 2 weeks on Monday, Tuesday, Wednesday, 10 times",
                FrequencyTypeOptions = FrequencyTypeEnum.Weekly,
                DaysOfWeek = 14,
                WeeklyInterval = 2,
                NumberOfOccurrences = 10,
                FirstDateTime = new DateTime(2013, 7, 29)
            };

            var schedule = new Schedule(aEvent);
            DateTime? endDate = schedule.GetLastOccurrenceDate();
            Assert.IsTrue(endDate == new DateTime(2013, 9, 9));
        }
Exemplo n.º 18
0
        public void DailyEventTest2()
        {
            var aEvent = new Event()
            {
                ID = 1,
                Title = "Event 2",
                RangeInYear = null,
                Frequency = 1,        // daily
                MonthlyInterval = 0,  // not applicable
                DaysOfWeek = 16       // Thursday
            };

            var schedule = new Schedule(aEvent);

            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 2, 14)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 4, 25)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 11, 7)));
        }
Exemplo n.º 19
0
        public void TestMontlyCalendar()
        {
            var aEvent = new Event()
            {
                ID = 1,
                Title = "Critical Mass",
                FrequencyTypeOptions = FrequencyTypeEnum.Monthly,
                MonthlyIntervalOptions = MonthlyIntervalEnum.First,
                DaysOfWeekOptions = DayOfWeekEnum.Fri
            }; var schedule = new Schedule(aEvent);
            var range = new DateRange()
            {
                StartDateTime = DateTime.Now,
                EndDateTime = DateTime.Now.AddYears(1)
            };
            var occurrences = schedule.Occurrences(range);

        }
Exemplo n.º 20
0
        public void AnniversaryTest1()
        {
            var anniversary = new Anniversary()
            {
                Day = 1,
                Month = 8
            };

            var aEvent = new Event()
            {
                ID = 1,
                Title = "Daughter's Birthday",
                Frequency = 16, // yearly
                Anniversary = anniversary
            };

            var schedule = new Schedule(aEvent);
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2008, 8, 1)));
        }
Exemplo n.º 21
0
        public void YearTest1()
        {
            var aEvent = new Event()
            {
                ID = 1,
                Title = "Event 1",
                FrequencyTypeOptions = FrequencyTypeEnum.Yearly,
                Anniversary = new Anniversary()
                {
                    Month = 9,
                    Day = 27
                }
            };

            var schedule = new Schedule(aEvent);
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2014, 9, 27)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2015, 9, 27)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2016, 9, 27)));
        }
Exemplo n.º 22
0
        public void YearTest3()
        {
            var aEvent = new Event()
            {
                ID = 1,
                Title = "Event 3",
                FrequencyTypeOptions = FrequencyTypeEnum.Yearly,
                StartDateTime = new DateTime(2013, 9, 27),
                RepeatInterval = 2,
                Anniversary = new Anniversary()
                {
                    Month = 9,
                    Day = 27
                }
            };

            var schedule = new Schedule(aEvent);
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2014, 9, 27)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2015, 9, 27)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2016, 9, 27)));
        }
Exemplo n.º 23
0
        public void WeeklyEventTest2()
        {
            var aEvent = new Event()
            {
                ID = 1,
                Title = "Every Mon Wed Fri",
                Frequency = 2,        // weekly
                MonthlyInterval = 0,  // not applicable
                DaysOfWeek = 42      // every Mon, Wed and Fri
            };

            var schedule = new Schedule(aEvent);

            Assert.IsTrue(schedule.IsOccurring(new DateTime(2016, 2, 8)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2015, 11, 25)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2014, 6, 16)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2012, 10, 12)));

            Assert.IsFalse(schedule.IsOccurring(new DateTime(2012, 8, 9))); // Thu
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 2, 5))); // Tue
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2014, 7, 5))); // Sat
        }
Exemplo n.º 24
0
        public void WeeklyEventTest1()
        {
            var aEvent = new Event()
            {
                ID = 1,
                Title = "Every Mon and Wed",
                Frequency = 2,        // weekly
                MonthlyInterval = 0,  // not applicable
                DaysOfWeek = 10      // every Mon and Wed
            };

            var schedule = new Schedule(aEvent);

            // NOTE: If daily then date range doesn't matter
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2016, 2, 8)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2015, 11, 25)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2014, 6, 16)));

            Assert.IsFalse(schedule.IsOccurring(new DateTime(2012, 8, 9))); // Thu
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 2, 5))); // Tue
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2014, 7, 5))); // Sat
        }
Exemplo n.º 25
0
        public void MonthTest2()
        {
            var aEvent = new Event()
            {
                ID = 1,
                Title = "Event 2",
                FrequencyTypeOptions = FrequencyTypeEnum.Monthly,
                RepeatInterval = 2,
                MonthlyIntervalOptions = MonthlyIntervalEnum.Last,
                DaysOfWeekOptions = DayOfWeekEnum.Mon | DayOfWeekEnum.Fri,
                StartDateTime = new DateTime(2013, 1, 15)
            };

            var range = new DateRange()
            {
                StartDateTime = aEvent.StartDateTime.Value,
                EndDateTime = new DateTime(2013, 4, 30)
            };

            var nonOccurringDate = new DateTime(2013, 1, 29);

            var schedule = new Schedule(aEvent);
            Assert.IsFalse(schedule.IsOccurring(nonOccurringDate));

            var previousOccurrence = schedule.PreviousOccurrence(nonOccurringDate, range);
            Assert.AreEqual(new DateTime(2013, 1, 28), previousOccurrence.Value);

            var nextOccurrence = schedule.NextOccurrence(nonOccurringDate, range);
            Assert.AreEqual(new DateTime(2013, 3, 25), nextOccurrence.Value);

            var occurrences = schedule.Occurrences(range);

            Assert.AreEqual(4, occurrences.Count());
            Assert.AreEqual(new DateTime(2013, 1, 25), occurrences.First());
            Assert.AreEqual(new DateTime(2013, 3, 29), occurrences.Last());
        }
Exemplo n.º 26
0
        public void WeeklyEventTest3()
        {
            var aEvent = new Event()
            {
                ID = 1,
                Title = "Every 2nd week on Mon Wed Fri",
                Frequency = 2,        // weekly
                MonthlyInterval = 0,  // not applicable
                DaysOfWeek = 44,      // every Tue, Wed and Fri
                WeeklyInterval = 2, // every 2nd week
                FirstDateTime = new DateTime(2013, 1, 1) // start date on a Tue
            };

            var schedule = new Schedule(aEvent);

            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 1, 1)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 1, 15)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 2, 12)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 12, 17)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2014, 1, 14)));

            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 1, 8))); // 1st week
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 1, 14))); // 2nd week but Mon
        }
Exemplo n.º 27
0
        public void LastOccurrenceTest5()
        {
            var aEvent = new Event()
            {
                ID = 5,
                Title = "Monthly on day 29, 3 times",
                FrequencyTypeOptions = FrequencyTypeEnum.Monthly,
                DayOfMonth = 29,
                NumberOfOccurrences = 3,
                FirstDateTime = new DateTime(2013, 7, 29)
            };

            var schedule = new Schedule(aEvent);
            DateTime? endDate = schedule.GetLastOccurrenceDate();
            Assert.IsTrue(endDate == new DateTime(2013, 9, 29));
        }
Exemplo n.º 28
0
        public void LastOccurrenceTest11()
        {
            var aEvent = new Event()
            {
                ID = 10,
                Title = "Every 2 years on July 29, 2 times",
                FrequencyTypeOptions = FrequencyTypeEnum.Yearly,
                NumberOfOccurrences = 2,
                YearInterval = 2,
                Anniversary = new Anniversary { Day = 29, Month = 7 },
                FirstDateTime = new DateTime(2013, 7, 29)
            };

            var schedule = new Schedule(aEvent);
            DateTime? endDate = schedule.GetLastOccurrenceDate();
            Assert.IsTrue(endDate == new DateTime(2015, 7, 29));
        }
Exemplo n.º 29
0
        public void LastOccurrenceTest9()
        {
            var aEvent = new Event()
            {
                ID = 9,
                Title = "Every 2 months on the last Monday, 3 times",
                FrequencyTypeOptions = FrequencyTypeEnum.Monthly,
                DaysOfWeek = 2,
                NumberOfOccurrences = 3,
                MonthInterval = 2,
                MonthlyIntervalOptions = MonthlyIntervalEnum.Last,
                FirstDateTime = new DateTime(2013, 7, 29)
            };

            var schedule = new Schedule(aEvent);
            DateTime? endDate = schedule.GetLastOccurrenceDate();
            Assert.IsTrue(endDate == new DateTime(2013, 11, 25));
        }
Exemplo n.º 30
0
        public void DailyEventTest5()
        {
            var aEvent = new Event()
            {
                ID = 5,
                Title = "Event 5",
                FrequencyTypeOptions = FrequencyTypeEnum.Daily,
                RepeatInterval = 1,
                StartDateTime = new DateTime(2013, 8, 8)
            };

            var schedule = new Schedule(aEvent);

            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 8, 5)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 8, 6)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 8, 7)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 8, 8)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 8, 9)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 8, 10)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 8, 11)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 8, 12)));
        }