Exemple #1
0
        public void SetUp()
        {
            courseDelegatesService = A.Fake <ICourseDelegatesService>();

            controller = new CourseDelegatesController(courseDelegatesService).WithDefaultContext()
                         .WithMockUser(true, UserCentreId);
        }
Exemple #2
0
        public void SetUp()
        {
            courseAdminFieldsService           = A.Fake <ICourseAdminFieldsService>();
            courseDelegatesService             = A.Fake <ICourseDelegatesService>();
            courseDelegatesDownloadFileService = A.Fake <ICourseDelegatesDownloadFileService>();
            searchSortFilterPaginateService    = A.Fake <ISearchSortFilterPaginateService>();

            controller = new CourseDelegatesController(
                courseAdminFieldsService,
                courseDelegatesService,
                courseDelegatesDownloadFileService,
                searchSortFilterPaginateService
                )
                         .WithDefaultContext()
                         .WithMockUser(true, UserCentreId);
        }
Exemple #3
0
        public void Index_should_default_to_Active_filter()
        {
            // Given
            const int customisationId = 2;
            var       course          = new Course {
                CustomisationId = customisationId, Active = true
            };
            var courseDelegate = Builder <CourseDelegate>
                                 .CreateListOfSize(2)
                                 .TheFirst(1)
                                 .With(c => c.IsDelegateActive = false)
                                 .TheLast(1)
                                 .With(c => c.IsDelegateActive = true)
                                 .Build();

            A.CallTo(
                () => courseDelegatesService.GetCoursesAndCourseDelegatesForCentre(
                    UserCentreId,
                    null,
                    customisationId
                    )
                )
            .Returns(
                new CourseDelegatesData(
                    customisationId,
                    new List <Course> {
                course
            },
                    courseDelegate,
                    new List <CourseAdminField>()
                    )
                );

            var          httpRequest  = A.Fake <HttpRequest>();
            var          httpResponse = A.Fake <HttpResponse>();
            const string cookieName   = "CourseDelegatesFilter";
            const string cookieValue  = "AccountStatus|IsDelegateActive|true";

            var courseDelegatesController = new CourseDelegatesController(
                courseAdminFieldsService,
                courseDelegatesService,
                courseDelegatesDownloadFileService,
                searchSortFilterPaginateService
                )
                                            .WithMockHttpContext(httpRequest, cookieName, cookieValue, httpResponse)
                                            .WithMockUser(true, UserCentreId)
                                            .WithMockTempData();

            A.CallTo(() => httpRequest.Cookies).Returns(A.Fake <IRequestCookieCollection>());
            SearchSortFilterAndPaginateTestHelper
            .GivenACallToSearchSortFilterPaginateServiceReturnsResult <CourseDelegate>(
                searchSortFilterPaginateService
                );

            // When
            var result = courseDelegatesController.Index(customisationId);

            // Then
            using (new AssertionScope())
            {
                result.As <ViewResult>().Model.As <CourseDelegatesViewModel>().CourseDetails !.ExistingFilterString.Should()
                .Be("AccountStatus|IsDelegateActive|true");

                A.CallTo(
                    () => courseDelegatesService.GetCoursesAndCourseDelegatesForCentre(
                        UserCentreId,
                        null,
                        customisationId
                        )
                    )
                .MustHaveHappened();
            }
        }