本文整理汇总了C#中ScheduleWidget.ScheduledEvents.Schedule.GetLastOccurrenceDate方法的典型用法代码示例。如果您正苦于以下问题:C# Schedule.GetLastOccurrenceDate方法的具体用法?C# Schedule.GetLastOccurrenceDate怎么用?C# Schedule.GetLastOccurrenceDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScheduleWidget.ScheduledEvents.Schedule
的用法示例。
在下文中一共展示了Schedule.GetLastOccurrenceDate方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LastOccurrenceTest1
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));
}
示例2: LastOccurrenceTest3
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));
}
示例3: LastOccurrenceTest2
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));
}
示例4: LastOccurrenceTest10
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));
}
示例5: LastOccurrenceTest4
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));
}
示例6: LastOccurrenceTest5
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));
}
示例7: LastOccurrenceTest11
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));
}
示例8: LastOccurrenceTest9
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));
}
示例9: LastOccurrenceTest7
public void LastOccurrenceTest7()
{
var aEvent = new Event()
{
ID = 7,
Title = "Monthly on the last Monday, 3 times",
FrequencyTypeOptions = FrequencyTypeEnum.Monthly,
DaysOfWeek = 2,
MonthlyIntervalOptions = MonthlyIntervalEnum.Last,
StartDateTime = new DateTime(2013, 7, 29)
};
aEvent.SetEndDateWithNumberOfOccurrences(3);
var schedule = new Schedule(aEvent);
DateTime? endDate = schedule.GetLastOccurrenceDate();
Assert.IsTrue(endDate == new DateTime(2013, 9, 30));
}
示例10: LastOccurrenceTest6
public void LastOccurrenceTest6()
{
var aEvent = new Event()
{
ID = 6,
Title = "Every 2 months on day 29, 3 times",
FrequencyTypeOptions = FrequencyTypeEnum.Monthly,
DayOfMonth = 29,
RepeatInterval = 2,
StartDateTime = new DateTime(2013, 7, 29)
};
aEvent.SetEndDateWithNumberOfOccurrences(3);
var schedule = new Schedule(aEvent);
DateTime? endDate = schedule.GetLastOccurrenceDate();
Assert.IsTrue(endDate == new DateTime(2013, 11, 29));
}
示例11: 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);
}