public void Yearly_MultipleMonths_Ordinal() { // Arrange. var startDate = new DateTime(2018, 1, 1); IRecurring yearly = Recurs .Starting(startDate) .Every(1) .Years() .OnOrdinalWeek(Ordinal.THIRD) .OnDay(DayOfWeek.Thursday) .OnMonths(Month.JANUARY | Month.APRIL) .Ending(new DateTime(2030, 1, 1)) .Build(); // Act. // Assert. Assert.Equal(new DateTime(2018, 1, 18), yearly.Next(new DateTime(2014, 1, 1))); Assert.Equal(new DateTime(2018, 1, 18), yearly.Next(new DateTime(2018, 1, 1))); Assert.Equal(new DateTime(2018, 4, 19), yearly.Next(new DateTime(2018, 1, 18))); Assert.Equal(new DateTime(2019, 1, 17), yearly.Next(new DateTime(2018, 4, 19))); Assert.Null(yearly.Next(new DateTime(2030, 1, 1))); Assert.Equal(new DateTime(2018, 1, 18), yearly.Previous(new DateTime(2018, 1, 19))); Assert.Equal(new DateTime(2018, 1, 18), yearly.Previous(new DateTime(2018, 4, 19))); Assert.Equal(new DateTime(2018, 4, 19), yearly.Previous(new DateTime(2018, 4, 20))); Assert.Equal(new DateTime(2019, 1, 17), yearly.Previous(new DateTime(2019, 1, 18))); Assert.Null(yearly.Previous(new DateTime(2018, 1, 18))); }
public void Weekly_EveryWeek() { // Arrange. IRecurring weekly = Recurs .Starting(new DateTime(2015, 1, 1)) // Thursday .Every(1) .Weeks() .OnDays(Day.TUESDAY | Day.FRIDAY) .Ending(new DateTime(2015, 1, 19)) // Thursday .Build(); // Act. // Assert. Assert.Equal(new DateTime(2015, 1, 2), weekly.Next(new DateTime(2014, 1, 1))); Assert.Equal(new DateTime(2015, 1, 6), weekly.Next(new DateTime(2015, 1, 2))); Assert.Equal(new DateTime(2015, 1, 9), weekly.Next(new DateTime(2015, 1, 6))); Assert.Equal(new DateTime(2015, 1, 13), weekly.Next(new DateTime(2015, 1, 9))); Assert.Equal(new DateTime(2015, 1, 16), weekly.Next(new DateTime(2015, 1, 13))); Assert.Null(weekly.Next(new DateTime(2015, 1, 16))); Assert.Equal(new DateTime(2015, 1, 2), weekly.Previous(new DateTime(2015, 1, 6))); Assert.Equal(new DateTime(2015, 1, 6), weekly.Previous(new DateTime(2015, 1, 9))); Assert.Equal(new DateTime(2015, 1, 9), weekly.Previous(new DateTime(2015, 1, 13))); Assert.Equal(new DateTime(2015, 1, 13), weekly.Previous(new DateTime(2015, 1, 16))); Assert.Equal(new DateTime(2015, 1, 16), weekly.Previous(new DateTime(2015, 1, 19))); Assert.Equal(new DateTime(2015, 1, 16), weekly.Previous(new DateTime(2015, 1, 20))); Assert.Equal(new DateTime(2015, 1, 16), weekly.Previous(new DateTime(2015, 1, 21))); Assert.Null(weekly.Previous(new DateTime(2015, 1, 2))); Assert.Null(weekly.Previous(new DateTime(2015, 1, 1))); Assert.Null(weekly.Previous(new DateTime(2014, 1, 1))); }
public void Monthly_EveryThirdMonth_Ordinal() { // Arrange. IRecurring monthly = Recurs .Starting(new DateTime(2018, 1, 1)) // Monday .Every(3) .Months() .OnOrdinalWeek(Ordinal.SECOND) .OnDay(DayOfWeek.Friday) .Ending(new DateTime(2018, 12, 25)) .Build(); // Act. // Assert. Assert.Equal(new DateTime(2018, 1, 12), monthly.Next(new DateTime(2017, 1, 1))); Assert.Equal(new DateTime(2018, 1, 12), monthly.Next(new DateTime(2018, 1, 1))); Assert.Equal(new DateTime(2018, 1, 12), monthly.Next(new DateTime(2018, 1, 12))); Assert.Equal(new DateTime(2018, 7, 13), monthly.Next(new DateTime(2018, 7, 1))); Assert.Null(monthly.Next(new DateTime(2020, 2, 1))); Assert.Equal(new DateTime(2018, 1, 12), monthly.Previous(new DateTime(2018, 1, 13))); Assert.Equal(new DateTime(2018, 1, 12), monthly.Previous(new DateTime(2018, 4, 13))); Assert.Equal(new DateTime(2018, 4, 13), monthly.Previous(new DateTime(2018, 4, 14))); Assert.Equal(new DateTime(2018, 4, 13), monthly.Previous(new DateTime(2018, 7, 13))); Assert.Null(monthly.Previous(new DateTime(2018, 1, 12))); }
public void Yearly_EveryThirdYear_Ordinal() { // Arrange. var startDate = new DateTime(2018, 1, 1); IRecurring yearly = Recurs .Starting(startDate) .Every(3) .Years() .OnOrdinalWeek(Ordinal.THIRD) .OnDay(DayOfWeek.Thursday) .OnMonths(Month.JANUARY) .Ending(new DateTime(2030, 1, 1)) .Build(); // Act. // Assert. Assert.Equal(new DateTime(2018, 1, 18), yearly.Next(new DateTime(2014, 1, 1))); Assert.Equal(new DateTime(2018, 1, 18), yearly.Next(new DateTime(2018, 1, 1))); Assert.Equal(new DateTime(2021, 1, 21), yearly.Next(new DateTime(2018, 1, 18))); Assert.Equal(new DateTime(2024, 1, 18), yearly.Next(new DateTime(2021, 2, 18))); Assert.Null(yearly.Next(new DateTime(2030, 1, 1))); Assert.Equal(new DateTime(2018, 1, 18), yearly.Previous(new DateTime(2018, 1, 19))); Assert.Equal(new DateTime(2018, 1, 18), yearly.Previous(new DateTime(2021, 1, 21))); Assert.Equal(new DateTime(2021, 1, 21), yearly.Previous(new DateTime(2021, 1, 22))); Assert.Equal(new DateTime(2024, 1, 18), yearly.Previous(new DateTime(2024, 1, 19))); Assert.Null(yearly.Previous(new DateTime(2018, 1, 18))); }
public void Monthly_EveryMonth() { // Arrange. IRecurring monthly = Recurs .Starting(new DateTime(2015, 1, 1)) .Every(1) .Months() .OnDay(24) .Ending(new DateTime(2016, 2, 4)) .Build(); // Act. // Assert. Assert.Equal(new DateTime(2015, 1, 24), monthly.Next(new DateTime(2014, 4, 8))); Assert.Equal(new DateTime(2015, 2, 24), monthly.Next(new DateTime(2015, 1, 24))); Assert.Equal(new DateTime(2015, 2, 24), monthly.Next(new DateTime(2015, 2, 23))); Assert.Equal(new DateTime(2015, 3, 24), monthly.Next(new DateTime(2015, 2, 24))); Assert.Equal(new DateTime(2015, 3, 24), monthly.Next(new DateTime(2015, 2, 25))); Assert.Equal(new DateTime(2015, 6, 24), monthly.Next(new DateTime(2015, 6, 3))); Assert.Null(monthly.Next(new DateTime(2016, 6, 3))); Assert.Equal(new DateTime(2015, 1, 24), monthly.Previous(new DateTime(2015, 1, 25))); Assert.Equal(new DateTime(2015, 1, 24), monthly.Previous(new DateTime(2015, 2, 24))); Assert.Equal(new DateTime(2015, 2, 24), monthly.Previous(new DateTime(2015, 2, 25))); Assert.Equal(new DateTime(2015, 2, 24), monthly.Previous(new DateTime(2015, 3, 24))); Assert.Equal(new DateTime(2015, 2, 24), monthly.Previous(new DateTime(2015, 2, 25))); Assert.Equal(new DateTime(2015, 3, 24), monthly.Previous(new DateTime(2015, 3, 25))); Assert.Equal(new DateTime(2015, 3, 24), monthly.Previous(new DateTime(2015, 4, 24))); Assert.Equal(new DateTime(2015, 6, 24), monthly.Previous(new DateTime(2015, 6, 25))); Assert.Null(monthly.Previous(new DateTime(2015, 1, 24))); }
public void Monthly_EveryMonth_DifferentDaysInMonths() { // Arrange. IRecurring monthly = Recurs .Starting(new DateTime(2015, 1, 1)) .Every(1) .Months() .OnDay(31) .Ending(new DateTime(2016, 2, 4)) .Build(); // Act. // Assert. Assert.Equal(new DateTime(2015, 1, 31), monthly.Next(new DateTime(2014, 2, 1))); Assert.Equal(new DateTime(2015, 1, 31), monthly.Next(new DateTime(2015, 1, 30))); Assert.Equal(new DateTime(2015, 2, 28), monthly.Next(new DateTime(2015, 1, 31))); Assert.Equal(new DateTime(2015, 2, 28), monthly.Next(new DateTime(2015, 2, 27))); Assert.Equal(new DateTime(2015, 3, 31), monthly.Next(new DateTime(2015, 2, 28))); Assert.Equal(new DateTime(2015, 4, 30), monthly.Next(new DateTime(2015, 3, 31))); Assert.Null(monthly.Next(new DateTime(2016, 6, 3))); Assert.Equal(new DateTime(2015, 1, 31), monthly.Previous(new DateTime(2015, 2, 28))); Assert.Equal(new DateTime(2015, 1, 31), monthly.Previous(new DateTime(2015, 2, 1))); Assert.Equal(new DateTime(2015, 2, 28), monthly.Previous(new DateTime(2015, 3, 1))); Assert.Equal(new DateTime(2015, 2, 28), monthly.Previous(new DateTime(2015, 3, 15))); Assert.Equal(new DateTime(2015, 3, 31), monthly.Previous(new DateTime(2015, 4, 1))); Assert.Equal(new DateTime(2015, 4, 30), monthly.Previous(new DateTime(2015, 5, 1))); Assert.Null(monthly.Previous(new DateTime(2015, 1, 31))); }
public void Daily_EveryDay() { // Arrange. IRecurring daily = Recurs .Starting(new DateTime(2015, 1, 1)) .Every(1) .Days() .Ending(new DateTime(2015, 1, 15)) .Build(); // Act. // Assert. Assert.Equal(new DateTime(2015, 1, 1), daily.Next(new DateTime(2014, 7, 3))); Assert.Equal(new DateTime(2015, 1, 2), daily.Next(new DateTime(2015, 1, 1))); Assert.Equal(new DateTime(2015, 1, 3), daily.Next(new DateTime(2015, 1, 2))); Assert.Null(daily.Next(new DateTime(2015, 1, 15))); Assert.Equal(new DateTime(2015, 1, 1), daily.Previous(new DateTime(2015, 1, 2))); Assert.Equal(new DateTime(2015, 1, 2), daily.Previous(new DateTime(2015, 1, 3))); Assert.Equal(new DateTime(2015, 1, 3), daily.Previous(new DateTime(2015, 1, 4))); Assert.Equal(new DateTime(2015, 1, 14), daily.Previous(new DateTime(2015, 1, 15))); Assert.Equal(new DateTime(2015, 1, 15), daily.Previous(new DateTime(2015, 1, 16))); Assert.Equal(new DateTime(2015, 1, 15), daily.Previous(new DateTime(2015, 1, 17))); Assert.Null(daily.Previous(new DateTime(2015, 1, 1))); }
public void Weekly_EveryWeek_TwoDaysAfterDateTime() { // Arrange. DateTime startDate = new DateTime(2015, 1, 1); IRecurring weekly = Recurs .Starting(startDate) .Every(1) .Weeks() .OnDay(DayOfWeek.Saturday) .Ending(new DateTime(2015, 2, 19)) .Build(); // Act. // Assert. Assert.Equal(new DateTime(2015, 1, 3), weekly.Next(new DateTime(2014, 1, 1))); Assert.Equal(new DateTime(2015, 1, 3), weekly.Next(new DateTime(2015, 1, 2))); Assert.Equal(new DateTime(2015, 1, 10), weekly.Next(new DateTime(2015, 1, 6))); Assert.Equal(new DateTime(2015, 1, 10), weekly.Next(new DateTime(2015, 1, 9))); Assert.Equal(new DateTime(2015, 1, 17), weekly.Next(new DateTime(2015, 1, 13))); Assert.Null(weekly.Next(new DateTime(2015, 2, 19))); Assert.Equal(new DateTime(2015, 1, 3), weekly.Previous(new DateTime(2015, 1, 4))); Assert.Equal(new DateTime(2015, 1, 3), weekly.Previous(new DateTime(2015, 1, 10))); Assert.Equal(new DateTime(2015, 1, 10), weekly.Previous(new DateTime(2015, 1, 11))); Assert.Equal(new DateTime(2015, 1, 10), weekly.Previous(new DateTime(2015, 1, 17))); Assert.Equal(new DateTime(2015, 1, 17), weekly.Previous(new DateTime(2015, 1, 18))); Assert.Null(weekly.Previous(new DateTime(2015, 1, 3))); }
public void Weekly_EveryThirdWeek() { // Arrange. IRecurring weekly = Recurs .Starting(new DateTime(2015, 1, 1)) .Every(3) .Weeks() .OnDays(Day.TUESDAY | Day.FRIDAY) .Ending(new DateTime(2015, 2, 19)) .Build(); // Act. // Assert. Assert.Equal(new DateTime(2015, 1, 2), weekly.Next(new DateTime(2014, 1, 1))); Assert.Equal(new DateTime(2015, 1, 20), weekly.Next(new DateTime(2015, 1, 2))); Assert.Equal(new DateTime(2015, 1, 23), weekly.Next(new DateTime(2015, 1, 21))); Assert.Equal(new DateTime(2015, 2, 10), weekly.Next(new DateTime(2015, 1, 23))); Assert.Equal(new DateTime(2015, 2, 10), weekly.Next(new DateTime(2015, 1, 24))); Assert.Equal(new DateTime(2015, 2, 10), weekly.Next(new DateTime(2015, 1, 27))); Assert.Equal(new DateTime(2015, 2, 13), weekly.Next(new DateTime(2015, 2, 10))); Assert.Equal(new DateTime(2015, 1, 2), weekly.Previous(new DateTime(2015, 1, 3))); Assert.Equal(new DateTime(2015, 1, 20), weekly.Previous(new DateTime(2015, 1, 21))); Assert.Equal(new DateTime(2015, 1, 23), weekly.Previous(new DateTime(2015, 1, 24))); Assert.Equal(new DateTime(2015, 2, 10), weekly.Previous(new DateTime(2015, 2, 11))); Assert.Equal(new DateTime(2015, 2, 10), weekly.Previous(new DateTime(2015, 2, 13))); Assert.Equal(new DateTime(2015, 2, 13), weekly.Previous(new DateTime(2015, 2, 14))); }
public void Monthly_EveryMonth_Ordinal_LastWeek() { // Arrange. IRecurring monthly = Recurs .Starting(new DateTime(2018, 1, 1)) // Monday .Every(1) .Months() .OnOrdinalWeek(Ordinal.LAST) .OnDay(DayOfWeek.Wednesday) .Ending(new DateTime(2018, 12, 25)) .Build(); // Act. // Assert. Assert.Equal(new DateTime(2018, 1, 31), monthly.Next(new DateTime(2017, 1, 1))); Assert.Equal(new DateTime(2018, 1, 31), monthly.Next(new DateTime(2018, 1, 1))); Assert.Equal(new DateTime(2018, 1, 31), monthly.Next(new DateTime(2018, 1, 31))); Assert.Equal(new DateTime(2018, 2, 28), monthly.Next(new DateTime(2018, 2, 1))); Assert.Equal(new DateTime(2018, 4, 25), monthly.Next(new DateTime(2018, 4, 1))); Assert.Null(monthly.Next(new DateTime(2020, 2, 1))); Assert.Equal(new DateTime(2018, 1, 31), monthly.Previous(new DateTime(2018, 2, 1))); Assert.Equal(new DateTime(2018, 1, 31), monthly.Previous(new DateTime(2018, 2, 28))); Assert.Equal(new DateTime(2018, 2, 28), monthly.Previous(new DateTime(2018, 3, 1))); Assert.Equal(new DateTime(2018, 3, 28), monthly.Previous(new DateTime(2018, 4, 25))); Assert.Equal(new DateTime(2018, 4, 25), monthly.Previous(new DateTime(2018, 4, 26))); Assert.Null(monthly.Previous(new DateTime(2018, 1, 31))); }
public void Yearly_EveryYear_DifferentDaysInMonth() { // Arrange. IRecurring yearly = Recurs .Starting(new DateTime(2015, 1, 1)) .Every(1) .Years() .OnDay(31) .OnMonths(Month.JANUARY | Month.FEBRUARY | Month.AUGUST) .Ending(new DateTime(2020, 1, 1)) .Build(); // Act. // Assert. Assert.Equal(new DateTime(2015, 1, 31), yearly.Next(new DateTime(2014, 1, 1))); Assert.Equal(new DateTime(2015, 1, 31), yearly.Next(new DateTime(2015, 1, 6))); Assert.Equal(new DateTime(2015, 2, 28), yearly.Next(new DateTime(2015, 1, 31))); Assert.Equal(new DateTime(2015, 2, 28), yearly.Next(new DateTime(2015, 2, 27))); Assert.Equal(new DateTime(2015, 8, 31), yearly.Next(new DateTime(2015, 2, 28))); Assert.Null(yearly.Next(new DateTime(2020, 1, 1))); Assert.Equal(new DateTime(2015, 1, 31), yearly.Previous(new DateTime(2015, 2, 1))); Assert.Equal(new DateTime(2015, 1, 31), yearly.Previous(new DateTime(2015, 2, 28))); Assert.Equal(new DateTime(2015, 2, 28), yearly.Previous(new DateTime(2015, 3, 1))); Assert.Equal(new DateTime(2015, 2, 28), yearly.Previous(new DateTime(2015, 3, 1))); Assert.Equal(new DateTime(2015, 8, 31), yearly.Previous(new DateTime(2015, 9, 1))); Assert.Null(yearly.Previous(new DateTime(2015, 1, 31))); }
public void Daily_EveryThirdDay_ExcludeWeekends() { // Arrange. IRecurring daily = Recurs .Starting(new DateTime(2015, 1, 1)) .Every(3) .Days() .Including(Day.MONDAY | Day.TUESDAY | Day.WEDNESDAY | Day.THURSDAY | Day.FRIDAY) .Build(); // Act. // Assert. Assert.Equal(new DateTime(2015, 1, 1), daily.Next(new DateTime(2014, 7, 3))); Assert.Equal(new DateTime(2015, 1, 6), daily.Next(new DateTime(2015, 1, 1))); Assert.Equal(new DateTime(2015, 1, 9), daily.Next(new DateTime(2015, 1, 6))); Assert.Equal(new DateTime(2015, 1, 14), daily.Next(new DateTime(2015, 1, 9))); Assert.Equal(new DateTime(2015, 1, 1), daily.Previous(new DateTime(2015, 1, 2))); Assert.Equal(new DateTime(2015, 1, 6), daily.Previous(new DateTime(2015, 1, 7))); Assert.Equal(new DateTime(2015, 1, 9), daily.Previous(new DateTime(2015, 1, 10))); Assert.Equal(new DateTime(2015, 1, 14), daily.Previous(new DateTime(2015, 1, 15))); }
public void Weekly_Every2Weeks_SunMon() { // Arrange. DateTime startDate = new DateTime(2018, 2, 22); IRecurring weekly = Recurs .Starting(startDate) .Every(2) .Weeks() .FirstDayOfWeek(DayOfWeek.Monday) .OnDays(Day.SUNDAY | Day.MONDAY) .Ending(new DateTime(2018, 8, 28)) .Build(); // Act. // Assert. Assert.Equal(new DateTime(2018, 2, 25), weekly.Next(new DateTime(2018, 2, 24))); Assert.Equal(new DateTime(2018, 3, 5), weekly.Next(new DateTime(2018, 2, 25))); Assert.Equal(new DateTime(2018, 3, 5), weekly.Next(new DateTime(2018, 3, 3))); Assert.Equal(new DateTime(2018, 3, 11), weekly.Next(new DateTime(2018, 3, 5))); Assert.Equal(new DateTime(2018, 3, 19), weekly.Next(new DateTime(2018, 3, 11))); Assert.Equal(new DateTime(2018, 3, 25), weekly.Next(new DateTime(2018, 3, 20))); Assert.Equal(new DateTime(2018, 4, 2), weekly.Next(new DateTime(2018, 4, 1))); Assert.Equal(new DateTime(2018, 4, 8), weekly.Next(new DateTime(2018, 4, 3))); Assert.Null(weekly.Next(new DateTime(2018, 8, 28))); Assert.Equal(new DateTime(2018, 2, 25), weekly.Previous(new DateTime(2018, 2, 26))); Assert.Equal(new DateTime(2018, 3, 5), weekly.Previous(new DateTime(2018, 3, 6))); Assert.Equal(new DateTime(2018, 3, 5), weekly.Previous(new DateTime(2018, 3, 11))); Assert.Equal(new DateTime(2018, 3, 11), weekly.Previous(new DateTime(2018, 3, 12))); Assert.Equal(new DateTime(2018, 3, 19), weekly.Previous(new DateTime(2018, 3, 25))); Assert.Equal(new DateTime(2018, 3, 25), weekly.Previous(new DateTime(2018, 4, 2))); Assert.Equal(new DateTime(2018, 4, 2), weekly.Previous(new DateTime(2018, 4, 3))); Assert.Equal(new DateTime(2018, 4, 8), weekly.Previous(new DateTime(2018, 4, 9))); Assert.Null(weekly.Previous(new DateTime(2018, 2, 25))); }
public void Yearly_EveryYear_TwoMonthsAfterDateTime() { // Arrange. var startDate = new DateTime(2015, 1, 1); IRecurring yearly = Recurs .Starting(startDate) .Every(1) .Years() .OnDay(24) .OnMonth(startDate.AddMonths(2)) .Ending(new DateTime(2020, 1, 1)) .Build(); // Act. // Assert. Assert.Equal(new DateTime(2015, 3, 24), yearly.Next(new DateTime(2014, 1, 1))); Assert.Equal(new DateTime(2015, 3, 24), yearly.Next(new DateTime(2015, 1, 1))); Assert.Equal(new DateTime(2015, 3, 24), yearly.Next(new DateTime(2015, 1, 23))); Assert.Equal(new DateTime(2016, 3, 24), yearly.Next(new DateTime(2015, 3, 24))); Assert.Equal(new DateTime(2016, 3, 24), yearly.Next(new DateTime(2015, 3, 25))); Assert.Equal(new DateTime(2016, 3, 24), yearly.Next(new DateTime(2015, 10, 1))); Assert.Equal(new DateTime(2016, 3, 24), yearly.Next(new DateTime(2015, 10, 23))); Assert.Equal(new DateTime(2016, 3, 24), yearly.Next(new DateTime(2015, 10, 24))); Assert.Equal(new DateTime(2017, 3, 24), yearly.Next(new DateTime(2016, 3, 24))); Assert.Equal(new DateTime(2017, 3, 24), yearly.Next(new DateTime(2016, 4, 24))); Assert.Null(yearly.Next(new DateTime(2020, 1, 1))); Assert.Equal(new DateTime(2015, 3, 24), yearly.Previous(new DateTime(2015, 3, 25))); Assert.Equal(new DateTime(2015, 3, 24), yearly.Previous(new DateTime(2015, 10, 25))); Assert.Equal(new DateTime(2015, 3, 24), yearly.Previous(new DateTime(2016, 3, 24))); Assert.Equal(new DateTime(2016, 3, 24), yearly.Previous(new DateTime(2016, 3, 25))); Assert.Equal(new DateTime(2016, 3, 24), yearly.Previous(new DateTime(2017, 3, 24))); Assert.Equal(new DateTime(2017, 3, 24), yearly.Previous(new DateTime(2017, 3, 25))); Assert.Equal(new DateTime(2017, 3, 24), yearly.Previous(new DateTime(2018, 3, 24))); Assert.Null(yearly.Previous(new DateTime(2015, 3, 24))); }
public void Daily_EveryThirdDay() { // Arrange. IRecurring daily = Recurs .Starting(new DateTime(2015, 1, 1)) .Every(3) .Days() .Build(); // Act. // Assert. Assert.Equal(new DateTime(2015, 1, 1), daily.Next(new DateTime(2014, 7, 3))); Assert.Equal(new DateTime(2015, 1, 4), daily.Next(new DateTime(2015, 1, 1))); Assert.Equal(new DateTime(2015, 1, 7), daily.Next(new DateTime(2015, 1, 5))); Assert.Equal(new DateTime(2015, 1, 1), daily.Previous(new DateTime(2015, 1, 2))); Assert.Equal(new DateTime(2015, 1, 1), daily.Previous(new DateTime(2015, 1, 3))); Assert.Equal(new DateTime(2015, 1, 1), daily.Previous(new DateTime(2015, 1, 4))); Assert.Equal(new DateTime(2015, 1, 4), daily.Previous(new DateTime(2015, 1, 5))); Assert.Equal(new DateTime(2015, 1, 4), daily.Previous(new DateTime(2015, 1, 6))); Assert.Equal(new DateTime(2015, 1, 4), daily.Previous(new DateTime(2015, 1, 7))); Assert.Equal(new DateTime(2015, 1, 7), daily.Previous(new DateTime(2015, 1, 8))); }
public void Yearly_EveryYear() { // Arrange. IRecurring yearly = Recurs .Starting(new DateTime(2015, 1, 1)) .Every(1) .Years() .OnDay(24) .OnMonths(Month.JANUARY | Month.FEBRUARY | Month.AUGUST) .Ending(new DateTime(2020, 1, 1)) .Build(); // Act. // Assert. Assert.Equal(new DateTime(2015, 1, 24), yearly.Next(new DateTime(2014, 1, 1))); Assert.Equal(new DateTime(2015, 1, 24), yearly.Next(new DateTime(2015, 1, 1))); Assert.Equal(new DateTime(2015, 1, 24), yearly.Next(new DateTime(2015, 1, 23))); Assert.Equal(new DateTime(2015, 2, 24), yearly.Next(new DateTime(2015, 1, 24))); Assert.Equal(new DateTime(2015, 2, 24), yearly.Next(new DateTime(2015, 1, 25))); Assert.Equal(new DateTime(2015, 2, 24), yearly.Next(new DateTime(2015, 2, 1))); Assert.Equal(new DateTime(2015, 2, 24), yearly.Next(new DateTime(2015, 2, 23))); Assert.Equal(new DateTime(2015, 8, 24), yearly.Next(new DateTime(2015, 2, 24))); Assert.Equal(new DateTime(2015, 8, 24), yearly.Next(new DateTime(2015, 3, 24))); Assert.Equal(new DateTime(2015, 8, 24), yearly.Next(new DateTime(2015, 4, 24))); Assert.Equal(new DateTime(2015, 8, 24), yearly.Next(new DateTime(2015, 5, 24))); Assert.Equal(new DateTime(2015, 8, 24), yearly.Next(new DateTime(2015, 6, 24))); Assert.Equal(new DateTime(2015, 8, 24), yearly.Next(new DateTime(2015, 7, 24))); Assert.Equal(new DateTime(2016, 1, 24), yearly.Next(new DateTime(2015, 8, 24))); Assert.Equal(new DateTime(2016, 2, 24), yearly.Next(new DateTime(2016, 1, 24))); Assert.Null(yearly.Next(new DateTime(2020, 1, 1))); Assert.Equal(new DateTime(2015, 1, 24), yearly.Previous(new DateTime(2015, 1, 25))); Assert.Equal(new DateTime(2015, 1, 24), yearly.Previous(new DateTime(2015, 2, 23))); Assert.Equal(new DateTime(2015, 1, 24), yearly.Previous(new DateTime(2015, 2, 24))); Assert.Equal(new DateTime(2015, 2, 24), yearly.Previous(new DateTime(2015, 2, 25))); Assert.Equal(new DateTime(2015, 2, 24), yearly.Previous(new DateTime(2015, 3, 25))); Assert.Equal(new DateTime(2015, 2, 24), yearly.Previous(new DateTime(2015, 4, 25))); Assert.Equal(new DateTime(2015, 2, 24), yearly.Previous(new DateTime(2015, 7, 25))); Assert.Equal(new DateTime(2015, 8, 24), yearly.Previous(new DateTime(2015, 8, 25))); Assert.Equal(new DateTime(2015, 8, 24), yearly.Previous(new DateTime(2015, 9, 25))); Assert.Equal(new DateTime(2015, 8, 24), yearly.Previous(new DateTime(2015, 10, 25))); Assert.Equal(new DateTime(2015, 8, 24), yearly.Previous(new DateTime(2015, 12, 25))); Assert.Equal(new DateTime(2015, 8, 24), yearly.Previous(new DateTime(2016, 1, 1))); Assert.Equal(new DateTime(2015, 8, 24), yearly.Previous(new DateTime(2016, 1, 24))); Assert.Equal(new DateTime(2016, 1, 24), yearly.Previous(new DateTime(2016, 1, 25))); Assert.Equal(new DateTime(2016, 2, 24), yearly.Previous(new DateTime(2016, 2, 25))); Assert.Null(yearly.Previous(new DateTime(2015, 1, 24))); Assert.Null(yearly.Previous(new DateTime(2015, 1, 1))); Assert.Null(yearly.Previous(new DateTime(2014, 1, 24))); }