Ejemplo n.º 1
0
        public void Cron_YearOutOfRange()
        {
            Action act = () => schedule.Add(CronTimeSections.Years, 0);

            act.Should()
            .Throw <ArgumentOutOfRangeException>();
        }
Ejemplo n.º 2
0
 private static void TestTimeSection(ICron cron, ISection section)
 {
     section.Add(1)
     .Every.Should()
     .BeFalse();
     cron.Add(section.Time, 2);
     section.Every.Should()
     .BeFalse();
     cron.Add(section.Time, 3, true);
     section.Every.Should()
     .BeTrue();
 }
Ejemplo n.º 3
0
        private static void TestDateSection(ICron cron, ISection section)
        {
            section.Add(1)
            .Every.Should()
            .BeFalse();
            cron.Add(section.Time, 2);
            section.Every.Should()
            .BeFalse();
            Action act = () => cron.Add(section.Time, 3, true);

            act.Should()
            .Throw <Exception>();
        }
Ejemplo n.º 4
0
        public void Cron_CanThrowSecondsOutOfRange()
        {
            Action act = () => schedule.Add(CronTimeSections.Seconds, 60);

            act.Should()
            .Throw <ArgumentOutOfRangeException>();
        }
Ejemplo n.º 5
0
        public void Cron_CanVerifyComplex(
            int seconds, int dayMonth, int years, string expectedValue, string expectedDescription)
        {
            schedule = new CronBuilder()
                       .Add(time: CronTimeSections.Seconds, value: seconds, repeatEvery: true)
                       .Add(CronTimeSections.Minutes, 4)
                       .Add(CronTimeSections.Minutes, 3, true)
                       .Add(CronTimeSections.Hours, 3, 5)
                       .Add(CronTimeSections.Hours, 7, 11)
                       .Add(CronMonths.March)
                       .Add(CronDays.Wednesday)
                       .Add(CronDays.Friday)
                       .Add(CronTimeSections.DayMonth, dayMonth);

            if (years > 0)
            {
                schedule.Add(CronTimeSections.Years, years);
            }

            schedule.Seconds.Select(x => x.MinValue)
            .First()
            .Should()
            .Be(seconds);

            schedule.Minutes.Select(x => x.MinValue)
            .ToList()
            .Should()
            .NotBeEmpty()
            .And.HaveCount(2)
            .And.Contain(3)
            .And.Contain(4);

            schedule.Hours
            .ToList()
            .Should()
            .NotBeEmpty()
            .And.HaveCount(2)
            .And.Contain(x => x.MinValue == 3 && x.MaxValue == 5)
            .And.Contain(x => x.MinValue == 7 && x.MaxValue == 11);

            schedule.Months.Select(x => x.MinValue)
            .First()
            .Should()
            .Be(3);

            schedule.DayWeek.Select(x => x.MinValue)
            .Should()
            .NotBeEmpty()
            .And.HaveCount(2)
            .And.Contain(3)
            .And.Contain(5);

            schedule.DayMonth.Select(x => x.MinValue)
            .First()
            .Should()
            .Be(dayMonth);

            if (years > 0)
            {
                schedule.Years.Select(x => x.MinValue)
                .First()
                .Should()
                .Be(years);
            }

            schedule.Value
            .Should()
            .Be(expectedValue);

            schedule.Description
            .Should()
            .Be(expectedDescription);

            schedule.Seconds.Every.Should()
            .BeTrue();
            schedule.Minutes.Every.Should()
            .BeTrue();
            schedule.Hours.Every.Should()
            .BeFalse();

            schedule.Seconds.ToString()
            .Should()
            .Be($"*/{seconds}");

            schedule.DayMonth.ToString()
            .Should()
            .Be($"{dayMonth}");
        }