public void GetRecurrency_Yearly_DayOfMonth()
        {
            var info = new RecurrencyInfo
            {
                Type = RecurrencyType.Yearly,
                StartDate = new DateTime(2011, 2, 01),
                EndDate = new DateTime(2011, 11, 30),
                YearlyInterval = 2,
                YearlyType = MonthlyType.MonthDay,
                YearlyDay = 14,
                YearlyMonth = 2
            };

            var recurrency = info.GetRecurrency();
            Assert.IsNotNull(recurrency);
            YearlyRecurrency yearly = recurrency as YearlyRecurrency;
            Assert.IsNotNull(yearly);

            Assert.AreEqual(new DateTime(2011, 2, 01), yearly.StartDate);
            Assert.AreEqual(new DateTime(2011, 11, 30), yearly.EndDate);
            Assert.AreEqual(0, yearly.Occurrences);

            Assert.AreEqual(2, yearly.Interval);
            Assert.AreEqual(MonthlyType.MonthDay, yearly.Type);
            Assert.AreEqual(14, yearly.Day);
            Assert.AreEqual(2, yearly.Month);
        }
        public void GetRecurrency_Yearly_DayOfWeek()
        {
            var info = new RecurrencyInfo
            {
                Type = RecurrencyType.Yearly,
                StartDate = new DateTime(2011, 2, 01),
                Occurrences = 6,
                YearlyInterval = 2,
                YearlyType = MonthlyType.Weekday,
                YearlyDayOfWeek = DayOfWeek.Tuesday,
                YearlyDayIndex = DayIndex.Third,
                YearlyMonth = 3
            };

            var recurrency = info.GetRecurrency();
            Assert.IsNotNull(recurrency);
            YearlyRecurrency yearly = recurrency as YearlyRecurrency;
            Assert.IsNotNull(yearly);

            Assert.AreEqual(new DateTime(2011, 2, 01), yearly.StartDate);
            Assert.IsNull(yearly.EndDate);
            Assert.AreEqual(6, yearly.Occurrences);
            Assert.AreEqual(2, yearly.Interval);
            Assert.AreEqual(MonthlyType.Weekday, yearly.Type);
            Assert.AreEqual(01, yearly.Day);
            Assert.AreEqual(DayOfWeek.Tuesday, yearly.DayOfWeek);
            Assert.AreEqual(DayIndex.Third, yearly.DayIndex);
            Assert.AreEqual(3, yearly.Month);
        }
        public void GetRecurrency_Monthly_DayOfWeek()
        {
            var info = new RecurrencyInfo
            {
                Type = RecurrencyType.Monthly,
                StartDate = new DateTime(2011, 2, 01),
                Occurrences = 6,
                MonthlyInterval = 2,
                MonthlyType = MonthlyType.Weekday,
                MonthlyDayOfWeek = DayOfWeek.Tuesday,
                MonthlyDayIndex = DayIndex.Third
            };

            var recurrency = info.GetRecurrency();
            Assert.IsNotNull(recurrency);
            MonthlyRecurrency monthly = recurrency as MonthlyRecurrency;
            Assert.IsNotNull(monthly);

            Assert.AreEqual(new DateTime(2011, 2, 01), monthly.StartDate);
            Assert.IsNull(monthly.EndDate);
            Assert.AreEqual(6, monthly.Occurrences);
            Assert.AreEqual(2, monthly.Interval);
            Assert.AreEqual(MonthlyType.Weekday, monthly.Type);
            Assert.AreEqual(01, monthly.Day);
            Assert.AreEqual(DayOfWeek.Tuesday, monthly.DayOfWeek);
            Assert.AreEqual(DayIndex.Third, monthly.DayIndex);
        }
        public void GetRecurrency_Monthly_DayOfMonth()
        {
            var info = new RecurrencyInfo
            {
                Type = RecurrencyType.Monthly,
                StartDate = new DateTime(2011, 2, 01),
                EndDate = new DateTime(2011, 11, 30),
                MonthlyInterval = 2,
                MonthlyType = MonthlyType.MonthDay,
                MonthlyDay=14
            };

            var recurrency = info.GetRecurrency();
            Assert.IsNotNull(recurrency);
            MonthlyRecurrency monthly = recurrency as MonthlyRecurrency;
            Assert.IsNotNull(monthly);

            Assert.AreEqual(new DateTime(2011, 2, 01), monthly.StartDate);
            Assert.AreEqual(new DateTime(2011, 11, 30), monthly.EndDate);
            Assert.AreEqual(0, monthly.Occurrences);

            Assert.AreEqual(2, monthly.Interval);
            Assert.AreEqual(MonthlyType.MonthDay, monthly.Type);
            Assert.AreEqual(14, monthly.Day);
        }
        public void GetRecurrency_Weekly_ByEndDate()
        {
            var info = new RecurrencyInfo
            {
                Type = RecurrencyType.Weekly,
                StartDate = new DateTime(2011, 5, 12),
                EndDate = new DateTime(2011, 10, 6),
                WeeklyInterval = 50
            };

            info.WeeklyDays = WeeklyRecurrency.WeekEnd;
            info.Monday = true;
            info.Tuesday = false;
            info.Wednesday = true;
            info.Thursday = false;
            info.Friday = true;
            info.Saturday = false;
            info.Sunday = false;

            var recurrency = info.GetRecurrency();
            Assert.IsNotNull(recurrency);
            WeeklyRecurrency weekly = recurrency as WeeklyRecurrency;
            Assert.IsNotNull(weekly);

            Assert.AreEqual(new DateTime(2011, 5, 12), weekly.StartDate);
            Assert.AreEqual(new DateTime(2011, 10, 6), weekly.EndDate);
            Assert.AreEqual(0, weekly.Occurrences);
            Assert.AreEqual(50, weekly.Interval);
            Assert.IsTrue(weekly.Monday);
            Assert.IsFalse(weekly.Tuesday);
            Assert.IsTrue(weekly.Wednesday);
            Assert.IsFalse(weekly.Thursday);
            Assert.IsTrue(weekly.Friday);
            Assert.IsFalse(weekly.Saturday);
            Assert.IsFalse(weekly.Sunday);
        }
        public void GetRecurrency_DailyWeekdays()
        {
            var info = new RecurrencyInfo { StartDate = new DateTime(2011, 5, 12), EndDate = new DateTime(2012, 11, 15), DailyType = DailyType.Weekdays, DailyInterval = 50, Type = RecurrencyType.Daily };
            var recurrency = info.GetRecurrency();
            Assert.IsNotNull(recurrency);
            DailyRecurrency daily = recurrency as DailyRecurrency;
            Assert.IsNotNull(daily);

            Assert.AreEqual(new DateTime(2011, 5, 12), daily.StartDate);
            Assert.AreEqual(new DateTime(2012, 11, 15), daily.EndDate);
            Assert.AreEqual(DailyType.Weekdays, daily.Type);
            Assert.AreEqual(1, daily.Interval);
        }
 public void GetRecurrency_DailyX()
 {
     var info = new RecurrencyInfo { StartDate = new DateTime(2011, 10, 7), Occurrences = 156, DailyType= DailyType.EveryXDays, DailyInterval=50, Type=RecurrencyType.Daily };
     var recurrency = info.GetRecurrency();
     Assert.IsNotNull(recurrency);
     DailyRecurrency daily = recurrency as DailyRecurrency;
     Assert.IsNotNull(daily);
     Assert.AreEqual(new DateTime(2011, 10, 7), daily.StartDate);
     Assert.IsNull(daily.EndDate);
     Assert.AreEqual(156, daily.Occurrences);
     Assert.AreEqual(DailyType.EveryXDays, daily.Type);
     Assert.AreEqual(50, daily.Interval);
 }