本文整理汇总了C#中CronExpression.NextOccurrence方法的典型用法代码示例。如果您正苦于以下问题:C# CronExpression.NextOccurrence方法的具体用法?C# CronExpression.NextOccurrence怎么用?C# CronExpression.NextOccurrence使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CronExpression
的用法示例。
在下文中一共展示了CronExpression.NextOccurrence方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_be_able_to_create_an_all_inclusive_expression
public void Should_be_able_to_create_an_all_inclusive_expression()
{
var date = new DateTime(2011, 1, 1, 0, 0, 0);
var cron = new CronExpression("* * * * *", date);
for (var i = 1; i < 121; i++)
{
Assert.AreEqual(date.AddMinutes(i), cron.NextOccurrence());
}
}
示例2: Should_be_able_to_get_week_days_across_month_boundary
public void Should_be_able_to_get_week_days_across_month_boundary()
{
var date = new DateTime(2011, 1, 23, 0, 0, 0);
var cron = new CronExpression("0 0 ? * 3,6", date);
Assert.AreEqual(new DateTime(2011, 1, 25, 0, 0, 0), cron.NextOccurrence());
Assert.AreEqual(new DateTime(2011, 1, 28, 0, 0, 0), cron.NextOccurrence());
Assert.AreEqual(new DateTime(2011, 2, 1, 0, 0, 0), cron.NextOccurrence());
Assert.AreEqual(new DateTime(2011, 2, 4, 0, 0, 0), cron.NextOccurrence());
Assert.AreEqual(new DateTime(2011, 2, 8, 0, 0, 0), cron.NextOccurrence());
date = new DateTime(2011, 2, 10, 0, 0, 0);
cron = new CronExpression("0 0 ? * 3,6", date);
Assert.AreEqual(new DateTime(2011, 2, 8, 0, 0, 0), cron.PreviousOccurrence());
Assert.AreEqual(new DateTime(2011, 2, 4, 0, 0, 0), cron.PreviousOccurrence());
Assert.AreEqual(new DateTime(2011, 2, 1, 0, 0, 0), cron.PreviousOccurrence());
Assert.AreEqual(new DateTime(2011, 1, 28, 0, 0, 0), cron.PreviousOccurrence());
Assert.AreEqual(new DateTime(2011, 1, 25, 0, 0, 0), cron.PreviousOccurrence());
}
示例3: Should_be_able_to_get_last_day_of_month_across_multiple_months
public void Should_be_able_to_get_last_day_of_month_across_multiple_months()
{
var date = new DateTime(2011, 1, 1, 0, 0, 0);
var cron = new CronExpression("0 0 L 1,2,5,6,9,12 *", date);
Assert.AreEqual(new DateTime(2011, 1, 31, 0, 0, 0), cron.NextOccurrence());
Assert.AreEqual(new DateTime(2011, 2, 28, 0, 0, 0), cron.NextOccurrence());
Assert.AreEqual(new DateTime(2011, 5, 31, 0, 0, 0), cron.NextOccurrence());
Assert.AreEqual(new DateTime(2011, 6, 30, 0, 0, 0), cron.NextOccurrence());
Assert.AreEqual(new DateTime(2011, 9, 30, 0, 0, 0), cron.NextOccurrence());
Assert.AreEqual(new DateTime(2011, 12, 31, 0, 0, 0), cron.NextOccurrence());
date = new DateTime(2012, 1, 1, 0, 0, 0);
cron = new CronExpression("0 0 L 1,2,5,6,9,12 *", date);
Assert.AreEqual(new DateTime(2011, 12, 31, 0, 0, 0), cron.PreviousOccurrence());
Assert.AreEqual(new DateTime(2011, 9, 30, 0, 0, 0), cron.PreviousOccurrence());
Assert.AreEqual(new DateTime(2011, 6, 30, 0, 0, 0), cron.PreviousOccurrence());
Assert.AreEqual(new DateTime(2011, 5, 31, 0, 0, 0), cron.PreviousOccurrence());
Assert.AreEqual(new DateTime(2011, 2, 28, 0, 0, 0), cron.PreviousOccurrence());
Assert.AreEqual(new DateTime(2011, 1, 31, 0, 0, 0), cron.PreviousOccurrence());
}