public void GetCourseSearchInputTest(string courseName, CourseSearchProperties courseSearchProperties, CourseListInput expectedCourseListInput) { // Assign var buildTribalMessageService = new BuildTribalMessageService(fakeConvertTribalCodesService, fakeConfiguration); //Act var result = buildTribalMessageService.GetCourseSearchInput(courseName, courseSearchProperties); //Assert result.Should().BeEquivalentTo(expectedCourseListInput); A.CallTo(() => fakeConvertTribalCodesService.GetTribalAttendanceModes(A <string> ._)).MustHaveHappened(); A.CallTo(() => fakeConvertTribalCodesService.GetTribalAttendancePatterns(A <string> ._)).MustHaveHappened(); A.CallTo(() => fakeConvertTribalCodesService.GetTribalStudyModes(A <string> ._)).MustHaveHappened(); A.CallTo(() => fakeConfiguration.GetConfig <string>(A <string> ._)).MustHaveHappened(1, Times.Exactly); }
public CourseListInput GetCourseSearchInput(string courseName, CourseSearchProperties courseSearchProperties) { if (courseSearchProperties == null) { throw new ArgumentNullException(nameof(courseSearchProperties)); } var apiRequest = new CourseListInput { CourseListRequest = new CourseListRequestStructure { CourseSearchCriteria = new SearchCriteriaStructure { APIKey = configuration.GetConfig <string>(Constants.CourseSearchApiKey), SubjectKeyword = courseName, EarliestStartDate = null, AttendanceModes = convertTribalCodesService.GetTribalAttendanceModes(string.Join(",", courseSearchProperties.Filters.Attendance ?? new List <string>())), StudyModes = convertTribalCodesService.GetTribalStudyModes(string.Join(",", courseSearchProperties.Filters.StudyMode ?? new List <string>())), DFE1619Funded = courseSearchProperties.Filters.Only1619Courses ? "Y" : null, AttendancePatterns = convertTribalCodesService.GetTribalAttendancePatterns(string.Join(",", courseSearchProperties.Filters.AttendancePattern ?? new List <string>())), ProviderKeyword = courseSearchProperties.Filters.Provider, Distance = courseSearchProperties.Filters.Distance, DistanceSpecified = courseSearchProperties.Filters.DistanceSpecified, Location = courseSearchProperties.Filters.Location }, RecordsPerPage = courseSearchProperties.Count.ToString(), PageNo = courseSearchProperties.Page.ToString(), SortBy = GetSortType(courseSearchProperties.OrderedBy), SortBySpecified = true } }; return(apiRequest); }