public void GetCourseSearchInputTest(CourseSearchProperties courseSearchProperties, CourseListInput expectedCourseListInput)
        {
            // Assign
            var buildTribalMessageService = new TribalMessageBuilder(fakeConvertTribalCodesService, fakeConfiguration, fakeCourseBusinessRules);

            //Act
            var result = buildTribalMessageService.GetCourseSearchInput(courseSearchProperties);

            //Assert
            result.Should().BeEquivalentTo(expectedCourseListInput);
            A.CallTo(() => fakeConvertTribalCodesService.GetTribalAttendanceModes(A <CourseType> ._)).MustHaveHappened();
            A.CallTo(() => fakeCourseBusinessRules.GetEarliestStartDate(A <StartDate> ._, A <DateTime> ._)).MustHaveHappened();
            A.CallTo(() => fakeConvertTribalCodesService.GetTribalStudyModes(A <CourseHours> ._)).MustHaveHappened();
            A.CallTo(() => fakeConfiguration.GetConfig <string>(A <string> ._)).MustHaveHappened(1, Times.Exactly);
        }
예제 #2
0
        public CourseListInput GetCourseSearchInput(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    = courseSearchProperties.Filters.SearchTerm,
                        EarliestStartDate = courseBusinessRules.GetEarliestStartDate(courseSearchProperties.Filters.StartDate, courseSearchProperties.Filters.StartDateFrom),
                        AttendanceModes   = convertTribalCodes.GetTribalAttendanceModes(courseSearchProperties.Filters.CourseType),
                        StudyModes        = convertTribalCodes.GetTribalStudyModes(courseSearchProperties.Filters.CourseHours),
                        ProviderKeyword   = courseSearchProperties.Filters.Provider,
                        Distance          = courseSearchProperties.Filters.DistanceSpecified ? courseSearchProperties.Filters.Distance : default(float),
                        DistanceSpecified = courseSearchProperties.Filters.DistanceSpecified,
                        Location          = courseSearchProperties.Filters.Location
                    },
                    RecordsPerPage  = courseSearchProperties.Count.ToString(),
                    PageNo          = courseSearchProperties.Page.ToString(),
                    SortBy          = GetSortType(courseSearchProperties.OrderedBy),
                    SortBySpecified = true
                }
            };

            return(apiRequest);
        }