当前位置: 首页>>代码示例>>C#>>正文


C# Schedule.PreviousOccurrence方法代码示例

本文整理汇总了C#中ScheduleWidget.ScheduledEvents.Schedule.PreviousOccurrence方法的典型用法代码示例。如果您正苦于以下问题:C# Schedule.PreviousOccurrence方法的具体用法?C# Schedule.PreviousOccurrence怎么用?C# Schedule.PreviousOccurrence使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ScheduleWidget.ScheduledEvents.Schedule的用法示例。


在下文中一共展示了Schedule.PreviousOccurrence方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: EventOptionsPreviousOccurrenceTest

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

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

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

            foreach (var item in schedule.Occurrences(range))
            {
                System.Diagnostics.Debug.WriteLine(item);
            }

            var prev = schedule.PreviousOccurrence(new DateTime(2016, 6, 6));
            Assert.IsTrue(prev.Equals(new DateTime(2016, 5, 16)));
            Assert.IsFalse(prev.Equals(new DateTime(2016, 6, 6)));
            Assert.IsFalse(prev.Equals(new DateTime(2016, 6, 20)));
        }
开发者ID:hoopkjaz,项目名称:ScheduleWidget,代码行数:26,代码来源:EventOptionsTests.cs

示例3: RecurringSchedulePreviousOccurrenceTest1

 public void RecurringSchedulePreviousOccurrenceTest1()
 {
     var aEvent = CreateRecurringEvent();
     var schedule = new Schedule(aEvent);
     Assert.IsNotNull(schedule);
     var previousOccurrence = schedule.PreviousOccurrence(new DateTime(2013, 1, 2));
     Assert.IsFalse(previousOccurrence == new DateTime(2012, 12, 17));
     Assert.IsTrue(previousOccurrence == new DateTime(2012, 12, 19));
 }
开发者ID:hoopkjaz,项目名称:ScheduleWidget,代码行数:9,代码来源:BasicTest.cs

示例4: StreetCleaningPreviousOccurrenceTest

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

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

        var prev = schedule.PreviousOccurrence(new DateTime(2016, 6, 6));
        Assert.IsTrue(prev.Equals(new DateTime(2016, 5, 16)));
        Assert.IsFalse(prev.Equals(new DateTime(2016, 6, 6)));
        Assert.IsFalse(prev.Equals(new DateTime(2016, 6, 20)));
    }
开发者ID:hoopkjaz,项目名称:ScheduleWidget,代码行数:15,代码来源:StreetCleaningTests.cs

示例5: MonthTest2

        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());
        }
开发者ID:Rachitman,项目名称:ScheduleWidget,代码行数:36,代码来源:MonthTests.cs

示例6: MonthTest3

        public void MonthTest3()
        {
            var aEvent = new Event()
            {
                ID = 1,
                Title = "Event 3",
                FrequencyTypeOptions = FrequencyTypeEnum.Monthly,
                DayOfMonth = 3
            };

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

            var occurringDate = new DateTime(2013, 12, 3);

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

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

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

            var occurrences = schedule.Occurrences(range);

            Assert.AreEqual(24, occurrences.Count());
            Assert.AreEqual(new DateTime(2013, 1, 3), occurrences.First());
            Assert.AreEqual(new DateTime(2014, 12, 3), occurrences.Last());
        }
开发者ID:Rachitman,项目名称:ScheduleWidget,代码行数:33,代码来源:MonthTests.cs

示例7: MonthTest5

        public void MonthTest5()
        {
            var holidays = new UnionTE();
            holidays.Add(new FixedHolidayTE(1, 25));
            holidays.Add(new FloatingHolidayTE(3, DayOfWeekEnum.Mon, MonthlyIntervalEnum.First));

            var aEvent = new Event()
            {
                ID = 1,
                Title = "Event 5",
                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, holidays);
            Assert.IsTrue(schedule.IsOccurring(occurringDate));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 3, 4)));

            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, 28), nextOccurrence.Value);

            var occurrences = schedule.Occurrences(range);

            Assert.AreEqual(28, occurrences.Count());
            Assert.AreEqual(new DateTime(2013, 1, 18), occurrences.First());
            Assert.AreEqual(new DateTime(2013, 4, 29), occurrences.Last());
        }
开发者ID:Rachitman,项目名称:ScheduleWidget,代码行数:39,代码来源:MonthTests.cs

示例8: MonthTest4

        public void MonthTest4()
        {
            var aEvent = new Event()
            {
                ID = 1,
                Title = "Event 4",
                FrequencyTypeOptions = FrequencyTypeEnum.Monthly,
                RepeatInterval = 3,
                DayOfMonth = 30,
                StartDateTime = new DateTime(2013, 2, 1)
            };

            var range = new DateRange()
            {
                StartDateTime = aEvent.StartDateTime.Value,
                EndDateTime = new DateTime(2014, 12, 31)
            };

            var occurringDate = new DateTime(2014, 2, 28);

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

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

            var nextOccurrence = schedule.NextOccurrence(occurringDate, range);
            Assert.AreEqual(new DateTime(2014, 5, 30), nextOccurrence.Value);

            var occurrences = schedule.Occurrences(range);

            Assert.AreEqual(8, occurrences.Count());
            Assert.AreEqual(new DateTime(2013, 2, 28), occurrences.First());
            Assert.AreEqual(new DateTime(2014, 11, 30), occurrences.Last());
        }
开发者ID:Rachitman,项目名称:ScheduleWidget,代码行数:35,代码来源:MonthTests.cs

示例9: MultifunctionTest1

        public void MultifunctionTest1()
        {
            var aEvent = new Event()
            {
                FrequencyTypeOptions = FrequencyTypeEnum.Yearly,
                RepeatInterval = 2,
                StartDateTime = new DateTime(2000, 9, 27), // even years only
                Anniversary = new Anniversary()
                {
                    Month = 9,
                    Day = 27
                }
            };
            // Occurs 2000,2002,2004,2006,2008,2010
            aEvent.SetEndDateWithNumberOfOccurrences(6);

            // Check that the ending date was set correctly.
            Assert.IsTrue(aEvent.EndDateTime == new DateTime(2010, 9, 27));

            // Check that the number of occurrences is retrievable.
            Assert.IsTrue(aEvent.NumberOfOccurrencesThatWasLastSet == 6);

            // Exclude 2000,2006,2010.
            var excludedDates = new List<DateTime>
            {
                new DateTime(2000, 9, 27),
                new DateTime(2005, 9, 27),
                new DateTime(2005, 9, 28),
                new DateTime(2006, 9, 27),
                new DateTime(2010, 9, 27)
            };
            var schedule = new Schedule(aEvent, excludedDates);

            // Make sure it is not occurring on excluded dates.
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2000, 9, 27)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2006, 9, 27)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2010, 9, 27)));

            // Make sure it is not occurring outside the set range.
            Assert.IsFalse(schedule.IsOccurring(new DateTime(1998, 9, 27)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2012, 9, 27)));

            // Make sure it is occurring on desired dates.
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2002, 9, 27)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2004, 9, 27)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2008, 9, 27)));

            // Check the occurrences function.
            var during = new DateRange(new DateTime(1995, 1, 1),new DateTime(2015, 1, 1));
            var occurrences = schedule.Occurrences(during);
            Assert.IsTrue(occurrences.Count() == 3);

            // Check the last occurrence date function.
            var lastDate = schedule.GetLastOccurrenceDate();
            Assert.IsTrue(lastDate == new DateTime(2008, 9, 27));

            // Check the next occurrence (date only) function.
            Assert.IsTrue(schedule.NextOccurrence(new DateTime(1995, 1, 1)) == new DateTime(2002, 9, 27));
            Assert.IsTrue(schedule.NextOccurrence(new DateTime(2004, 9, 26)) == new DateTime(2004, 9, 27));
            Assert.IsTrue(schedule.NextOccurrence(new DateTime(2004, 9, 27)) == new DateTime(2008, 9, 27));
            Assert.IsTrue(schedule.NextOccurrence(new DateTime(2008, 9, 27)) == null);

            // Check the previous occurrence (date only) function.
            Assert.IsTrue(schedule.PreviousOccurrence(new DateTime(1995, 1, 1)) == null);
            Assert.IsTrue(schedule.PreviousOccurrence(new DateTime(2004, 9, 26)) == new DateTime(2002, 9, 27));
            Assert.IsTrue(schedule.PreviousOccurrence(new DateTime(2004, 9, 28)) == new DateTime(2004, 9, 27));
            Assert.IsTrue(schedule.PreviousOccurrence(new DateTime(2013, 9, 27)) == new DateTime(2008, 9, 27));

            // Check the next occurrence ranged function.
            var range1 = new DateRange(new DateTime(2004, 9, 1), new DateTime(2004, 10, 1));
            var range2 = new DateRange(new DateTime(2004, 11, 1), new DateTime(2002, 9, 27));
            Assert.IsTrue(schedule.NextOccurrence(new DateTime(1995, 1, 1), range1) == new DateTime(2004, 9, 27));
            Assert.IsTrue(schedule.NextOccurrence(new DateTime(1995, 1, 1), range2) == null);

            // Check the previous occurrence ranged function.
            Assert.IsTrue(schedule.PreviousOccurrence(new DateTime(2015, 1, 1), range1) == new DateTime(2004, 9, 27));
            Assert.IsTrue(schedule.PreviousOccurrence(new DateTime(2015, 1, 1), range2) == null);
        }
开发者ID:Rachitman,项目名称:ScheduleWidget,代码行数:78,代码来源:AAMultifunctionTests.cs


注:本文中的ScheduleWidget.ScheduledEvents.Schedule.PreviousOccurrence方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。