當前位置: 首頁>>代碼示例>>C#>>正文


C# Schedule.IsOccurring方法代碼示例

本文整理匯總了C#中ScheduleWidget.ScheduledEvents.Schedule.IsOccurring方法的典型用法代碼示例。如果您正苦於以下問題:C# Schedule.IsOccurring方法的具體用法?C# Schedule.IsOccurring怎麽用?C# Schedule.IsOccurring使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ScheduleWidget.ScheduledEvents.Schedule的用法示例。


在下文中一共展示了Schedule.IsOccurring方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: YearTest2

        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());
        }
開發者ID:Rachitman,項目名稱:ScheduleWidget,代碼行數:31,代碼來源:YearTests.cs

示例2: WeeklyEventOnEveryMonWedFriTest

        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)));
        }
開發者ID:Rachitman,項目名稱:ScheduleWidget,代碼行數:31,代碼來源:WeeklyTests.cs

示例3: RecurringScheduleIsOccurringTest1

 public void RecurringScheduleIsOccurringTest1()
 {
     var aEvent = CreateRecurringEvent();
     var schedule = new Schedule(aEvent);
     Assert.IsNotNull(schedule);
     Assert.IsTrue(schedule.IsOccurring(new DateTime(2012, 10, 1)));
     Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 1, 18)));
 }
開發者ID:willemda,項目名稱:ScheduleWidget,代碼行數:8,代碼來源:BasicTest.cs

示例4: EventOptionsIndependenceDayTest

        public void EventOptionsIndependenceDayTest()
        {
            var holidays = GetHolidays();
            var aEvent = CreateStreetCleaningEvent();
            var schedule = new Schedule(aEvent, holidays);

            Assert.IsNotNull(holidays);
            Assert.IsNotNull(aEvent);
            Assert.IsNotNull(schedule);
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2012, 7, 4)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2016, 7, 4)));
        }
開發者ID:hoopkjaz,項目名稱:ScheduleWidget,代碼行數:12,代碼來源:EventOptionsTests.cs

示例5: SimpleScheduleIsOccurringTest2

 public void SimpleScheduleIsOccurringTest2()
 {
     var aEvent = CreateTodayEvent();
     var schedule = new Schedule(aEvent);
     Assert.IsNotNull(schedule);
     Assert.IsFalse(schedule.IsOccurring(DateTime.Today.AddDays(1)));
 }
開發者ID:hoopkjaz,項目名稱:ScheduleWidget,代碼行數:7,代碼來源:BasicTest.cs

示例6: EventOptionsLaborDayTest

        public void EventOptionsLaborDayTest()
        {
            var holidays = GetHolidays();
            var aEvent = CreateStreetCleaningEvent();
            var schedule = new Schedule(aEvent, holidays);

            Assert.IsNotNull(holidays);
            Assert.IsNotNull(aEvent);
            Assert.IsNotNull(schedule);

            // Labor Day
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2012, 9, 3)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 9, 2)));
            // Third Monday in Sep
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2014, 9, 15)));
        }
開發者ID:hoopkjaz,項目名稱:ScheduleWidget,代碼行數:16,代碼來源:EventOptionsTests.cs

示例7: AnniversaryTest2

        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));
        }
開發者ID:hoopkjaz,項目名稱:ScheduleWidget,代碼行數:28,代碼來源:AnniversaryTests.cs

示例8: MonthTest1

        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());
        }
開發者ID:Rachitman,項目名稱:ScheduleWidget,代碼行數:34,代碼來源:MonthTests.cs

示例9: SimpleScheduleIsOccurringTest1

 public void SimpleScheduleIsOccurringTest1()
 {
     var aEvent = CreateTodayEvent();
     var schedule = new Schedule(aEvent);
     Assert.IsNotNull(schedule);
     Assert.IsTrue(schedule.IsOccurring(DateTime.Today));
 }
開發者ID:hoopkjaz,項目名稱:ScheduleWidget,代碼行數:7,代碼來源:BasicTest.cs

示例10: DailyEventTest1

        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)));
        }
開發者ID:raghav-khunger,項目名稱:ScheduleWidget,代碼行數:17,代碼來源:DailyTests.cs

示例11: DailyEventTest3

        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)));
        }
開發者ID:Rachitman,項目名稱:ScheduleWidget,代碼行數:17,代碼來源:DailyTests.cs

示例12: DailyEventTest2

        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)));
        }
開發者ID:raghav-khunger,項目名稱:ScheduleWidget,代碼行數:18,代碼來源:DailyTests.cs

示例13: YearTest1

        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)));
        }
開發者ID:Rachitman,項目名稱:ScheduleWidget,代碼行數:19,代碼來源:YearTests.cs

示例14: SimpleExcludedDayTest2

        public void SimpleExcludedDayTest2()
        {
            // first Mon of Sep
            var excludedDay = new DateTime(2012, 9, 3);
            var aEvent = CreateRecurringEvent();
            var excludedDates = new List<DateTime>()
            {
                excludedDay
            };

            var schedule = new Schedule(aEvent, excludedDates);
            Assert.IsNotNull(schedule);
            Assert.IsFalse(schedule.IsOccurring(excludedDay));
        }
開發者ID:willemda,項目名稱:ScheduleWidget,代碼行數:14,代碼來源:SimpleDateTest.cs

示例15: FineGrainedRangeInYearTest

        public void FineGrainedRangeInYearTest()
        {
            var holidays = GetHolidays();
            var aEvent = CreateFineGrainedStreetCleaningEvent();
            var schedule = new Schedule(aEvent, holidays);

            Assert.IsNotNull(holidays);
            Assert.IsNotNull(aEvent);
            Assert.IsNotNull(schedule);

            Assert.IsTrue(schedule.IsOccurring(new DateTime(2016, 6, 20)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2016, 5, 16)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2016, 6, 6)));

            Assert.IsTrue(schedule.IsOccurring(new DateTime(2018, 10, 15)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2018, 11, 5)));

            Assert.IsFalse(schedule.IsOccurring(new DateTime(2018, 1, 1)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2018, 2, 5)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2018, 3, 19)));

            Assert.IsFalse(schedule.IsOccurring(new DateTime(2014, 11, 1)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2014, 12, 1)));
        }
開發者ID:hoopkjaz,項目名稱:ScheduleWidget,代碼行數:24,代碼來源:RangeEachYearTests.cs


注:本文中的ScheduleWidget.ScheduledEvents.Schedule.IsOccurring方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。