public void CalculatedRecurrenceSetEnforcesExcludedDates() { #region Arrange var validStartDateTime = new DateTime(2014, 2, 17); const int validWeeksBetweenOccurrences = 1; var validIncludedWeekDays = new List<DayOfWeek> { DayOfWeek.Monday, DayOfWeek.Wednesday, DayOfWeek.Saturday }; // end on Saturday two weeks from the start date DateTime validEndDateTime = validStartDateTime.AddDays(DayOfWeek.Saturday - DayOfWeek.Monday).AddDays(7*2); var validWeeklyRecurrence = new WeeklyRecurrence(validStartDateTime, validWeeksBetweenOccurrences, validIncludedWeekDays, validEndDateTime); validWeeklyRecurrence.Exclude(new DateTime(2014, 2, 22)); #endregion #region Act IEnumerable<DateTime> recurrenceSet = validWeeklyRecurrence.CalculateRecurrenceSet(); #endregion #region Assert var expectedRecurrenceSet = new List<DateTime> { // DateTimes from first occurrence validStartDateTime, validStartDateTime.AddDays(DayOfWeek.Wednesday - DayOfWeek.Monday), // DateTimes from second occurrence validStartDateTime.AddDays(7*2), validStartDateTime.AddDays(DayOfWeek.Wednesday - DayOfWeek.Monday).AddDays(7*2), validStartDateTime.AddDays(DayOfWeek.Saturday - DayOfWeek.Monday).AddDays(7*2) }; Assert.IsTrue(expectedRecurrenceSet.SequenceEqual(recurrenceSet)); #endregion }