コード例 #1
0
        public void Available_action_should_return_view_result()
        {
            // Given
            var availableCourses = new[]
            {
                AvailableCourseHelper.CreateDefaultAvailableCourse(),
           AvailableCourseHelper.CreateDefaultAvailableCourse(),
            };

            A.CallTo(() => courseDataService.GetAvailableCourses(CandidateId, CentreId)).Returns(availableCourses);
            SearchSortFilterAndPaginateTestHelper
            .GivenACallToSearchSortFilterPaginateServiceReturnsResult <AvailableCourse>(
                searchSortFilterPaginateService
                );

            // When
            var result = controller.Available();

            // Then
            var expectedModel = new AvailablePageViewModel(
                new SearchSortFilterPaginationResult <AvailableCourse>(
                    new PaginationResult <AvailableCourse>(availableCourses, 1, 1, 10, 2, true),
                    null,
                    "Name",
                    "Ascending",
                    null
                    ),
                ""
                );

            result.Should().BeViewResult()
            .Model.Should().BeEquivalentTo(expectedModel);
        }
コード例 #2
0
        public IActionResult Available(
            string?searchString  = null,
            string?sortBy        = null,
            string sortDirection = BaseSearchablePageViewModel.Ascending,
            int page             = 1
            )
        {
            sortBy ??= CourseSortByOptions.Name.PropertyName;

            var availableCourses = courseDataService.GetAvailableCourses(
                User.GetCandidateIdKnownNotNull(),
                User.GetCentreId()
                );
            var bannerText = GetBannerText();
            var model      = new AvailablePageViewModel(
                availableCourses,
                searchString,
                sortBy,
                sortDirection,
                bannerText,
                page
                );

            return(View("Available/Available", model));
        }
コード例 #3
0
        public IActionResult Available(
            string?searchString  = null,
            string?sortBy        = null,
            string sortDirection = GenericSortingHelper.Ascending,
            int page             = 1
            )
        {
            sortBy ??= CourseSortByOptions.Name.PropertyName;

            var availableCourses = courseDataService.GetAvailableCourses(
                User.GetCandidateIdKnownNotNull(),
                User.GetCentreId()
                );
            var bannerText = GetBannerText();
            var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions(
                new SearchOptions(searchString),
                new SortOptions(sortBy, sortDirection),
                null,
                new PaginationOptions(page)
                );

            var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                availableCourses,
                searchSortPaginationOptions
                );

            var model = new AvailablePageViewModel(
                result,
                bannerText
                );

            return(View("Available/Available", model));
        }
コード例 #4
0
        public void Available_courses_should_correctly_return_the_second_page_of_courses()
        {
            var courses = new[] {
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "a course 1"),
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "b course 2"),
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "c course 3"),
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "d course 4"),
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "e course 5"),
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "f course 6"),
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "g course 7"),
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "h course 8"),
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "i course 9"),
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "j course 10"),
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "k course 11"),
            };

            model = new AvailablePageViewModel(
                courses,
                null,
                "Name",
                "Ascending",
                null,
                2
                );

            model.AvailableCourses.Count().Should().Be(1);
            model.AvailableCourses.First().Name.Should().Be("k course 11");
        }
コード例 #5
0
        public void Available_courses_should_default_to_returning_the_first_ten_courses()
        {
            var courses = new[] {
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "a course 1"),
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "b course 2"),
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "c course 3"),
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "d course 4"),
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "e course 5"),
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "f course 6"),
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "g course 7"),
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "h course 8"),
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "i course 9"),
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "j course 10"),
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "k course 11"),
            };

            model = new AvailablePageViewModel(
                courses,
                null,
                "Name",
                "Ascending",
                null,
                1
                );

            model.AvailableCourses.Count().Should().Be(10);
            model.AvailableCourses.FirstOrDefault(course => course.Name == "k course 11").Should().BeNull();
        }
コード例 #6
0
        public void Available_action_should_return_view_result()
        {
            // Given
            var availableCourses = new[]
            {
                AvailableCourseHelper.CreateDefaultAvailableCourse(),
           AvailableCourseHelper.CreateDefaultAvailableCourse()
            };

            A.CallTo(() => courseDataService.GetAvailableCourses(CandidateId, CentreId)).Returns(availableCourses);

            // When
            var result = controller.Available();

            // Then
            var expectedModel = new AvailablePageViewModel(
                availableCourses,
                null,
                "Name",
                "Ascending",
                "",
                1
                );

            result.Should().BeViewResult()
            .Model.Should().BeEquivalentTo(expectedModel);
        }
コード例 #7
0
        public void SetUp()
        {
            var courses = new[] {
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "First course"),
                AvailableCourseHelper.CreateDefaultAvailableCourse(courseName: "Second course")
            };

            model = new AvailablePageViewModel(
                courses,
                null,
                "Name",
                "Ascending",
                null,
                1
                );
        }