Beispiel #1
0
        public void ifHoliday_ReturnNonHoliday(int year, int month, int day)
        {
            var  input = new DateTime(year, month, day);
            var  mockHolidayService = new HolidayService();
            var  _bill     = new Bill(mockHolidayService);
            var  output    = _bill.CheckDate(input);
            bool isHoliday = mockHolidayService.isHoliday(output);

            Assert.IsFalse(isHoliday);
        }
        public void ifHolidayReturnNonHoliday()
        {
            var      holiday    = new HolidayService <IHolidayService>();
            DateTime dueDate    = new DateTime(2018, 12, 25);
            var      check      = holiday.isHoliday(dueDate);
            bool     notHoliday = false;

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

            Assert.AreEqual(check, notHoliday);
        }
Beispiel #3
0
        public DateTime CheckDate(DateTime dueDate)
        {
            var checkHoliday = new HolidayService();
            var paymentDate = dueDate;

            while(paymentDate.DayOfWeek == DayOfWeek.Saturday || 
                  paymentDate.DayOfWeek == DayOfWeek.Sunday ||
                  checkHoliday.isHoliday(paymentDate))
                  {
                      paymentDate = paymentDate.AddDays(1);
                  }
            // if(dueDate.DayOfWeek == DayOfWeek.Saturday)
            //     return dueDate.AddDays(2);
            // if(dueDate.DayOfWeek == DayOfWeek.Sunday)
            //     return dueDate.AddDays(1);

           return paymentDate; 
        }
        public void IfHolidayReturnWeekday()
        {
            var      holiday  = new HolidayService <IHolidayService>();
            DateTime holidate = new DateTime(2018, 12, 25);
            var      check    = holiday.isHoliday(holidate);
            bool     weekday  = false;

            if (check == true)
            {
                DateTime nextDay = holidate.AddDays(1);

                if (holidate.DayOfWeek != DayOfWeek.Saturday || holidate.DayOfWeek != DayOfWeek.Sunday)
                {
                    weekday = true;
                }
                else
                {
                    holidate.AddDays(1);
                }
            }

            Assert.AreEqual(check, weekday);
        }