예제 #1
0
        ShouldBusinessDaysBetweenTwoDates_Throw_Exception_When_Given_EndDate_Is_Later_Or_Equal_StartDate()
        {
            var businessDayCounterService = new BusinessDayCounterService();

            Assert.Throws <ArgumentException>(() => businessDayCounterService.BusinessDaysBetweenTwoDates(
                                                  new DateTime(2014, 06, 20),
                                                  new DateTime(2014, 06, 10),
                                                  new List <IPublicHoliday>()
            {
            }
                                                  ));
        }
예제 #2
0
        ShouldBusinessDaysBetweenTwoDates_Returns_NumbersOfDaysBetween_TwoDates_With_Given_On_The_Same_Day_As_far_As_It_Is_not_Weekend()
        {
            var businessDayCounterService     = new BusinessDayCounterService();
            var followingWeekDayPublicHoliday = new FollowingWeekdayPublicHoliday(1, 1);
            var result = businessDayCounterService.BusinessDaysBetweenTwoDates(
                new DateTime(2013, 12, 25),
                new DateTime(2014, 1, 5),
                new List <IPublicHoliday>()
            {
                followingWeekDayPublicHoliday
            }
                );

            Assert.Equal(6, result);
        }
예제 #3
0
        ShouldBusinessDaysBetweenTwoDates_Returns_NumbersOfDaysBetween_TwoDates_With_Given_Certain_Occurrence_On_A_Certain_Day_In_A_Month()
        {
            var businessDayCounterService = new BusinessDayCounterService();
            var dayInMonthHoliday         =
                new DayInMonthHoliday(6, DayOfWeek.Monday,
                                      2); //Queen's Birthday on the second Monday of June every Year
            var result = businessDayCounterService.BusinessDaysBetweenTwoDates(
                new DateTime(2014, 06, 01),
                new DateTime(2014, 06, 23),
                new List <IPublicHoliday>()
            {
                dayInMonthHoliday
            }
                );

            Assert.Equal(14, result);
        }
예제 #4
0
        public async Task <IActionResult> CalculateBusinessDaysCounter(
            [Required][FromQuery] string startDate,
            [Required][FromQuery] string endDate
            )
        {
            (DateTime firstDate, DateTime secondDate) = ParseRequestDates(startDate, endDate);

            var publicHolidays = await _publicHolidaysProvider.QueryPublicHolidaysAsync();

            var result = _businessDayCounterService.BusinessDaysBetweenTwoDates(
                firstDate,
                secondDate,
                publicHolidays);

            return(Ok(new CalendarResponseViewModel()
            {
                NumberOfBusinessDays = result
            }));
        }
예제 #5
0
        ShouldBusinessDaysBetweenTwoDates_Returns_NumbersOfDaysBetween_TwoDates_With_Given_PublicHoliday_Dates(
            DateTime firstDate,
            DateTime secondDate,
            int expected)
        {
            var businessDayCounterService = new BusinessDayCounterService();
            var publicHolidays            =
                new List <DateTime>
            {
                new DateTime(2013, 12, 25),  // Christmas Day
                new DateTime(2013, 12, 26),  //Boxing Day
                new DateTime(2014, 1, 1)     // New Year's Day
            };
            var result =
                businessDayCounterService.BusinessDaysBetweenTwoDates(firstDate, secondDate, publicHolidays);


            Assert.Equal(expected, result);
        }