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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }