Пример #1
0
 public static void range_array_test()
 {
     var cron_schedule = new CronSchedule("1-10");
     List<int> results = cron_schedule.minutes.GetRange(0,10);//();
     Assert.AreEqual(results.ToArray(), new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
     var cs = new CronSchedule("1-10/3 20-45/4 * * *");
     results = cs.minutes;
     Assert.AreEqual(results.ToArray(), new int[] { 3, 6, 9 });
 }
Пример #2
0
 public void is_valid_test()
 {
     var cron_schedule = new CronSchedule();
     Assert.IsTrue(cron_schedule.isValid("*/2"));
     Assert.IsTrue(cron_schedule.isValid("* * * * *"));
     Assert.IsTrue(cron_schedule.isValid("0 * * * *"));
     Assert.IsTrue(cron_schedule.isValid("0,1,2 * * * *"));
     Assert.IsTrue(cron_schedule.isValid("*/2 * * * *"));
     Assert.IsTrue(cron_schedule.isValid("1-4 * * * *"));
     Assert.IsTrue(cron_schedule.isValid("1-55/3 * * * *"));
     Assert.IsTrue(cron_schedule.isValid("1,10,20 * * * *"));
     Assert.IsTrue(cron_schedule.isValid("* 1,10,20 * * *"));
 }
Пример #3
0
 public void generate_days_of_month_test()
 {
     var cron_schedule = new CronSchedule("* * 1,2,3 * *");
     Assert.AreEqual(cron_schedule.days_of_month.ToArray(), new int[] { 1, 2, 3 });
 }
Пример #4
0
 public void generate_hours_test()
 {
     var cron_schedule = new CronSchedule("* 1,2,3 * * *");
     Assert.AreEqual(cron_schedule.hours.ToArray(), new int[] { 1, 2, 3 });
 }
Пример #5
0
 public void generate_values_range_test()
 {
     var cron_schedule = new CronSchedule("1-10");
     List<int> results = cron_schedule.minutes.GetRange(0,10);//(, 0, 10);
     Assert.AreEqual(results.ToArray(), new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
 }
Пример #6
0
 public void generate_values_divided_test()
 {
     var cron_schedule = new CronSchedule("*/2");
     List<int> results = cron_schedule.minutes.GetRange(0,5);//(, 0, 10);
     Assert.AreEqual(results.ToArray(), new int[] { 0, 2, 4, 6, 8 });
 }
Пример #7
0
 public void list_array_test()
 {
     var cron_schedule = new CronSchedule("1,2,3,4,5,6,7,8,9,10");
     List<int> results = cron_schedule.minutes;
     Assert.AreEqual(results.ToArray(), new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
 }
Пример #8
0
 public void wild_array_test()
 {
     var cron_schedule = new CronSchedule("*");
     List<int> results = cron_schedule.minutes.GetRange(0,10);//("*", 0, 10);
     Assert.AreEqual(results.ToArray(), new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
 }
Пример #9
0
 public void is_time_test()
 {
     var cron_schedule = new CronSchedule("0 0 12 10 *");
     Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("12:00:00 am 10/12/2008")));
     Assert.IsFalse(cron_schedule.isTime(DateTime.Parse("12:01:00 am 10/12/2008")));
 }
Пример #10
0
        public void is_time_day_of_week_test()
        {
            var cron_schedule = new CronSchedule("* * * * 0");
            Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("10/12/2008")));
            Assert.IsFalse(cron_schedule.isTime(DateTime.Parse("10/13/2008")));

            cron_schedule = new CronSchedule("* * * * */2");
            Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("10/14/2008")));
        }
Пример #11
0
        public void is_time_month_test()
        {
            var cron_schedule = new CronSchedule("* * * 1 *");
            Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("1/1/2008")));

            cron_schedule = new CronSchedule("* * * 12 *");
            Assert.IsFalse(cron_schedule.isTime(DateTime.Parse("1/1/2008")));

            cron_schedule = new CronSchedule("* * * */3 *");
            Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("3/1/2008")));
            Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("6/1/2008")));
        }
Пример #12
0
 public void is_time_day_of_month_test()
 {
     var cron_schedule = new CronSchedule("* * 1 * *");
     Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("2010/08/01")));
 }
Пример #13
0
        public void is_time_hour_test()
        {
            var cron_schedule = new CronSchedule("* 0 * * *");
            Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("12:00 am")));

            cron_schedule = new CronSchedule("* 0,12 * * *");
            Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("12:00 am")));
            Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("12:00 pm")));
        }
Пример #14
0
        public void is_time_minute_test()
        {
            var cron_schedule = new CronSchedule("0 * * * *");
            Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("8:00 am")));
            Assert.IsFalse(cron_schedule.isTime(DateTime.Parse("8:01 am")));

            cron_schedule = new CronSchedule("0-10 * * * *");
            Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("8:00 am")));
            Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("8:03 am")));

            cron_schedule = new CronSchedule("*/2 * * * *");
            Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("8:00 am")));
            Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("8:02 am")));
            Assert.IsFalse(cron_schedule.isTime(DateTime.Parse("8:03 am")));
        }
Пример #15
0
 public void generate_days_of_weeks()
 {
     var cron_schedule = new CronSchedule("* * * * 1,2,3 ");
     Assert.AreEqual(cron_schedule.days_of_week.ToArray(), new int[] { 1, 2, 3 });
 }