public void Field_can_accept_match_all_values_expression()
        {
            var field = new MinuteField("*");

            field.GetFirst().Value.ShouldBe(0);
            field.GetNext(30).Value.ShouldBe(30);
            field.GetNext(59).Value.ShouldBe(59);
            field.GetNext(60).Value.ShouldBe(CronValue.Wrapped.Value);
        }
        const int MaxDayInMonthFixAttempts = 12 * 10; //12 months * 10 ; means we check if the date can be found up to 10 years in the future.

        #endregion Fields

        #region Constructors

        internal CronSchedule(SecondField secondField, MinuteField minuteField, HourField hourField, DayOfMonthField dayOfMonthField, MonthField monthField, DayOfWeekField dayOfWeek)
        {
            SecondField = secondField;
            MinuteField = minuteField;
            HourField = hourField;
            DayOfMonthField = dayOfMonthField;
            MonthField = monthField;
            DayOfWeek = dayOfWeek;
        }
        public void Field_can_accept_a_simple_list_expression()
        {
            var field = new MinuteField("10,20");

            field.GetFirst().Value.ShouldBe(10);
            field.GetNext(10).Value.ShouldBe(10);
            field.GetNext(11).Value.ShouldBe(20);
            field.GetNext(20).Value.ShouldBe(20);
            field.GetNext(21).Value.ShouldBe(CronValue.Wrapped.Value);
        }
Exemple #4
0
        private static CronSchedule BuildCronSchedule(string[] fieldExpressions)
        {
            var secondField = new SecondField(fieldExpressions[SecondIndex]);
            var minuteField = new MinuteField(fieldExpressions[MinuteIndex]);
            var hourField = new HourField(fieldExpressions[HourIndex]);
            var dayOfMonthField = new DayOfMonthField(fieldExpressions[DayOfMonthIndex]);
            var monthField = new MonthField(fieldExpressions[MonthIndex]);
            var dayOfWeek = new DayOfWeekField(fieldExpressions[DayOfWeekIndex]);

            return new CronSchedule(secondField, minuteField, hourField, dayOfMonthField, monthField, dayOfWeek);
        }
        public void Field_can_accept_a_simple_increment_expression()
        {
            var field = new MinuteField("*/10");

            field.GetFirst().Value.ShouldBe(0);
            field.GetNext(1).Value.ShouldBe(10);
            field.GetNext(10).Value.ShouldBe(10);
            field.GetNext(11).Value.ShouldBe(20);
            field.GetNext(21).Value.ShouldBe(30);
            field.GetNext(51).Value.ShouldBe(CronValue.Wrapped.Value);
        }
        public void Field_can_accept_a_ranged_increment_expression()
        {
            var field = new MinuteField("10-40/10");

            field.GetFirst().Value.ShouldBe(10);
            field.GetNext(10).Value.ShouldBe(10);
            field.GetNext(11).Value.ShouldBe(20);
            field.GetNext(21).Value.ShouldBe(30);
            field.GetNext(31).Value.ShouldBe(40);
            field.GetNext(41).Value.ShouldBe(CronValue.Wrapped.Value);
        }
        public void Field_can_accept_a_simple_range_expression()
        {
            var field = new MinuteField("10-14");

            field.GetFirst().Value.ShouldBe(10);
            field.GetNext(10).Value.ShouldBe(10);
            field.GetNext(11).Value.ShouldBe(11);
            field.GetNext(12).Value.ShouldBe(12);
            field.GetNext(13).Value.ShouldBe(13);
            field.GetNext(14).Value.ShouldBe(14);
            field.GetNext(15).Value.ShouldBe(CronValue.Wrapped.Value);
        }
        public void Field_can_accept_a_list_of_ranges_expression()
        {
            var field = new MinuteField("10-11,20-21");

            field.GetFirst().Value.ShouldBe(10);
            field.GetNext(10).Value.ShouldBe(10);
            field.GetNext(11).Value.ShouldBe(11);
            field.GetNext(12).Value.ShouldBe(20);
            field.GetNext(20).Value.ShouldBe(20);
            field.GetNext(21).Value.ShouldBe(21);
            field.GetNext(22).Value.ShouldBe(CronValue.Wrapped.Value);
        }
 public void Throw_ArgumentException_on_empty_expressions()
 {
     var field = new MinuteField(string.Empty);
 }
 public void Throw_CronException_on_expression_containing_invalid_characters()
 {
     var field = new MinuteField("*/15+");
 }
 public void Throw_ArgumentNullException_on_null_expressions()
 {
     var field = new MinuteField(null);
 }