Пример #1
0
        public void TestTimeIncluded()
        {
            CronCalendar calendar = new CronCalendar("0/15 * * * * ?");
            string       fault    = "Time was included when it was not supposed to be";
            DateTime     tst      = DateTime.UtcNow.AddMinutes(2);

            tst = new DateTime(tst.Year, tst.Month, tst.Day, tst.Hour, tst.Minute, 30);
            Assert.IsFalse(calendar.IsTimeIncluded(tst), fault);

            calendar.SetCronExpressionString("0/25 * * * * ?");
            fault = "Time was not included as expected";
            Assert.IsTrue(calendar.IsTimeIncluded(tst), fault);
        }
Пример #2
0
        public void MillisecondsShouldBeIgnored()
        {
            var calendar = new CronCalendar("* * 1-3 ? * *")
            {
                TimeZone = TimeZoneInfo.Utc
            };
            var dateTime = new DateTimeOffset(2017, 7, 27, 2, 0, 1, 123, TimeSpan.Zero);

            Assert.That(calendar.IsTimeIncluded(dateTime), Is.False);
        }
        public void CronCalendarTest()
        {
            XmlLoaderPlugin plugin = new XmlLoaderPlugin();

            plugin.FileName = "quartz_loader_required_fields.xml";
            IScheduler scheduler = new Mock <IScheduler>().Object;

            plugin.Initialize("MyPlugin", scheduler);
            CronCalendar cal = plugin.Calendars["name1"] as CronCalendar;

            Assert.AreEqual("* * 0-20 * * ?", cal.CronExpression.CronExpressionString);
            Assert.IsTrue(cal.IsTimeIncluded(new DateTimeOffset(2012, 08, 30, 17, 0, 0, new TimeSpan(0, 0, 0))));
        }
Пример #4
0
        public void QuartzCronCalendar_Should_ReturnTrue_When_EventTimeIsNotInQuietPeriod()
        {
            // Arrange
            var today     = DateTime.UtcNow;
            var eventTime = new DateTimeOffset(
                new DateTime(today.Year, today.Month, today.Day, 7, 30, 00, DateTimeKind.Local));
            var calendar = new CronCalendar("* * 6 ? * * *"); // 6:00 AM until 6:59 AM, every day

            // Act
            var quiet = calendar.IsTimeIncluded(eventTime);

            // Assert
            Assert.True(quiet);
        }