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)); }
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)); }
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)); }
public void ValidParseTests(string dayRule) { Assert.IsTrue(DayRuleParser.TryParse(dayRule, out var obj)); Assert.IsNotNull(obj); }