Exemple #1
0
        public void WalkingEveryMinuteTest()
        {
            CronExpr cron = new CronExpr("*");
            DateTime when = DateTime.Now.NextMinute();

            for (int loop = 0; loop < LoopCount; loop++) {
                DateTime calc = cron.CalcNextTime(when);

                when = when.AddMinutes(1);

                Assert.AreEqual(when, calc);
                Assert.IsTrue(cron.Matches(when));
            }
        }
Exemple #2
0
        public void SundayTest()
        {
            CronExpr cron = new CronExpr("* * * * 7");
            DateTime when = cron.CalcNextTime(DateTime.Now);
            Assert.IsTrue(when.DayOfWeek == DayOfWeek.Sunday);

            cron = new CronExpr("* * * * 0");
            when = cron.CalcNextTime(DateTime.Now);
            Assert.IsTrue(when.DayOfWeek == DayOfWeek.Sunday);

            cron = new CronExpr("* * * * 0,7");
            when = cron.CalcNextTime(DateTime.Now);
            Assert.IsTrue(when.DayOfWeek == DayOfWeek.Sunday);

            cron = new CronExpr("* * * * 1-6");
            when = cron.CalcNextTime(DateTime.Now);
            Assert.IsFalse(when.DayOfWeek == DayOfWeek.Sunday);
        }