Пример #1
0
        public void TestDayOfWeek()
        {
            //Arrange
            MonthlySchedule itemMon = new MonthlySchedule
            {
                MonthlyTheNDayOfWeek = DayOfWeek.Monday
            };
            MonthlySchedule itemTue = new MonthlySchedule
            {
                MonthlyTheNDayOfWeek = DayOfWeek.Tuesday
            };
            MonthlySchedule itemWed = new MonthlySchedule
            {
                MonthlyTheNDayOfWeek = DayOfWeek.Wednesday
            };
            MonthlySchedule itemThu = new MonthlySchedule
            {
                MonthlyTheNDayOfWeek = DayOfWeek.Thursday
            };
            MonthlySchedule itemFri = new MonthlySchedule
            {
                MonthlyTheNDayOfWeek = DayOfWeek.Friday
            };
            MonthlySchedule itemSat = new MonthlySchedule
            {
                MonthlyTheNDayOfWeek = DayOfWeek.Saturday
            };
            MonthlySchedule itemSun = new MonthlySchedule
            {
                MonthlyTheNDayOfWeek = DayOfWeek.Sunday
            };

            //Act

            //Assert
            Assert.AreEqual(itemMon.GetMonthlyTheNDayOfWeekText(), "Monday");
            Assert.AreEqual(itemTue.GetMonthlyTheNDayOfWeekText(), "Tuesday");
            Assert.AreEqual(itemWed.GetMonthlyTheNDayOfWeekText(), "Wednesday");
            Assert.AreEqual(itemThu.GetMonthlyTheNDayOfWeekText(), "Thursday");
            Assert.AreEqual(itemFri.GetMonthlyTheNDayOfWeekText(), "Friday");
            Assert.AreEqual(itemSat.GetMonthlyTheNDayOfWeekText(), "Saturday");
            Assert.AreEqual(itemSun.GetMonthlyTheNDayOfWeekText(), "Sunday");
        }
Пример #2
0
        public void TestNullGetMonthlyTheNDayOfWeekText()
        {
            try
            {
                //Arrange
                MonthlySchedule month = new MonthlySchedule
                {
                    MonthlyTheNDayOfWeek = (DayOfWeek)100
                };

                //Act
                string result = month.GetMonthlyTheNDayOfWeekText();

                //Assert
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex.Message == "No day of the week found");
            }
        }
Пример #3
0
        public void TestEveryLastFridayFor3Months()
        {
            //Arrange
            MonthlySchedule item = new MonthlySchedule
            {
                RecurrenceType                = MonthlySchedule.RecurrenceTypeEnum.Monthly,
                MonthlyTheNDaySelected        = true,
                MonthlyTheNOccurrence         = MonthlySchedule.MonthlyTheNOccurrenceEnum.Last,
                MonthlyTheNDayOfWeek          = DayOfWeek.Friday,
                MonthlyTheNDayDayMonth        = 1,
                RecurrenceStartDate           = new System.DateTime(2019, 1, 25),
                RecurrenceEndAfterNSelected   = true,
                RecurrenceEndAfterNOccurences = 3
            };
            DateTime lastDate = item.NormalizeDate(new DateTime(2019, 3, 29)); //item.NormalizeDate(item.RecurrenceStartDate.AddMonths(item.MonthlyEveryNMonths * item.RecurrenceEndAfterNOccurences - item.MonthlyEveryNMonths));

            //Act
            item.ProcessFutureDates();

            //Assert
            Assert.AreEqual(item.Name, "Monthly the " + item.GetMonthlyTheNOccurrenceText() + " " + item.GetMonthlyTheNDayOfWeekText() + " of every " + item.MonthlyTheNDayDayMonth + " months for a total of " + item.RecurrenceEndAfterNOccurences + " FutureDates");
            DateTime[] dates = item.FutureDates.ToArray();
            Assert.AreEqual(lastDate, dates[dates.Length - 1]);
        }