public void The3rdMondayAndFollowingThursdayAndFridayOfGivenMonths_AsSeparateRules(int year, int month, int day, bool expected) { //The 3rd Monday and also Thursday && Friday after the 3rd Monday of January/April/July/October/December var thirdMonday = DayOfWeek.Monday.EveryWeek().The3rdOccurenceInTheMonth(); var thirdMondayWithMonthsFilter = thirdMonday.InMonths(Month.Jan, Month.Apr, Month.Jul, Month.Oct, Month.Dec); var thursdayAfter = new NthBeforeAfterRule() { Nth = 1, NthRule = new DayOfWeekRule(DayOfWeek.Thursday), ReferencedRule = thirdMondayWithMonthsFilter }; var fridayAfter = new NthBeforeAfterRule { Nth = 1, NthRule = new DayOfWeekRule(DayOfWeek.Friday), ReferencedRule = thirdMondayWithMonthsFilter }; var rule = thirdMondayWithMonthsFilter .Or(thursdayAfter) .Or(fridayAfter); Process(rule).IsMatch(new DateTime(year, month, day)) .Should().Be(expected); }
public void SecondMondayAfterFirstFriday(int year, int month, int day, bool expected) { //Second Monday after the first Friday of the month var rule = new NthBeforeAfterRule { Nth = 2, NthRule = DayOfWeek.Monday.EveryWeek(), ReferencedRule = DayOfWeek.Friday.EveryWeek().The1stOccurenceInTheMonth() }; Process(rule).IsMatch(new DateTime(year, month, day)) .Should().Be(expected); }
public void FirstDayBefore15OfTheMonth(int year, int month, int day, bool expected) { var nthRule = new NthBeforeAfterRule() { Nth = -1, NthRule = new EveryDayRule(), ReferencedRule = new EveryDayRule().TheNthOccurenceInTheMonth(15) }; var date = new DateTime(year, month, day); Process(nthRule).IsMatch(date).Should().Be(expected); }
public void SecondMondayAfterFirstFriday(int year, int month, int day, bool expected) { var nthRule = new NthBeforeAfterRule() { Nth = 2, NthRule = DayOfWeek.Monday.EveryWeek(), ReferencedRule = DayOfWeek.Friday.EveryWeek().The1stOccurenceInTheMonth() }; var date = new DateTime(year, month, day); Process(nthRule).IsMatch(date).Should().Be(expected); }
public void MondayAndWednesdayBefore2ndFriday(int year, int month, int day, bool expected) { var nthRule = new NthBeforeAfterRule() { Nth = -1, NthRule = new DaysOfWeekRule(DayOfWeek.Monday, DayOfWeek.Wednesday), ReferencedRule = DayOfWeek.Friday.EveryWeek().The2ndOccurenceInTheMonth() }; var date = new DateTime(year, month, day); Process(nthRule).IsMatch(date).Should().Be(expected); }
public void TwoDaysAfterEveryMondayAndTuesday(int year, int month, int day, bool expected) { var nthRule = new NthBeforeAfterRule() { Nth = 2, NthRule = new EveryDayRule(), ReferencedRule = new DaysOfWeekRule(DayOfWeek.Monday, DayOfWeek.Tuesday) }; var date = new DateTime(year, month, day); Process(nthRule).IsMatch(date).Should().Be(expected); }
public void MondayAndWednesdayBefore15Th(int year, int month, int day, bool expected) { var nthRule = new NthBeforeAfterRule() { Nth = 1, NthRule = new DaysOfWeekRule(DayOfWeek.Monday, DayOfWeek.Wednesday), ReferencedRule = new NthDayBeforeAfterRule() { Nth = 15, ReferencedRule = new EveryDayRule() } }; var date = new DateTime(year, month, day); Process(nthRule).IsMatch(date).Should().Be(expected); }
//The 3rd Monday and also Thursday & Friday after the 3rd Monday of January/April/July/October/December public void The3rdMondayAndFollowingThursdayAndFridayOfGivenMonths(int year, int month, int day, bool expected) { var anyThirdMonday = DayOfWeek.Monday.EveryWeek().The3rdOccurenceInTheMonth(); var thirdMonday = anyThirdMonday.InMonths(Month.Jan, Month.Apr, Month.Jul, Month.Oct, Month.Dec); var thuOrFri = new NthBeforeAfterRule() { Nth = 1, NthRule = new DaysOfWeekRule(DayOfWeek.Thursday, DayOfWeek.Friday), ReferencedRule = thirdMonday }; var mondayAndNextDays = thirdMonday.Or(thuOrFri); Process(mondayAndNextDays).IsMatch(new DateTime(year, month, day)) .Should().Be(expected); }
public void FridayBefore2ndTuesdayOfGivenMonths(int year, int month, int day, bool expected) { //Friday before the 2nd Tuesday of each three months (March, June etc) var fridayBefore2ndTuesday = new NthBeforeAfterRule { Nth = -1, NthRule = DayOfWeek.Friday.EveryWeek(), ReferencedRule = DayOfWeek.Tuesday.EveryWeek().The2ndOccurenceInTheMonth() }; var rule = new MonthsFilterRule { Months = new[] { Month.Mar, Month.Jun, Month.Sep, Month.Dec, }, ReferencedRule = fridayBefore2ndTuesday }; Process(rule).IsMatch(new DateTime(year, month, day)) .Should().Be(expected); }