public void WeekdaysBetweenTwoDates_Should_Return_Expected_Data()
            {
                //Arrange
                var dateCounter = new BusinessDayCounter();
                var startDate1  = new DateTime(2013, 10, 7);
                var endDate1    = new DateTime(2013, 10, 9);
                var startDate2  = new DateTime(2013, 10, 5);
                var endDate2    = new DateTime(2013, 10, 14);
                var startDate3  = new DateTime(2013, 10, 7);
                var endDate3    = new DateTime(2014, 1, 1);
                var startDate4  = new DateTime(2013, 10, 7);
                var endDate4    = new DateTime(2013, 10, 5);

                //Act
                var weekDaysQty1 = dateCounter.WeekdaysBetweenTwoDates(startDate1, endDate1);
                var weekDaysQty2 = dateCounter.WeekdaysBetweenTwoDates(startDate2, endDate2);
                var weekDaysQty3 = dateCounter.WeekdaysBetweenTwoDates(startDate3, endDate3);
                var weekDaysQty4 = dateCounter.WeekdaysBetweenTwoDates(startDate4, endDate4);

                //Assert
                Assert.AreEqual(1, weekDaysQty1);
                Assert.AreEqual(5, weekDaysQty2);
                Assert.AreEqual(61, weekDaysQty3);
                Assert.AreEqual(0, weekDaysQty4);
            }
예제 #2
0
        public void WeekdaysBetweenTwoDatesTest()
        {
            BusinessDayCounter counter = new BusinessDayCounter();

            var firstDate      = new DateTime(2013, 10, 7);
            var secondDate     = new DateTime(2013, 10, 9);
            var expectedResult = 1;

            Assert.AreEqual(expectedResult, counter.WeekdaysBetweenTwoDates(firstDate, secondDate));

            firstDate      = new DateTime(2013, 10, 5);
            secondDate     = new DateTime(2013, 10, 14);
            expectedResult = 5;
            Assert.AreEqual(expectedResult, counter.WeekdaysBetweenTwoDates(firstDate, secondDate));

            firstDate      = new DateTime(2013, 10, 7);
            secondDate     = new DateTime(2014, 1, 1);
            expectedResult = 61;
            Assert.AreEqual(expectedResult, counter.WeekdaysBetweenTwoDates(firstDate, secondDate));

            firstDate      = new DateTime(2013, 10, 7);
            secondDate     = new DateTime(2013, 10, 5);
            expectedResult = 0;
            Assert.AreEqual(expectedResult, counter.WeekdaysBetweenTwoDates(firstDate, secondDate));
        }
예제 #3
0
        public void WeekdaysBetweenTwoDates_ShouldReturnGoodValueForCorrectData(int[] firstDataSet, int[] secondDataSet, int expected)
        {
            var firstDate  = ArrayToDate(firstDataSet);
            var secondDate = ArrayToDate(secondDataSet);
            var result     = businessDayCounter.WeekdaysBetweenTwoDates(firstDate, secondDate);

            Assert.Equal(expected, result);
        }
예제 #4
0
        public void WeekdaysBetweenTwoDatesReturns0WhenSecondEqualsFirst()
        {
            var firstDate  = DateTime.Now;
            var secondDate = firstDate;

            int expectedResult = 0;
            var actualResult   = _counter.WeekdaysBetweenTwoDates(firstDate, secondDate);

            Assert.Equal(expectedResult, actualResult);
        }
예제 #5
0
        public void WeekdaysBetweenTwoDatesStartDatetNotBeforeOrEqualToEndDateReturnsZero()
        {
            //Arrange
            var expected  = 0;
            var startDate = new DateTime(2013, 10, 07);
            var endDate   = new DateTime(2013, 10, 05);

            //Act
            var actual = _businessDaysService.WeekdaysBetweenTwoDates(startDate, endDate);

            //Assert
            Assert.AreEqual(expected, actual);
        }
예제 #6
0
        public void WeekdaysBetweenTwoDates_With_valid_data_Should_return_weekdays(DateTime startDate, DateTime endDate, int expected)
        {
            var businessDayCounter = new BusinessDayCounter();
            int result             = businessDayCounter.WeekdaysBetweenTwoDates(startDate, endDate);

            Assert.IsTrue(result == expected);
        }
예제 #7
0
        public void TestWeekdaysBetweenTwoDates()
        {
            DateTime first    = new DateTime(2013, 10, 5);
            DateTime second   = new DateTime(2013, 10, 14);
            int      weekdays = BusinessDayCounter.WeekdaysBetweenTwoDates(first, second);

            Assert.AreEqual(weekdays, 5);
        }
예제 #8
0
        public void WeekdaysBetweenTwoDatesTest(DateTime firstDate, DateTime secondDate, Action <int> assertion)
        {
            var _publicHolidayProvider = new PublicHolidayProvider();

            var businessDayCounter = new BusinessDayCounter(_publicHolidayProvider);

            var daysCount = businessDayCounter.WeekdaysBetweenTwoDates(firstDate, secondDate);

            assertion(daysCount);
        }
        public void WeekdaysBetweenTwoDates_WhenDatesAreTheSame_ThenReturnZero()
        {
            var businessDayCounter = new BusinessDayCounter();
            var date           = new DateTime(2020, 12, 11);
            var expectedResult = 0;

            var result = businessDayCounter.WeekdaysBetweenTwoDates(date, date);

            Assert.AreEqual(expectedResult, result);
        }
예제 #10
0
        public void WeekdaysBetweenTwoDatesReturns0WhenFirstAfterSecond()
        {
            var counter    = new BusinessDayCounter();
            var firstDate  = DateTime.Now;
            var secondDate = firstDate.AddDays(-1);
            int expected   = 0;
            var actual     = counter.WeekdaysBetweenTwoDates(firstDate, secondDate);

            Assert.Equal(expected, actual);
        }
        public void WeekdaysBetweenTwoDates_WhenTheYearIsNotALeapYear_ThenReturn261()
        {
            var businessDayCounter = new BusinessDayCounter();
            var firstDate          = new DateTime(2018, 12, 31);
            var secondDate         = new DateTime(2020, 01, 01);
            var expectedResult     = 261;

            var result = businessDayCounter.WeekdaysBetweenTwoDates(firstDate, secondDate);

            Assert.AreEqual(expectedResult, result);
        }
        public void WeekdaysBetweenTwoDates_WhenSecondDateIsOneDayMoreThenFirstDate_ThenReturnZero()
        {
            var businessDayCounter = new BusinessDayCounter();
            var firstDate          = new DateTime(2020, 12, 10);
            var secondDate         = new DateTime(2020, 12, 11);
            var expectedResult     = 0;

            var result = businessDayCounter.WeekdaysBetweenTwoDates(firstDate, secondDate);

            Assert.AreEqual(expectedResult, result);
        }
        public void WeekdaysBetweenTwoDates_WhenSecondDateIsTwoDaysMoreThenFirstDate_ThenReturnOne()
        {
            var businessDayCounter = new BusinessDayCounter();
            var firstDate          = new DateTime(2013, 10, 07);
            var secondDate         = new DateTime(2013, 10, 09);
            var expectedResult     = 1;

            var result = businessDayCounter.WeekdaysBetweenTwoDates(firstDate, secondDate);

            Assert.AreEqual(expectedResult, result);
        }
        public void WeekdaysBetweenTwoDates_WhenDatesAreThreeMonthsApart_ThenReturn61()
        {
            var businessDayCounter = new BusinessDayCounter();
            var firstDate          = new DateTime(2013, 10, 07);
            var secondDate         = new DateTime(2014, 01, 01);
            var expectedResult     = 61;

            var result = businessDayCounter.WeekdaysBetweenTwoDates(firstDate, secondDate);

            Assert.AreEqual(expectedResult, result);
        }
        public void WeekdaysBetweenTwoDates_WhereDatesHaveTime_ThenReturnFive()
        {
            var businessDayCounter = new BusinessDayCounter();
            var firstDate          = new DateTime(2013, 10, 05, 12, 59, 30);
            var secondDate         = new DateTime(2013, 10, 14, 10, 30, 30);
            var expectedResult     = 5;

            var result = businessDayCounter.WeekdaysBetweenTwoDates(firstDate, secondDate);

            Assert.AreEqual(expectedResult, result);
        }
예제 #16
0
        public void TestCountWeekdays()
        {
            var counter = new BusinessDayCounter();

            var beginDate = new DateTime(2013, 10, 7);
            var endDate   = new DateTime(2013, 10, 9);

            Assert.AreEqual(counter.WeekdaysBetweenTwoDates(beginDate, endDate), 1);

            beginDate = new DateTime(2013, 10, 5);
            endDate   = new DateTime(2013, 10, 14);
            Assert.AreEqual(counter.WeekdaysBetweenTwoDates(beginDate, endDate), 5);

            beginDate = new DateTime(2013, 10, 7);
            endDate   = new DateTime(2014, 1, 1);
            Assert.AreEqual(counter.WeekdaysBetweenTwoDates(beginDate, endDate), 61);

            beginDate = new DateTime(2013, 10, 7);
            endDate   = new DateTime(2013, 10, 5);
            Assert.AreEqual(counter.WeekdaysBetweenTwoDates(beginDate, endDate), 0);
        }
예제 #17
0
        public void Task1_Calculate_Weekdays_Between_TwoDates(string firstDate, string secondDate, int expectedCount)
        {
            //Given two dates
            var testFirstDate   = DateTime.ParseExact(firstDate, "d/M/yyyy", CultureInfo.InvariantCulture);
            var testSecondtDate = DateTime.ParseExact(secondDate, "d/M/yyyy", CultureInfo.InvariantCulture);

            //When I count the weekdays between the two dates
            var actualCount = BusinessDayCounter.WeekdaysBetweenTwoDates(testFirstDate, testSecondtDate);

            //Then the count should exclude weekends
            Assert.Equal(expectedCount, actualCount);
        }
예제 #18
0
        public void CountWeekdays_ValidInput_Calculated()
        {
            Assert.AreEqual(5, BusinessDayCounter.WeekdaysBetweenTwoDates(new DateTime(2013, 10, 5), new DateTime(2013, 10, 14)));

            Assert.AreEqual(0, BusinessDayCounter.WeekdaysBetweenTwoDates(new DateTime(2019, 10, 25), new DateTime(2019, 10, 28)));

            Assert.AreEqual(1, BusinessDayCounter.WeekdaysBetweenTwoDates(new DateTime(2013, 10, 7), new DateTime(2013, 10, 9)));

            Assert.AreEqual(5, BusinessDayCounter.WeekdaysBetweenTwoDates(new DateTime(2013, 10, 5), new DateTime(2013, 10, 14)));

            Assert.AreEqual(61, BusinessDayCounter.WeekdaysBetweenTwoDates(new DateTime(2013, 10, 7), new DateTime(2014, 1, 1)));

            Assert.AreEqual(4, BusinessDayCounter.WeekdaysBetweenTwoDates(new DateTime(2015, 1, 8), new DateTime(2015, 1, 15)));
        }
예제 #19
0
        public void WeekdaysBetweenTwoDates_GivesExpectedResult(DateTime firstDate, DateTime secondDate, int expectedResult)
        {
            var weekdays = _businessDayCounter.WeekdaysBetweenTwoDates(firstDate, secondDate);

            Assert.Equal(weekdays, expectedResult);
        }
예제 #20
0
        public void FirstTestForWeekDaysBetweenTwoDates()
        {
            var result = bdc.WeekdaysBetweenTwoDates(new DateTime(2013, 10, 7), new DateTime(2013, 10, 9));

            Assert.That(result, Is.EqualTo(1));
        }
        public int TestWeekdaysBetweenTwoDates(DateTime startDate, DateTime endDate)
        {
            var underTest = new BusinessDayCounter();

            return(underTest.WeekdaysBetweenTwoDates(startDate, endDate));
        }
예제 #22
0
 public void CountWeekdays_NegativeRange_ReturnZero()
 {
     Assert.AreEqual(0, BusinessDayCounter.WeekdaysBetweenTwoDates(new DateTime(2013, 10, 7), new DateTime(2013, 10, 5)));
 }
예제 #23
0
        public void CalculateWeekdaysBetweenTwoDates(DateTime firstDate, DateTime secondDate, int expectedResults)
        {
            var results = counter.WeekdaysBetweenTwoDates(firstDate, secondDate);

            Assert.AreEqual(expectedResults, results);
        }