Exemplo n.º 1
0
        public void IsDayOff_ReturnsFalse_ForWorkingDay()
        {

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

            //Act

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

        }
Exemplo n.º 2
0
        public void IsWorkingTime_ReturnsFalse_ForWeekend()
        {

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

            //Act

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

        }
Exemplo n.º 3
0
        public void isTimeAfterHolidayEveMarketClose_ReturnsFalse_IfNextDayIsSunday()
        {

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

            //Act

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

        }
Exemplo n.º 4
0
        public void IsWorkingDay_ReturnsTrue_ForWorkingDay()
        {

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

            //Act

            //Assert
            bool isWorkingDay = manager.IsWorkingDay(checkedDate);
            Assert.IsTrue(isWorkingDay);

        }
Exemplo n.º 5
0
        public void IsDayOff_ReturnsTrue_ForWeekend()
        {

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

            //Act

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

        }
Exemplo n.º 6
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);

        }
Exemplo n.º 7
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);

        }
Exemplo n.º 8
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);

        }
Exemplo n.º 9
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);

        }
Exemplo n.º 10
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);

        }
Exemplo n.º 11
0
        public void GetPreviousTimeOff_ReturnsPreviousWeekendStart_IfThereIsNoPreviousHoliday()
        {

            //Arrange
            HolidaysManager manager = new HolidaysManager();
            DateTime baseDate = new DateTime(2017, 5, 9);

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

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

        }
Exemplo n.º 12
0
        public void GetNextWorkingDay_ReturnsNextMonday_IfNextDayIsSaturday()
        {

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

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

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

        }
Exemplo n.º 13
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);

        }
Exemplo n.º 14
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);

        }
Exemplo n.º 15
0
        public void GetNextTimeOff_ReturnsWeekendStart_IfItIsEarlierThanNextHoliday()
        {

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

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

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

        }
Exemplo n.º 16
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);

        }
Exemplo n.º 17
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);

        }
Exemplo n.º 18
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);

        }
Exemplo n.º 19
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);

        }
Exemplo n.º 20
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);

        }
Exemplo n.º 21
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);

        }
Exemplo n.º 22
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);

        }
Exemplo n.º 23
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);

        }
Exemplo n.º 24
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);

        }
Exemplo n.º 25
0
        public void LoadHolidays_ReturnsTrue_ForDateAddedAsListItem()
        {

            //Arrange
            HolidaysManager manager = new HolidaysManager();
            List<DateTime> holidays = new List<DateTime>();
            holidays.Add(new DateTime(2017, 5, 1));
            holidays.Add(new DateTime(2017, 5, 3));
            holidays.Add(new DateTime(2017, 11, 11));
            DateTime checkedDate = new DateTime(2017, 5, 2);

            //Act
            manager.LoadHolidays(holidays);

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

        }