Пример #1
0
        public async Task And_Model_Invalid_Redirect_To_Not_Found(
            GetCourseEpaosRequest getRequest,
            ValidationException exception,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] CoursesController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.IsAny <GetCourseEpaosQuery>(),
                       It.IsAny <CancellationToken>()))
            .ThrowsAsync(exception);

            var result = await controller.CourseEpaos(getRequest) as RedirectToRouteResult;

            result.RouteName.Should().Be(RouteNames.Error404);
        }
Пример #2
0
        public async Task Then_Has_No_Epaos_Then_Adds_Empty_List(
            GetCourseEpaosRequest getRequest,
            GetCourseEpaosResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] CoursesController controller)
        {
            mediatorResult.Epaos = new List <EpaoListItem>();
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.Is <GetCourseEpaosQuery>(query => query.CourseId == getRequest.Id),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(mediatorResult);

            var result = await controller.CourseEpaos(getRequest) as ViewResult;

            var model = result.Model as CourseEpaosViewModel;

            model.Course.Should().BeEquivalentTo((CourseListItemViewModel)mediatorResult.Course);
            model.Epaos.Should().BeEmpty();
        }
Пример #3
0
        public async Task Then_Gets_Epaos_From_Handler(
            GetCourseEpaosRequest getRequest,
            GetCourseEpaosResult mediatorResult,
            [Frozen] Mock <ILocationStringBuilder> mockLocationStringBuilder,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] CoursesController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.Is <GetCourseEpaosQuery>(query => query.CourseId == getRequest.Id),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(mediatorResult);

            var result = await controller.CourseEpaos(getRequest) as ViewResult;

            var model = result.Model as CourseEpaosViewModel;

            model.Course.Should().BeEquivalentTo((CourseListItemViewModel)mediatorResult.Course);
            model.Epaos.Should().BeEquivalentTo(mediatorResult.Epaos.Select(item => new EpaoListItemViewModel(
                                                                                item,
                                                                                mediatorResult.DeliveryAreas,
                                                                                mockLocationStringBuilder.Object.BuildLocationString)));
        }
        public async Task <IActionResult> CourseEpaos(GetCourseEpaosRequest request)
        {
            try
            {
                var query = new GetCourseEpaosQuery {
                    CourseId = request.Id
                };
                var result = await _mediator.Send(query);

                var model = new CourseEpaosViewModel
                {
                    Course = result.Course,
                    Epaos  = result.Epaos.Select(item => new EpaoListItemViewModel(
                                                     item,
                                                     result.DeliveryAreas,
                                                     _locationStringBuilder.BuildLocationString))
                };
                return(View(model));
            }
            catch (ValidationException)
            {
                return(RedirectToRoute(RouteNames.Error404));
            }
        }
 public void Then_The_Url_Is_Correctly_Built(
     GetCourseEpaosRequest actual)
 {
     actual.GetAllUrl.Should().Be($"api/v1/standards/{actual.CourseId}/organisations");
 }