/// <summary>
        /// Converts the specified pattern.
        /// </summary>
        /// <param name="pattern">The pattern.</param>
        /// <param name="defaultOccurrence">The default occurrence.</param>
        /// <returns></returns>
        public static OccurrenceCollection Convert(RelativeYearlyPattern pattern, Occurrence defaultOccurrence)
        {
            Expression <Func <DateTime, DateTime> > predicate = previousDate => previousDate
                                                                .AddRelativeYears(1, pattern.Month, pattern.DayOfTheWeek, pattern.DayOfTheWeekIndex);

            return(Convert(pattern, defaultOccurrence, predicate));
        }
            /// <summary>
            /// Checks if two recurrence objects are identical.
            /// </summary>
            /// <param name="otherRecurrence">The recurrence to compare this one to.</param>
            /// <returns>true if the two recurrences are identical, false otherwise.</returns>
            public override bool IsSame(Recurrence otherRecurrence)
            {
                RelativeYearlyPattern otherYearlyPattern = (RelativeYearlyPattern)otherRecurrence;

                return(base.IsSame(otherRecurrence) &&
                       this.dayOfTheWeek == otherYearlyPattern.dayOfTheWeek &&
                       this.dayOfTheWeekIndex == otherYearlyPattern.dayOfTheWeekIndex &&
                       this.month == otherYearlyPattern.month);
            }
Exemple #3
0
 bool IsSame(Recurrence otherRecurrence)
            {
                RelativeYearlyPattern otherYearlyPattern = (RelativeYearlyPattern)otherRecurrence;

                return super.IsSame();otherRecurrence) &&
                       this.dayOfTheWeek == otherYearlyPattern.dayOfTheWeek &&
                       this.dayOfTheWeekIndex == otherYearlyPattern.dayOfTheWeekIndex &&
                       this.month == otherYearlyPattern.month;
            }
        public void ShouldContainRelativeYearlyOccurences()
        {
            var date = DateTime.Parse("2017-01-01T00:00:00");

            var pattern = new RelativeYearlyPattern(date, Month.January, DayOfTheWeek.Sunday, DayOfTheWeekIndex.First)
            {
                EndDate = DateTime.Now.Date.AddYears(2)
            };

            var occurrence = new Occurrence {
                Start = date, End = date.AddHours(1)
            };

            var result = PatternConverter.Convert(pattern, occurrence);

            Assert.Equal(3, result.Count);
            Assert.Equal(date, result.First().Start);
        }