Exemplo n.º 1
0
        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)));
        }
Exemplo n.º 2
0
        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)));
        }
Exemplo n.º 3
0
        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)));
        }
        public void Daily_EveryThirdDay()
        {
            // Arrange.
            IRecurring daily = Recurs
                               .Starting(new DateTime(2015, 1, 1))
                               .Every(3)
                               .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, 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, 13), daily.Next(new DateTime(2015, 1, 10)));
        }
Exemplo n.º 5
0
        public void Weekly_EveryWeek_SameTimeAsDateTime()
        {
            // Arrange.
            DateTime startDate = new DateTime(2020, 04, 06, 10, 00, 00);

            IRecurring weekly = Recurs
                                .Starting(startDate)
                                .Every(1)
                                .Weeks()
                                .OnDay(DayOfWeek.Monday)
                                .Ending(new DateTime(2021, 2, 19))
                                .Build();

            // Act.

            // Assert.
            Assert.Equal(new DateTime(2020, 04, 13, 10, 00, 00), weekly.Next(new DateTime(2020, 04, 06, 11, 00, 00)));
            Assert.Equal(new DateTime(2020, 04, 20, 10, 00, 00), weekly.Next(new DateTime(2020, 04, 13, 10, 00, 00)));
            Assert.Equal(new DateTime(2020, 04, 20, 10, 00, 00), weekly.Next(new DateTime(2020, 04, 20, 09, 00, 00)));
        }
        public void Weekly_EveryWeek()
        {
            // Arrange.
            IRecurring weekly = Recurs
                                .Starting(new DateTime(2015, 1, 1))
                                .Every(1)
                                .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, 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)));
        }
        public void Monthly_EveryMonth_Ordinal()
        {
            // Arrange.
            IRecurring monthly = Recurs
                                 .Starting(new DateTime(2018, 1, 1))// Monday
                                 .Every(1)
                                 .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, 2, 9), monthly.Next(new DateTime(2018, 2, 1)));
            Assert.Equal(new DateTime(2018, 9, 14), monthly.Next(new DateTime(2018, 9, 1)));
            Assert.Null(monthly.Next(new DateTime(2020, 2, 1)));
        }
        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)));
        }
Exemplo n.º 9
0
        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(2014, 1, 1)));
            Assert.Equal(new DateTime(2018, 1, 18), yearly.Next(new DateTime(2018, 1, 1)));
            Assert.Equal(new DateTime(2018, 1, 18), 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)));
        }
Exemplo n.º 10
0
        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)));
        }
Exemplo n.º 11
0
        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)));
        }
Exemplo n.º 12
0
        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)));
        }
Exemplo n.º 13
0
        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)));
        }
Exemplo n.º 14
0
        public void Monthly_EveryFirstMonth_Ordinal_SameDay()
        {
            // Arrange.
            IRecurring monthly = Recurs
                                 .Starting(new DateTime(2020, 04, 06, 13, 00, 00)) // Monday
                                 .Every(1)
                                 .Months()
                                 .OnOrdinalWeek(Ordinal.FIRST)
                                 .OnDay(DayOfWeek.Monday)
                                 .Build();

            // Act.

            // Assert.
            Assert.Equal(new DateTime(2020, 05, 04, 13, 00, 00), monthly.Next(new DateTime(2020, 04, 06, 14, 00, 00)));
        }
Exemplo n.º 15
0
        public void Monthly_EveryLastMonth_Ordinal_SameDay()
        {
            // Arrange.
            IRecurring monthly = Recurs
                                 .Starting(new DateTime(2019, 04, 30, 13, 00, 00)) // Tuesday
                                 .Every(1)
                                 .Months()
                                 .OnOrdinalWeek(Ordinal.LAST)
                                 .OnDay(DayOfWeek.Monday)
                                 .Build();

            // Act.

            // Assert.
            Assert.Equal(new DateTime(2019, 05, 27, 13, 00, 00), monthly.Next(new DateTime(2019, 05, 27, 09, 00, 00)));
        }
Exemplo n.º 16
0
        public void Yearly_EveryYear_Ordinal_Today()
        {
            // Arrange.
            var startDate = new DateTime(2019, 1, 1, 12, 00, 00);

            IRecurring yearly = Recurs
                                .Starting(startDate)
                                .Every(1)
                                .Years()
                                .OnOrdinalWeek(Ordinal.FIRST)
                                .OnDay(DayOfWeek.Monday)
                                .OnMonths(Month.JANUARY)
                                .Ending(new DateTime(2030, 1, 1))
                                .Build();

            // Act.

            // Assert.
            Assert.Equal(new DateTime(2020, 01, 6, 12, 00, 00), yearly.Next(new DateTime(2020, 01, 06, 08, 00, 00)));
        }
Exemplo n.º 17
0
        public void Yearly_EndAfterNumOfOccurences()
        {
            IRecurring recur = Recurs
                               .Starting(new DateTime(2015, 1, 1))
                               .Every(3)
                               .Years()
                               .OnDay(24)
                               .OnMonths(Month.JANUARY | Month.FEBRUARY | Month.AUGUST)
                               .Ending(6)
                               .Build();

            Assert.Equal(new DateTime(2015, 1, 24), recur.Next(new DateTime(2014, 2, 1)));
            Assert.Equal(new DateTime(2015, 2, 24), recur.Next(new DateTime(2015, 1, 24)));
            Assert.Equal(new DateTime(2015, 8, 24), recur.Next(new DateTime(2015, 2, 24)));
            Assert.Equal(new DateTime(2018, 1, 24), recur.Next(new DateTime(2015, 8, 24)));
            Assert.Equal(new DateTime(2018, 2, 24), recur.Next(new DateTime(2018, 1, 24)));
            Assert.Equal(new DateTime(2018, 8, 24), recur.Next(new DateTime(2018, 2, 24)));
            Assert.Null(recur.Next(new DateTime(2018, 8, 24)));
        }
Exemplo n.º 18
0
        public void Monthly_EveryThirdMonth()
        {
            // Arrange.
            IRecurring monthly = Recurs
                                 .Starting(new DateTime(2015, 1, 1))
                                 .Every(3)
                                 .Months()
                                 .OnDay(24)
                                 .Ending(new DateTime(2016, 2, 4))
                                 .Build();

            // Act.

            // Assert.
            Assert.Equal(new DateTime(2015, 1, 24), monthly.Next(new DateTime(2014, 2, 1)));
            Assert.Equal(new DateTime(2015, 4, 24), monthly.Next(new DateTime(2015, 1, 24)));
            Assert.Equal(new DateTime(2015, 4, 24), monthly.Next(new DateTime(2015, 1, 25)));
            Assert.Equal(new DateTime(2015, 4, 24), monthly.Next(new DateTime(2015, 2, 1)));
            Assert.Equal(new DateTime(2015, 4, 24), monthly.Next(new DateTime(2015, 2, 17)));
            Assert.Equal(new DateTime(2015, 4, 24), monthly.Next(new DateTime(2015, 4, 23)));
            Assert.Equal(new DateTime(2015, 7, 24), monthly.Next(new DateTime(2015, 4, 24)));
            Assert.Null(monthly.Next(new DateTime(2016, 6, 3)));
        }
Exemplo n.º 19
0
        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)));
        }
Exemplo n.º 20
0
        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)));
        }
Exemplo n.º 21
0
        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)));
        }