public void NextWorkDayShouldReturnSameDayWhenDateIsWorkDay()
 {
     var monday = new DateTime(2012, 4, 2);
     Assert.AreEqual(DayOfWeek.Monday, monday.DayOfWeek);
     var expected = monday;
     var actual = monday.NextWorkDay();
     Assert.AreEqual(expected, actual);
 }
        public void NextWorkDayShouldReturnNextTuesdayWhenHolydayCalculatorsSaysMondayIsHolidayAndDateIsSaturday()
        {
            var year = 2012;
            var monday = new DateTime(year, 4, 2);
            var saturday = monday.AddDays(-2);
            var sunday = monday.AddDays(-1);
            var tuesday = monday.AddDays(1);

            Assert.AreEqual(DayOfWeek.Monday, monday.DayOfWeek);
            var holydays = new[] { monday };
            var holydayCalculator = MockRepository.GenerateMock<IHolidayCalculator>();

            holydayCalculator.Expect(hc => hc.GetHolidays(year)).Return(holydays);

            Assert.AreEqual(tuesday, saturday.NextWorkDay(holydayCalculator));
            Assert.AreEqual(tuesday, sunday.NextWorkDay(holydayCalculator));
            Assert.AreEqual(tuesday, monday.NextWorkDay(holydayCalculator));
        }
        public void NextWorkDayShouldReturnNextMondayWhenHolydayCalculatorsSaysSundayIsHolydayAndDateIsSaturday()
        {
            const int year = 2011;
            var saturday = new DateTime(year, 12, 31);
            var sunday = saturday.AddDays(1);
            var monday = sunday.AddDays(1);

            Assert.AreEqual(DayOfWeek.Sunday, sunday.DayOfWeek);
            var holydays = new[] { sunday };
            var holydayCalculator = MockRepository.GenerateMock<IHolidayCalculator>();

            holydayCalculator.Expect(hc => hc.GetHolidays(year + 1)).Return(holydays);

            Assert.AreEqual(monday, saturday.NextWorkDay(holydayCalculator));
            Assert.AreEqual(monday, sunday.NextWorkDay(holydayCalculator));
            Assert.AreEqual(monday, monday.NextWorkDay(holydayCalculator));
        }
        public void NextWorkDayShouldReturnNextNonWeekendDayWhenHolydayCalculatorsAreNull()
        {
            const int year = 2011;
            var saturday = new DateTime(year, 12, 31);
            var sunday = saturday.AddDays(1);
            var monday = sunday.AddDays(1);

            Assert.AreEqual(DayOfWeek.Sunday, sunday.DayOfWeek);
            Assert.AreEqual(monday, saturday.NextWorkDay(null));
            Assert.AreEqual(monday, sunday.NextWorkDay(null));
            Assert.AreEqual(monday, monday.NextWorkDay(null));
        }
        public void NextWorkDayShouldReturnNextMondayWhenHolydayCalculatorsIsNullAndDateIsWeekend()
        {
            var sunday = new DateTime(2012, 4, 1);
            Assert.AreEqual(DayOfWeek.Sunday, sunday.DayOfWeek);
            var expected = sunday.AddDays(1);
            var actual = sunday.NextWorkDay();
            Assert.AreEqual(expected, actual);

            var saturday = sunday.AddDays(6);
            Assert.AreEqual(DayOfWeek.Saturday, saturday.DayOfWeek);
            expected = saturday.AddDays(2);
            actual = saturday.NextWorkDay();
            Assert.AreEqual(expected, actual);
        }