Esempio n. 1
0
        public async Task <CourseListItem> GetCourse(string courseId)
        {
            var request = new GetCourseApiRequest(courseId);
            var course  = await _apiClient.Get <CourseItem>(request);

            return(course.Course);
        }
Esempio n. 2
0
        public async Task Then_The_Api_Client_Is_Called_With_The_Request(
            int courseId,
            double lat,
            double lon,
            string locationName,
            string baseUrl,
            Guid shortlistUserId,
            TrainingCourse response,
            [Frozen] Mock <IOptions <FindApprenticeshipTrainingApi> > config,
            [Frozen] Mock <IApiClient> apiClient,
            CourseService courseService)
        {
            //Arrange

            var courseApiRequest = new GetCourseApiRequest(config.Object.Value.BaseUrl, courseId, lat, lon, locationName, shortlistUserId);

            apiClient.Setup(x => x.Get <TrainingCourse>(
                                It.Is <GetCourseApiRequest>(request => request.GetUrl.Equals(courseApiRequest.GetUrl)))).ReturnsAsync(response);

            //Act
            var actual = await courseService.GetCourse(courseId, lat, lon, locationName, shortlistUserId);

            //Assert
            actual.Should().BeEquivalentTo(response);
        }
        public void Then_The_Get_Url_Is_Constructed_Correctly_With_ShortlistUserId(string baseUrl, int id, double lat, double lon, string locationName, Guid shortlistUserId)
        {
            //Arrange Act
            var actual = new GetCourseApiRequest(baseUrl, id, lat, lon, locationName, shortlistUserId);

            //Assert
            actual.GetUrl.Should().Be($"{baseUrl}trainingcourses/{id}?lat={lat}&lon={lon}&location={locationName}&shortlistUserId={shortlistUserId}");
        }
Esempio n. 4
0
        public async Task <TrainingCourse> GetCourse(int courseId, double lat, double lon, Guid?shortlistUserId)
        {
            var request = new GetCourseApiRequest(_config.BaseUrl, courseId, lat, lon, shortlistUserId);

            var response = await _apiClient.Get <TrainingCourse>(request);

            return(response);
        }
Esempio n. 5
0
        public void Then_The_Get_Url_Is_Constructed_Correctly(string baseUrl, int id, double lat, double lon)
        {
            //Arrange Act
            var actual = new GetCourseApiRequest(baseUrl, id, lat, lon);

            //Assert
            actual.GetUrl.Should().Be($"{baseUrl}trainingcourses/{id}?lat={lat}&lon={lon}&shortlistUserId=");
        }