public void TestControllerJSONGenerationForDay()
        {
            //Arrange
            int           numberOfRecurrences = 10;
            DailySchedule item = new DailySchedule
            {
                RecurrenceType                = DailySchedule.RecurrenceTypeEnum.Daily,
                DailyEveryNDaysSelected       = true,
                DailyEveryNDays               = 1,
                RecurrenceStartDate           = DateTime.Now,
                RecurrenceEndAfterNSelected   = true,
                RecurrenceEndAfterNOccurences = numberOfRecurrences
            };
            ScheduleItem scheduleItem = new ScheduleItem
            {
                DailySchedule = item
            };
            ScheduleItemController controller = new ScheduleItemController();

            //Act
            item.ProcessFutureDates();
            string       json          = controller.CreateJSON(scheduleItem);
            ScheduleItem processedItem = controller.ProcessJSON(json);

            //Assert
            Assert.IsTrue(json != null);
            Assert.AreEqual(processedItem.ScheduleItemType, "Daily");
            Assert.IsTrue(processedItem.DailySchedule != null);
            Assert.IsTrue(processedItem.WeeklySchedule == null);
            Assert.IsTrue(processedItem.MonthlySchedule == null);
            Assert.IsTrue(processedItem.YearlySchedule == null);
        }
Esempio n. 2
0
        public void TestEverySeventhDayForTenOccurences()
        {
            //Arrange
            int           numberOfRecurrences = 3;
            DailySchedule item = new DailySchedule
            {
                RecurrenceType                = DailySchedule.RecurrenceTypeEnum.Daily,
                DailyEveryNDaysSelected       = true,
                DailyEveryNDays               = 7,
                RecurrenceStartDate           = DateTime.Now,
                RecurrenceEndAfterNSelected   = true,
                RecurrenceEndAfterNOccurences = numberOfRecurrences
            };
            DateTime lastDate = item.NormalizeDate(item.RecurrenceStartDate.AddDays(numberOfRecurrences * item.DailyEveryNDays - item.DailyEveryNDays));

            //Act
            item.ProcessFutureDates();

            //Assert
            Assert.AreEqual(item.Name, "Daily every " + item.DailyEveryNDays + " days for a total of " + numberOfRecurrences + " FutureDates");
            DateTime[] dates = item.FutureDates.ToArray();
            Assert.AreEqual(lastDate, dates[dates.Length - 1]);
        }