Exemplo n.º 1
0
        public void DayOfMonthMatcherTest()
        {
            var value = "* * *,*%2,1../2 *";

            Assert.IsTrue(DayRuleParser.TryParse(value, out var obj));
            Assert.AreEqual(3, obj.DayOfMonthMatchers.Count);
            Assert.IsInstanceOfType(obj.DayOfMonthMatchers[0], typeof(RangeDayOfMonthMatcher));
            Assert.IsInstanceOfType(obj.DayOfMonthMatchers[1], typeof(ModuloDayOfMonthMatcher));
            Assert.IsInstanceOfType(obj.DayOfMonthMatchers[2], typeof(PeriodicDayOfMonthMatcher));
        }
Exemplo n.º 2
0
        public void YearMatcherTest()
        {
            var value = "*,*%2,1../2,*/Leap,*/NotLeap * * *";

            Assert.IsTrue(DayRuleParser.TryParse(value, out var obj));
            Assert.AreEqual(5, obj.YearMatchers.Count);
            Assert.IsInstanceOfType(obj.YearMatchers[0], typeof(RangeYearMatcher));
            Assert.IsInstanceOfType(obj.YearMatchers[1], typeof(ModuloYearMatcher));
            Assert.IsInstanceOfType(obj.YearMatchers[2], typeof(PeriodicYearMatcher));
            Assert.IsInstanceOfType(obj.YearMatchers[3], typeof(LeapYearMatcher));
            Assert.IsInstanceOfType(obj.YearMatchers[4], typeof(NotLeapYearMatcher));
        }
Exemplo n.º 3
0
        public void InvalidParseTests()
        {
            var value = @"";

            // ReSharper disable once NotAccessedVariable
            Assert.IsFalse(DayRuleParser.TryParse(value, out var obj));
            value = null;
            // ReSharper disable once ExpressionIsAlwaysNull
            Assert.IsFalse(DayRuleParser.TryParse(value, out obj));
            value = "  ";
            Assert.IsFalse(DayRuleParser.TryParse(value, out obj));
            value = "*";
            Assert.IsFalse(DayRuleParser.TryParse(value, out obj));
            value = "* *";
            Assert.IsFalse(DayRuleParser.TryParse(value, out obj));
            value = "* * *";
            Assert.IsFalse(DayRuleParser.TryParse(value, out obj));
        }
Exemplo n.º 4
0
 public void ValidParseTests(string dayRule)
 {
     Assert.IsTrue(DayRuleParser.TryParse(dayRule, out var obj));
     Assert.IsNotNull(obj);
 }