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


C# CronExpression.NextOccurrence方法代码示例

本文整理汇总了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());
            }
        }
开发者ID:yonglehou,项目名称:shuttle-scheduling,代码行数:10,代码来源:CronExpressionTest.cs

示例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());
        }
开发者ID:yonglehou,项目名称:shuttle-scheduling,代码行数:20,代码来源:CronExpressionTest.cs

示例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());
        }
开发者ID:yonglehou,项目名称:shuttle-scheduling,代码行数:22,代码来源:CronExpressionTest.cs


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