Exemplo n.º 1
0
        public void BusienssDaysBetweenTwoDatesWithHolidayRuleTest()
        {
            BusinessDayCounter counter = new BusinessDayCounter();

            List <HolidayRule> holidayRules = new List <HolidayRule>
            {
                new HolidayRule(25, 4),
                new HolidayRule(1, 1, true),
                new HolidayRule(6, 2, DayOfWeek.Monday)
            };

            var firstDate      = new DateTime(2011, 12, 29);
            var secondDate     = new DateTime(2012, 1, 3);
            var expectedResult = 1;

            Assert.AreEqual(expectedResult, counter.BusienssDaysBetweenTwoDates(firstDate, secondDate, holidayRules));

            firstDate      = new DateTime(2015, 4, 23);
            secondDate     = new DateTime(2015, 4, 28);
            expectedResult = 2;
            Assert.AreEqual(expectedResult, counter.BusienssDaysBetweenTwoDates(firstDate, secondDate, holidayRules));

            firstDate      = new DateTime(2021, 6, 2);
            secondDate     = new DateTime(2021, 6, 8);
            expectedResult = 3;
            Assert.AreEqual(expectedResult, counter.BusienssDaysBetweenTwoDates(firstDate, secondDate, holidayRules));

            firstDate      = new DateTime(2021, 6, 9);
            secondDate     = new DateTime(2021, 6, 15);
            expectedResult = 2;
            Assert.AreEqual(expectedResult, counter.BusienssDaysBetweenTwoDates(firstDate, secondDate, holidayRules));
        }