コード例 #1
0
        public async Task Then_Gets_Employer_Course_Demands_From_Mediator(
            int ukprn,
            int courseId,
            string location,
            int locationRadius,
            GetEmployerCourseProviderDemandQueryResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] DemandController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.Is <GetEmployerCourseProviderDemandQuery>(query =>
                                                                    query.Ukprn == ukprn &&
                                                                    query.CourseId == courseId &&
                                                                    query.LocationName == location &&
                                                                    query.LocationRadius == locationRadius),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(mediatorResult);

            var controllerResult = await controller.GetEmployerCourseProviderDemand(ukprn, courseId, location, locationRadius) as ObjectResult;

            controllerResult !.StatusCode.Should().Be((int)HttpStatusCode.OK);
            var model = controllerResult.Value as GetProviderEmployerCourseDemandListResponse;

            model !.TrainingCourse.Should().BeEquivalentTo((GetCourseListItem)mediatorResult.Course);
            model !.ProviderEmployerDemandDetailsList.Should().BeEquivalentTo(mediatorResult.EmployerCourseDemands.Select(response => (GetProviderEmployerDemandDetailsListItem)response));
            model !.Total.Should().Be(mediatorResult.Total);
            model !.TotalFiltered.Should().Be(mediatorResult.TotalFiltered);
            model !.Location.Should().BeEquivalentTo((GetLocationSearchResponseItem)mediatorResult.Location);
            model !.ProviderContactDetails.Should().BeEquivalentTo((GetProviderContactDetails)mediatorResult.ProviderDetail);
        }
コード例 #2
0
        public async Task Then_Gets_Courses_And_Demands_From_Mediator(
            int ukprn,
            int courseId,
            string location,
            int locationRadius,
            List <string> routes,
            GetAggregatedCourseDemandListResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] DemandController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.Is <GetAggregatedCourseDemandListQuery>(query =>
                                                                  query.Ukprn == ukprn &&
                                                                  query.CourseId == courseId &&
                                                                  query.LocationName == location &&
                                                                  query.LocationRadius == locationRadius),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(mediatorResult);

            var controllerResult = await controller.GetAggregatedCourseDemandList(ukprn, courseId, location, locationRadius, routes) as ObjectResult;

            controllerResult !.StatusCode.Should().Be((int)HttpStatusCode.OK);
            var model = controllerResult.Value as GetAggregatedCourseDemandListResponse;

            model !.TrainingCourses.Should().BeEquivalentTo(mediatorResult.Courses.Select(item => (GetCourseListItem)item));
            model !.AggregatedCourseDemands.Should().BeEquivalentTo(mediatorResult.AggregatedCourseDemands.Select(response => (GetAggregatedCourseDemandSummary)response));
            model !.Total.Should().Be(mediatorResult.Total);
            model !.TotalFiltered.Should().Be(mediatorResult.TotalFiltered);
            model !.Location.Should().BeEquivalentTo((GetLocationSearchResponseItem)mediatorResult.LocationItem);
            model !.Routes.Should().BeEquivalentTo(mediatorResult.Routes);
        }