public void ToAbsenceDayListTests(IEnumerable <DateTime> dates, AbsenceRange absenceRange, IEnumerable <AbsenceDay> expectedAbsenceDays) { // Arrange // Act var actualAbsenceDays = dates.ToAbsenceDayList(absenceRange); // Assert actualAbsenceDays.ShouldBeEquivalentTo(expectedAbsenceDays); }
public void AbsenceDaysAlreadyBookedTests(AbsenceRange absenceRange, IEnumerable <AbsenceDay> alreadyBookedAbsences, IEnumerable <CanBeBookedAbsenceDay> expectedAbsenceRanges) { // Arrange _mockHRDataService.Setup(m => m.RetrieveAbsenceRangeBookedAbsenceDays(It.IsAny <AbsenceRange>())) .Returns(alreadyBookedAbsences); // Act var actualAlreadyBookedAbsenceDays = _hrBusinessService.RetrieveAlreadyBookedAbsencesExcludingCurrentAbsence(absenceRange); // Assert actualAlreadyBookedAbsenceDays.ShouldBeEquivalentTo(expectedAbsenceRanges); _mockHRDataService.Verify(m => m.RetrieveAbsenceRangeBookedAbsenceDays(It.IsAny <AbsenceRange>()), Times.Once); }
public void AbsenceDaysCannotBookTests(AbsenceRange absenceRange, WorkingPattern workingPattern, IEnumerable <PublicHoliday> publicHolidays, IEnumerable <AbsenceDay> alreadyBookedAbsenceDays, IEnumerable <INotAbsenceDay> expectedAbsenceDays) { // Arrange _mockHRDataService.Setup(m => m.RetrievePublicHolidays(It.IsAny <Int32>(), It.IsAny <Int32>(), It.IsAny <Expression <Func <PublicHoliday, bool> > >(), It.IsAny <List <OrderBy> >(), It.IsAny <Paging>())).Returns(PagedResult <PublicHoliday> .Create(publicHolidays, 1, publicHolidays.Count(), 1, publicHolidays.Count())); _mockHRDataService.Setup(m => m.RetrieveAbsenceRangeBookedAbsenceDays(It.IsAny <AbsenceRange>())) .Returns(alreadyBookedAbsenceDays); // Act var actualAbsenceDays = _hrBusinessService.RetrieveCannotBeBookedDays(absenceRange, workingPattern); // Assert actualAbsenceDays.ShouldBeEquivalentTo(expectedAbsenceDays); _mockHRDataService.Verify(m => m.RetrievePublicHolidays(It.IsAny <Int32>(), It.IsAny <Int32>(), It.IsAny <Expression <Func <PublicHoliday, bool> > >(), It.IsAny <List <OrderBy> >(), It.IsAny <Paging>()), Times.Once); _mockHRDataService.Verify(m => m.RetrieveAbsenceRangeBookedAbsenceDays(It.IsAny <AbsenceRange>()), Times.Once); }
public ActionResult AbsenceRequest(AbsenceRange absenceRange) { absenceRange.OrganisationId = UserOrganisationId; return(this.JsonNet(HRBusinessService.RetrieveAbsenceRequest(UserOrganisationId, absenceRange))); }
public static IEnumerable <AbsenceDay> ToAbsenceDayList(this IEnumerable <DateTime> dates, AbsenceRange absenceRange) { if (absenceRange == null) { return(null); } return(dates.Select(d => { var IsBeginDate = absenceRange.BeginDateUtc.Date == d.Date; var IsEndDate = absenceRange.EndDateUtc.Date == d.Date; var IsAM = IsBeginDate ? absenceRange.BeginAbsencePart != AbsencePart.HalfDayPM : IsEndDate ? absenceRange.EndAbsencePart != AbsencePart.HalfDayPM : true; var IsPM = IsBeginDate ? absenceRange.BeginAbsencePart != AbsencePart.HalfDayAM : IsEndDate ? absenceRange.EndAbsencePart != AbsencePart.HalfDayAM : true; return new AbsenceDay { AbsenceId = absenceRange.AbsenceId.HasValue ? absenceRange.AbsenceId.Value : 0, Date = d, AM = IsAM, PM = IsPM, Duration = CalculateAbsenceDayDuration(IsAM, IsPM), }; })); }