Ejemplo n.º 1
0
        public DateTime CheckDate(DateTime dueDate)
        {
            //throw new NotImplementedException();
            while (true)
            {
                if ((dueDate.DayOfWeek == DayOfWeek.Saturday) ||
                    (dueDate.DayOfWeek == DayOfWeek.Sunday) ||
                    holidayService.isHoliday(dueDate))
                {
                    dueDate = dueDate.AddDays(1);
                }
                else
                {
                    return(dueDate);
                }
            }
            //if (dueDate.DayOfWeek == DayOfWeek.Saturday )
            //{
            //    return dueDate.AddDays(2);
            //}
            //if (dueDate.DayOfWeek == DayOfWeek.Sunday)
            //{
            //    return dueDate.AddDays(1);
            //}
            //if (holidayService.isHoliday(dueDate))// test case 4
            //{
            //    return dueDate.AddDays(1);
            //}
            //if (holidayService.isHoliday(dueDate))// test case 5
            //{
            //    return dueDate.AddDays(3);
            //}

            //return dueDate;
        }
Ejemplo n.º 2
0
        public void ifHoliday_ReturnNonHoliday()
        {
            var      holidayOrNot = new HolidayService <IHolidayService>();
            bool     notHoliday   = false;
            DateTime dueDate      = new DateTime(2019, 12, 25);
            var      check        = holidayOrNot.isHoliday(dueDate);

            if (check == true)
            {
                notHoliday = true;
            }

            Assert.AreEqual(notHoliday, check);
        }
Ejemplo n.º 3
0
        public void IfHolidayReturnWeekday()
        {
            var      holiday  = new HolidayService <IHolidayService>();
            DateTime holiDate = new DateTime(2018, 9, 20);
            var      check    = holiday.isHoliday(holiDate);
            bool     weekDay  = false;

            if (check == true)
            {
                DateTime nextDay = holiDate.AddDays(1);
                if (nextDay.DayOfWeek != DayOfWeek.Saturday || nextDay.DayOfWeek != DayOfWeek.Sunday)
                {
                    weekDay = true;
                }
                else
                {
                    nextDay.AddDays(1);
                }
            }

            Assert.AreEqual(check, weekDay);
        }