示例#1
0
        public void Current_course_should_not_have_passed_sections_without_learning_assessment()
        {
            // Given
            var currentCourse = CurrentCourseHelper.CreateDefaultCurrentCourse(isAssessed: false);

            // When
            var currentCourseViewModel = new CurrentCourseViewModel(currentCourse);

            // Then
            currentCourseViewModel.HasPassedSections().Should().BeFalse();
        }
示例#2
0
        public void Current_course_should_be_overdue_when_complete_by_date_is_in_the_past()
        {
            // Given
            var currentCourse = CurrentCourseHelper.CreateDefaultCurrentCourse(completeByDate: DateTime.Today - TimeSpan.FromDays(1));

            // When
            var currentCourseViewModel = new CurrentCourseViewModel(currentCourse);

            // Then
            currentCourseViewModel.DateStyle().Should().Be("overdue");
        }
示例#3
0
        public void Current_course_should_have_diagnostic_score_with_diagnostic_score_value_and_diagnostic_assessment()
        {
            // Given
            var currentCourse = CurrentCourseHelper.CreateDefaultCurrentCourse();

            // When
            var currentCourseViewModel = new CurrentCourseViewModel(currentCourse);


            // Then
            currentCourseViewModel.HasDiagnosticScore().Should().BeTrue();
        }
示例#4
0
        public void Current_course_should_not_have_diagnostic_score_without_diagnostic_score_value()
        {
            // Given
            var currentCourse = CurrentCourseHelper.CreateDefaultCurrentCourse(diagnosticScore: null);

            // When
            var currentCourseViewModel = new CurrentCourseViewModel(currentCourse);


            // Then
            currentCourseViewModel.HasDiagnosticScore().Should().BeFalse();
        }
示例#5
0
        public void Current_course_should_have_no_date_style_when_due_far_in_the_future()
        {
            // Given
            var currentCourse = CurrentCourseHelper.CreateDefaultCurrentCourse(completeByDate: DateTime.Today + TimeSpan.FromDays(100));

            // When
            var currentCourseViewModel = new CurrentCourseViewModel(currentCourse);



            // Then
            currentCourseViewModel.DateStyle().Should().Be("");
        }
示例#6
0
        public void Requesting_a_course_unlock_should_call_the_unlock_service()
        {
            // Given
            const int progressId     = 1;
            var       currentCourses = new[]
            {
                CurrentCourseHelper.CreateDefaultCurrentCourse(progressId: progressId, locked: true),
            };

            A.CallTo(() => courseDataService.GetCurrentCourses(CandidateId)).Returns(currentCourses);

            // When
            controller.RequestUnlock(progressId);

            // Then
            A.CallTo(() => notificationService.SendUnlockRequest(progressId)).MustHaveHappened();
        }
示例#7
0
        public async Task Current_action_should_return_view_result()
        {
            // Given
            var currentCourses = new[]
            {
                CurrentCourseHelper.CreateDefaultCurrentCourse(),
           CurrentCourseHelper.CreateDefaultCurrentCourse(),
            };
            var selfAssessments = new[]
            {
                SelfAssessmentHelper.CreateDefaultSelfAssessment(),
                SelfAssessmentHelper.CreateDefaultSelfAssessment(),
            };
            var actionPlanResources = Builder <ActionPlanResource> .CreateListOfSize(2).Build().ToArray();

            var bannerText = "bannerText";

            A.CallTo(() => courseDataService.GetCurrentCourses(CandidateId)).Returns(currentCourses);
            A.CallTo(() => selfAssessmentService.GetSelfAssessmentsForCandidate(CandidateId)).Returns(selfAssessments);
            A.CallTo(() => actionPlanService.GetIncompleteActionPlanResources(CandidateId))
            .Returns(actionPlanResources);
            A.CallTo(() => centresDataService.GetBannerText(CentreId)).Returns(bannerText);
            A.CallTo(() => config[ConfigHelper.UseSignposting]).Returns("true");

            // When
            var result = await controller.Current();

            // Then
            var expectedModel = new CurrentPageViewModel(
                currentCourses,
                null,
                "LastAccessed",
                "Descending",
                selfAssessments,
                actionPlanResources,
                bannerText,
                1
                );

            result.Should().BeViewResult()
            .Model.Should().BeEquivalentTo(expectedModel);
        }
示例#8
0
        public void Requesting_unlock_for_non_existent_course_should_return_404()
        {
            // Given
            var currentCourses = new[]
            {
                CurrentCourseHelper.CreateDefaultCurrentCourse(progressId: 2, locked: true),
            };

            A.CallTo(() => courseDataService.GetCurrentCourses(CandidateId)).Returns(currentCourses);

            // When
            var result = controller.RequestUnlock(3);

            // Then
            result.Should()
            .BeRedirectToActionResult()
            .WithControllerName("LearningSolutions")
            .WithActionName("StatusCode")
            .WithRouteValue("code", 404);
        }
示例#9
0
        public void Trying_to_edit_complete_by_date_for_non_existent_course_should_return_404()
        {
            // Given
            var currentCourses = new[]
            {
                CurrentCourseHelper.CreateDefaultCurrentCourse(2),
            };

            A.CallTo(() => courseDataService.GetCurrentCourses(CandidateId)).Returns(currentCourses);

            // When
            var result = controller.SetCurrentCourseCompleteByDate(3);

            // Then
            result.Should()
            .BeRedirectToActionResult()
            .WithControllerName("LearningSolutions")
            .WithActionName("StatusCode")
            .WithRouteValue("code", 404);
        }
示例#10
0
        public void Remove_confirmation_for_a_current_course_should_show_confirmation()
        {
            // Given
            const int customisationId = 2;
            var       currentCourse   = CurrentCourseHelper.CreateDefaultCurrentCourse(customisationId);
            var       currentCourses  = new[]
            {
                currentCourse,
            };

            A.CallTo(() => courseDataService.GetCurrentCourses(CandidateId)).Returns(currentCourses);

            // When
            var result = controller.RemoveCurrentCourseConfirmation(customisationId);

            // Then
            var expectedModel = new CurrentCourseViewModel(currentCourse);

            result.Should().BeViewResult()
            .Model.Should().BeEquivalentTo(expectedModel);
        }
示例#11
0
        public void Current_courses_should_correctly_return_the_second_page_of_courses()
        {
            var courses = new[]
            {
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "a course 1"),
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "b course 2"),
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "c course 3"),
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "d course 4"),
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "e course 5"),
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "f course 6"),
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "g course 7"),
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "h course 8"),
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "i course 9"),
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "j course 10"),
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "k course 11"),
            };

            selfAssessments = new SelfAssessment[]
            {
                SelfAssessmentHelper.CreateDefaultSelfAssessment(),
                    SelfAssessmentHelper.CreateDefaultSelfAssessment(),
            };
            actionPlanResources = Builder <ActionPlanResource> .CreateListOfSize(2).Build().ToArray();

            model = new CurrentPageViewModel(
                courses,
                null,
                "Name",
                "Ascending",
                selfAssessments,
                actionPlanResources,
                null,
                2
                );

            model.CurrentActivities.Count().Should().Be(5);
            model.CurrentActivities.First().Name.Should().Be("k course 11");
        }
示例#12
0
        public void Current_courses_should_default_to_returning_the_first_ten_courses()
        {
            var courses = new[]
            {
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "a course 1"),
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "b course 2"),
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "c course 3"),
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "d course 4"),
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "e course 5"),
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "f course 6"),
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "g course 7"),
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "h course 8"),
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "i course 9"),
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "j course 10"),
                CurrentCourseHelper.CreateDefaultCurrentCourse(courseName: "k course 11"),
            };

            selfAssessments = new SelfAssessment[]
            {
                SelfAssessmentHelper.CreateDefaultSelfAssessment(),
                    SelfAssessmentHelper.CreateDefaultSelfAssessment(),
            };

            model = new CurrentPageViewModel(
                courses,
                null,
                "Name",
                "Ascending",
                selfAssessments,
                actionPlanResources,
                null,
                1
                );

            model.CurrentActivities.Count().Should().Be(10);
            model.CurrentActivities.FirstOrDefault(course => course.Name == "k course 11").Should().BeNull();
        }
示例#13
0
        public void Trying_to_edit_complete_by_date_when_not_self_enrolled_should_return_403()
        {
            // Given
            var currentCourse = CurrentCourseHelper.CreateDefaultCurrentCourse(
                enrollmentMethodId: 0,
                completeByDate: new DateTime(2020, 1, 1)
                );
            var currentCourses = new[]
            {
                currentCourse,
            };

            A.CallTo(() => courseDataService.GetCurrentCourses(CandidateId)).Returns(currentCourses);

            // When
            var result = controller.SetCurrentCourseCompleteByDate(currentCourse.Id);

            // Then
            result.Should()
            .BeRedirectToActionResult()
            .WithControllerName("LearningSolutions")
            .WithActionName("StatusCode")
            .WithRouteValue("code", 403);
        }
示例#14
0
        public void SetUp()
        {
            var config = A.Fake <IConfiguration>();

            A.CallTo(() => config["CurrentSystemBaseUrl"]).Returns("http://www.dls.nhs.uk");

            currentCourses = new[]
            {
                CurrentCourseHelper.CreateDefaultCurrentCourse(
                    71,
                    "B: Course",
                    true,
                    isAssessed: true,
                    startedDate: new DateTime(2010, 1, 31),
                    lastAccessed: new DateTime(2010, 2, 22),
                    completeByDate: new DateTime(2010, 3, 22),
                    passes: 4,
                    diagnosticScore: 123
                    ),
                CurrentCourseHelper.CreateDefaultCurrentCourse(
                    72,
                    "C: Course",
                    true,
                    isAssessed: false,
                    startedDate: new DateTime(2010, 2, 1),
                    lastAccessed: new DateTime(2011, 2, 22),
                    completeByDate: new DateTime(2011, 3, 22),
                    passes: 14,
                    diagnosticScore: 0
                    ),
                CurrentCourseHelper.CreateDefaultCurrentCourse(
                    73,
                    "A: Course",
                    false,
                    isAssessed: true,
                    startedDate: new DateTime(2001, 1, 22),
                    lastAccessed: new DateTime(2011, 2, 23),
                    completeByDate: null,
                    passes: 0,
                    diagnosticScore: 0
                    ),
            }.AsQueryable();

            completedCourses = new[]
            {
                CompletedCourseHelper.CreateDefaultCompletedCourse(
                    71,
                    "B: Course",
                    true,
                    isAssessed: true,
                    startedDate: new DateTime(2010, 1, 31),
                    lastAccessed: new DateTime(2010, 2, 22),
                    completed: new DateTime(2010, 3, 22),
                    evaluated: new DateTime(2010, 5, 5),
                    diagnosticScore: 123,
                    passes: 4
                    ),
                CompletedCourseHelper.CreateDefaultCompletedCourse(
                    72,
                    "C: Course",
                    true,
                    isAssessed: false,
                    startedDate: new DateTime(2010, 2, 1),
                    lastAccessed: new DateTime(2011, 2, 22),
                    completed: new DateTime(2011, 3, 22),
                    evaluated: new DateTime(2008, 5, 5),
                    diagnosticScore: 0,
                    passes: 14
                    ),
                CompletedCourseHelper.CreateDefaultCompletedCourse(
                    73,
                    "A: Course",
                    false,
                    isAssessed: true,
                    startedDate: new DateTime(2001, 1, 22),
                    lastAccessed: new DateTime(2011, 2, 23),
                    completed: new DateTime(2011, 2, 23),
                    evaluated: new DateTime(2009, 5, 5),
                    diagnosticScore: 0,
                    passes: 0
                    ),
            }.AsQueryable();

            availableCourses = new[]
            {
                AvailableCourseHelper.CreateDefaultAvailableCourse(
                    71,
                    "A: Course",
                    brand: "B: Brand",
                    category: "C: Category",
                    topic: "B: Topic"
                    ),
                AvailableCourseHelper.CreateDefaultAvailableCourse(
                    72,
                    "B: Course",
                    brand: "A: Brand",
                    category: null,
                    topic: "A: Topic"
                    ),
                AvailableCourseHelper.CreateDefaultAvailableCourse(
                    73,
                    "C: Course",
                    brand: "C: Brand",
                    category: "A: Category",
                    topic: null
                    ),
            }.AsQueryable();
        }