@@ -165,18 +165,29 @@ public void EventScheduledInstanceCommand_WithDateRangeInMonths_ReturnsExpectedE
165165 {
166166 var effectiveDate = EventsDataManager . Instance . GetDefaultEffectiveDate ( ) ;
167167
168- // Get the first Wednesday of the month, then the next two Wednesdays 4 weeks apart.
169- var date1 = effectiveDate . GetNextWeekday ( DayOfWeek . Wednesday ) ;
170-
171- var date2 = date1 . AddDays ( 12 * 7 ) ;
168+ // Get the first Wednesday of the month, then every other wednesday
169+ // until we hit the cutoff date of 3 months.
170+ var initialDate = effectiveDate . GetNextWeekday ( DayOfWeek . Wednesday ) ;
171+ var validDates = new List < DateTime > ( ) ;
172+ var invalidDates = new List < DateTime > ( ) ;
172173
173- // Staff Meeting recurs every 2 weeks, so our date range of 3 months should not include the first meeting in month 4.
174- var dateInvalid = RockDateTime . New ( date1 . Year , date1 . Month , 1 ) . Value . AddMonths ( 3 ) . GetNextWeekday ( DayOfWeek . Wednesday ) ;
174+ for ( var date = initialDate ; ; date = date . AddDays ( 14 ) )
175+ {
176+ if ( date < effectiveDate . AddMonths ( 3 ) )
177+ {
178+ validDates . Add ( date ) ;
179+ }
180+ else
181+ {
182+ invalidDates . Add ( date ) ;
183+ break ;
184+ }
185+ }
175186
176187 AssertTestEventOccurrences ( effectiveDate : null ,
177188 "3m" ,
178- validDateList : new List < DateTime > { date1 , date2 } ,
179- invalidDateList : new List < DateTime > { dateInvalid } ) ;
189+ validDateList : validDates ,
190+ invalidDateList : invalidDates ) ;
180191 }
181192
182193 [ TestMethod ]
0 commit comments