예제 #1
0
        public void GetPreviousTimeOff_ReturnsClosestRegisteredHoliday_IfItIsLaterThanPreviousWeekend()
        {

            //Arrange
            HolidaysManager manager = new HolidaysManager();
            manager.AddHoliday(new DateTime(2017, 5, 1));
            manager.AddHoliday(new DateTime(2017, 5, 3));
            manager.AddHoliday(new DateTime(2017, 11, 11));
            DateTime baseDate = new DateTime(2017, 5, 4, 16, 0, 0);

            //Act
            DateTime date = manager.GetPreviousTimeOff(baseDate);

            //Assert
            DateTime expectedDate = new DateTime(2017, 5, 2, 21, 0, 0);
            Assert.AreEqual(expectedDate, date);

        }
예제 #2
0
        public void GetNextHoliday_ReturnsClosestRegisteredHoliday()
        {

            //Arrange
            HolidaysManager manager = new HolidaysManager();
            manager.AddHoliday(new DateTime(2017, 5, 1));
            manager.AddHoliday(new DateTime(2017, 5, 3));
            manager.AddHoliday(new DateTime(2017, 11, 11));
            DateTime baseDate = new DateTime(2017, 5, 2);

            //Act
            DateTime? date = manager.GetNextHoliday(baseDate);

            //Assert
            DateTime expectedDate = new DateTime(2017, 5, 3);
            Assert.AreEqual(expectedDate, date);

        }
예제 #3
0
        public void IsDayOff_ReturnsTrue_ForWeekDayHoliday()
        {

            //Arrange
            HolidaysManager manager = new HolidaysManager();
            DateTime checkedDate = new DateTime(2017, 5, 2, 11, 15, 0);

            //Act
            manager.AddHoliday(checkedDate.Midnight());

            //Assert
            bool isDayOff = manager.IsDayOff(checkedDate);
            Assert.IsTrue(isDayOff);

        }
예제 #4
0
        public void IsWorkingTime_ReturnsFalse_ForWeekDayHoliday()
        {

            //Arrange
            HolidaysManager manager = new HolidaysManager();
            DateTime checkedDate = new DateTime(2017, 5, 2, 11, 15, 0);

            //Act
            manager.AddHoliday(checkedDate.Midnight());

            //Assert
            bool isWorkingTime = manager.IsWorkingTime(checkedDate);
            Assert.IsFalse(isWorkingTime);

        }
예제 #5
0
        public void IsDayBeforeHoliday_ReturnsFalse_IfNextDayIsRegularSaturday()
        {

            //Arrange
            HolidaysManager manager = new HolidaysManager();
            DateTime checkedDate = new DateTime(2017, 5, 5, 11, 23, 34);

            //Act
            manager.AddHoliday(new DateTime(2017, 5, 3));

            //Assert
            bool isHoliday = manager.IsDayBeforeHoliday(checkedDate);
            Assert.IsFalse(isHoliday);

        }
예제 #6
0
        public void IsDayBeforeHoliday_ReturnsTrue_IfNextDayAfterGivenDateIsHoliday()
        {

            //Arrange
            HolidaysManager manager = new HolidaysManager();
            DateTime checkedDate = new DateTime(2017, 5, 2, 11, 23, 34);

            //Act
            manager.AddHoliday(new DateTime(2017, 5, 3));

            //Assert
            bool isHoliday = manager.IsDayBeforeHoliday(checkedDate);
            Assert.IsTrue(isHoliday);

        }
예제 #7
0
        public void IsDayBeforeHoliday_ReturnsFalse_IfGivenDayIsHolidayButNotNextOne()
        {

            //Arrange
            HolidaysManager manager = new HolidaysManager();
            DateTime checkedDate = new DateTime(2017, 5, 3, 11, 23, 34);

            //Act
            manager.AddHoliday(new DateTime(2017, 5, 3));

            //Assert
            bool isHoliday = manager.IsDayBeforeHoliday(checkedDate);
            Assert.IsFalse(isHoliday);

        }
예제 #8
0
        public void GetNextHoliday_ReturnsNull_IfThereIsNoMoreHolidays()
        {

            //Arrange
            HolidaysManager manager = new HolidaysManager();
            manager.AddHoliday(new DateTime(2017, 5, 3));
            DateTime baseDate = new DateTime(2017, 5, 4);

            //Act
            DateTime? result = manager.GetNextHoliday(baseDate);

            //Assert
            Assert.IsNull(result);

        }
예제 #9
0
        public void GetNextWorkingDay_ReturnsTwoDaysLater_IfNextDayIsMiddleWeekHoliday()
        {

            //Arrange
            HolidaysManager manager = new HolidaysManager();
            manager.AddHoliday(new DateTime(2017, 5, 3));
            DateTime baseDate = new DateTime(2017, 5, 2);

            //Act
            DateTime date = manager.GetNextWorkingDay(baseDate);

            //Assert
            DateTime expectedDate = new DateTime(2017, 5, 4);
            Assert.AreEqual(expectedDate, date);

        }
예제 #10
0
        public void GetPreviousTimeOff_ReturnsPreviousWeekendStart_IfItIsLaterThanPreviousHoliday()
        {

            //Arrange
            HolidaysManager manager = new HolidaysManager();
            manager.AddHoliday(new DateTime(2017, 5, 4));
            DateTime baseDate = new DateTime(2017, 5, 8);

            //Act
            DateTime date = manager.GetPreviousTimeOff(baseDate);

            //Assert
            DateTime expectedDate = new DateTime(2017, 5, 6, 0, 0, 0);
            Assert.AreEqual(expectedDate, date);

        }
예제 #11
0
        public void IsWorkingTime_ReturnsFalse_ForWorkingDayBeforeHolidayAfterEveningBreak()
        {

            //Arrange
            HolidaysManager manager = new HolidaysManager();
            DateTime checkedDate = new DateTime(2017, 5, 3, 21, 15, 0);

            //Act
            manager.AddHoliday(new DateTime(2017, 5, 4));
            manager.SetHolidayEveBreak(new TimeSpan(3, 0, 0));

            //Assert
            bool isWorkingTime = manager.IsWorkingTime(checkedDate);
            Assert.IsFalse(isWorkingTime);

        }
예제 #12
0
        public void GetNextHolidayWithEndDate_ReturnsNull_IfThereAreHolidaysOnlyAfterEndDate()
        {

            //Arrange
            HolidaysManager manager = new HolidaysManager();
            manager.AddHoliday(new DateTime(2017, 5, 3));
            DateTime startDate = new DateTime(2017, 4, 2);
            DateTime endDate = new DateTime(2017, 4, 21);

            //Act
            DateTime? result = manager.GetNextHoliday(startDate, endDate);

            //Assert
            Assert.IsNull(result);

        }
예제 #13
0
        public void IsHoliday_ReturnsTrue_ForDateAddedToHolidaysInTheMiddleOfDay()
        {

            //Arrange
            HolidaysManager manager = new HolidaysManager();
            DateTime holiday = new DateTime(2017, 5, 1);
            DateTime checkedDate = new DateTime(2017, 5, 1, 13, 14, 21);

            //Act
            manager.AddHoliday(holiday);

            //Assert
            bool isHoliday = manager.IsHoliday(checkedDate);
            Assert.IsTrue(isHoliday);

        }
예제 #14
0
        public void GetNextWorkingDay_ReturnsNextTuesday_IfItIsFridayAndMondayIsHoliday()
        {

            //Arrange
            HolidaysManager manager = new HolidaysManager();
            manager.AddHoliday(new DateTime(2017, 5, 8));
            DateTime baseDate = new DateTime(2017, 5, 5);

            //Act
            DateTime date = manager.GetNextWorkingDay(baseDate);

            //Assert
            DateTime expectedDate = new DateTime(2017, 5, 9);
            Assert.AreEqual(expectedDate, date);

        }
예제 #15
0
        public void IsHoliday_ReturnsFalse_ForDateNotAddedToHolidays()
        {

            //Arrange
            HolidaysManager manager = new HolidaysManager();
            DateTime holiday = new DateTime(2017, 5, 1);
            DateTime checkedDate = new DateTime(2017, 5, 2);

            //Act
            manager.AddHoliday(holiday);

            //Assert
            bool isHoliday = manager.IsHoliday(checkedDate);
            Assert.IsFalse(isHoliday);

        }
예제 #16
0
        public void IsHoliday_ReturnsTrue_IfDateIsAddedAsHoliday()
        {

            //Arrange
            HolidaysManager manager = new HolidaysManager();
            DateTime holiday = new DateTime(2017, 5, 1);
            DateTime checkedDate = new DateTime(2017, 5, 1);
            
            //Act
            manager.AddHoliday(holiday);

            //Assert
            bool isHoliday = manager.IsHoliday(checkedDate);
            Assert.IsTrue(isHoliday);

        }
예제 #17
0
        public void isTimeAfterHolidayEveMarketClose_ReturnsTrue_IfNextDayIsHolidayAndItIsAfterBreak()
        {

            //Arrange
            HolidaysManager manager = new HolidaysManager();
            manager.AddHoliday(new DateTime(2017, 5, 3));
            manager.SetHolidayEveBreak(new TimeSpan(3, 0, 0));

            //Act
            DateTime checkedDate = new DateTime(2017, 5, 2, 23, 0, 0);

            //Assert
            bool isTimeAfterHolidayEveMarketClose = manager.IsHolidayEveAfterMarketClose(checkedDate);
            Assert.IsTrue(isTimeAfterHolidayEveMarketClose);

        }