public void Should_ReturnError_When_EmployeeIdsExceed40() { var suitableMeetingsRequest = new SuitableMeetingsRequest { EmployeeIds = Enumerable.Repeat("1", 41) }; _validator.ShouldHaveValidationErrorFor(x => x.EmployeeIds.Count(), suitableMeetingsRequest); }
public void Should_ReturnError_When_DesiredMeetingLengthLoweOrEqualTo0(int desiredMeetingLength) { var suitableMeetingsRequest = new SuitableMeetingsRequest { EmployeeIds = Enumerable.Repeat("1", 40), DesiredMeetingLength = desiredMeetingLength }; _validator.ShouldHaveValidationErrorFor(x => x.DesiredMeetingLength, suitableMeetingsRequest); }
public void Should_ReturnError_When_RequestedEarliestDateTimeGreaterOrEqualToLatestTime( string requestedEarliestMeetingTime, string requestedLatestMeetingTime) { var suitableMeetingsRequest = new SuitableMeetingsRequest { EmployeeIds = Enumerable.Repeat("1", 40), DesiredMeetingLength = 1, requestedEarliestMeetingTime = DateTime.Parse(requestedEarliestMeetingTime), requestedLatestMeetingTime = DateTime.Parse(requestedLatestMeetingTime) }; _validator.ShouldHaveValidationErrorFor(x => x.requestedEarliestMeetingTime, suitableMeetingsRequest); }
public void Should_ReturnError_When_OfficeHoursStartTimeGreaterOrEqualToEndTime( string officeHoursStartTime, string officeHoursEndTime) { var suitableMeetingsRequest = new SuitableMeetingsRequest { EmployeeIds = Enumerable.Repeat("1", 40), DesiredMeetingLength = 1, requestedEarliestMeetingTime = DateTime.Parse("11/23/2019 11:00:00"), requestedLatestMeetingTime = DateTime.Parse("11/23/2019 11:30:00"), officeHoursStartTime = TimeSpan.Parse(officeHoursStartTime), officeHoursEndTime = TimeSpan.Parse(officeHoursEndTime), }; _validator.ShouldHaveValidationErrorFor(x => x.officeHoursStartTime, suitableMeetingsRequest); }
public async Task <ActionResult <IEnumerable <Meeting> > > GetSuitableMeetings([FromQuery] SuitableMeetingsRequest suitableMeetingsRequest) { var validationResult = _validator.Validate(suitableMeetingsRequest); if (!validationResult.IsValid) { return(BadRequest(validationResult)); } var employees = await _employeeQuery.GetEmployees(suitableMeetingsRequest.EmployeeIds ?? new List <string>()); var allEmployeeBusySlots = employees.Aggregate(new List <BusySlot>() as IEnumerable <BusySlot>, (a, b) => a.Concat(b.BusySlots)); var suitableMeetings = _meetingQuery.GetSuitableMeetings( allEmployeeBusySlots, suitableMeetingsRequest.DesiredMeetingLength, (suitableMeetingsRequest.requestedEarliestMeetingTime, suitableMeetingsRequest.requestedLatestMeetingTime), (suitableMeetingsRequest.officeHoursStartTime, suitableMeetingsRequest.officeHoursEndTime)); return(Ok(suitableMeetings)); }