public void EditSupervisorPost_redirects_to_correct_action(
            DelegateAccessRoute accessedVia,
            string expectedController,
            string expectedAction
            )
        {
            // Given
            const int supervisorId = 1;
            var       formData     = new EditSupervisorFormData
            {
                SupervisorId    = supervisorId,
                ReturnPageQuery = ReturnPageQueryHelper.GetDefaultReturnPageQuery(itemIdToReturnTo: CardId),
            };

            A.CallTo(() => progressService.UpdateSupervisor(ProgressId, supervisorId)).DoesNothing();

            // When
            var result = delegateProgressController.EditSupervisor(formData, ProgressId, accessedVia);

            // Then
            var expectedFragment = accessedVia.Equals(DelegateAccessRoute.CourseDelegates) ? CardId : null;

            result.Should().BeRedirectToActionResult().WithControllerName(expectedController)
            .WithActionName(expectedAction).WithFragment(expectedFragment);
        }
Exemple #2
0
        public void ViewModel_sets_Enrolment_method_text_correctly(int enrolmentMethodId, string expectedText)
        {
            // Given
            var delegateInfo = new DelegateCourseInfo
            {
                EnrolmentMethodId     = enrolmentMethodId,
                EnrolledByForename    = "Ronnie",
                EnrolledBySurname     = "Dio",
                EnrolledByAdminActive = true,
                DelegateId            = 1,
            };
            var viewModel = new DelegateProgressViewModel(
                DelegateAccessRoute.ViewDelegate,
                new DetailedCourseProgress(
                    new Progress(),
                    new List <DetailedSectionProgress>(),
                    delegateInfo
                    ),
                A.Fake <IConfiguration>(),
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            viewModel.EnrolmentMethod.Should().Be(expectedText);
        }
Exemple #3
0
        public void EditRolesViewModel_sets_up_all_checkboxes_and_inputs_when_under_limits()
        {
            // Given
            var adminUser      = UserTestHelper.GetDefaultAdminUser();
            var numberOfAdmins = CentreContractAdminUsageTestHelper.GetDefaultNumberOfAdministrators();

            // When
            var result = new EditRolesViewModel(
                adminUser,
                1,
                categories,
                numberOfAdmins,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            using (new AssertionScope())
            {
                result.Checkboxes.Count.Should().Be(5);
                result.Radios.Count.Should().Be(3);
                result.Checkboxes.Contains(AdminRoleInputs.CentreAdminCheckbox).Should().BeTrue();
                result.Checkboxes.Contains(AdminRoleInputs.SupervisorCheckbox).Should().BeTrue();
                result.Checkboxes.Contains(AdminRoleInputs.TrainerCheckbox).Should().BeTrue();
                result.Checkboxes.Contains(AdminRoleInputs.ContentCreatorCheckbox).Should().BeTrue();
                result.Radios.Contains(AdminRoleInputs.CmsAdministratorRadioButton).Should().BeTrue();
                result.Radios.Contains(AdminRoleInputs.CmsManagerRadioButton).Should().BeTrue();
                result.Radios.Contains(AdminRoleInputs.NoCmsPermissionsRadioButton).Should().BeTrue();
                result.NotAllRolesDisplayed.Should().BeFalse();
                result.NoContentManagerOptionsAvailable.Should().BeFalse();
            }
        }
        public void EditDelegateCourseAdminField_POST_calls_service_and_redirects_to_correct_action(
            DelegateAccessRoute accessedVia,
            string expectedController,
            string expectedAction
            )
        {
            // Given
            const int    promptNumber = 1;
            const string answer       = "Test Answer";
            var          formData     = new EditDelegateCourseAdminFieldFormData
            {
                Answer          = answer,
                ReturnPageQuery = ReturnPageQueryHelper.GetDefaultReturnPageQuery(itemIdToReturnTo: CardId),
            };

            A.CallTo(() => progressService.UpdateCourseAdminFieldForDelegate(A <int> ._, A <int> ._, A <string> ._))
            .DoesNothing();

            // When
            var result = delegateProgressController.EditDelegateCourseAdminField(
                formData,
                promptNumber,
                ProgressId,
                accessedVia
                );

            // Then
            A.CallTo(() => progressService.UpdateCourseAdminFieldForDelegate(ProgressId, promptNumber, answer))
            .MustHaveHappenedOnceExactly();
            var expectedFragment = accessedVia.Equals(DelegateAccessRoute.CourseDelegates) ? CardId : null;

            result.Should().BeRedirectToActionResult().WithControllerName(expectedController)
            .WithActionName(expectedAction).WithFragment(expectedFragment);
        }
Exemple #5
0
        EditRolesViewModel_does_set_up_Cms_admin_radio_button_when_its_limit_is_reached_and_user_is_a_cms_admin()
        {
            // Given
            var adminUser      = UserTestHelper.GetDefaultAdminUser(importOnly: true, isContentManager: true);
            var numberOfAdmins =
                CentreContractAdminUsageTestHelper.GetDefaultNumberOfAdministrators(
                    cmsAdministrators: 5,
                    cmsAdministratorSpots: 5
                    );

            // When
            var result = new EditRolesViewModel(
                adminUser,
                1,
                categories,
                numberOfAdmins,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            using (new AssertionScope())
            {
                result.Radios.Count.Should().Be(3);
                result.Radios.Contains(AdminRoleInputs.CmsAdministratorRadioButton).Should().BeTrue();
                result.NotAllRolesDisplayed.Should().BeFalse();
                result.NoContentManagerOptionsAvailable.Should().BeFalse();
            }
        }
        public void EditCompleteByDatePost_redirects_to_correct_action(
            DelegateAccessRoute accessedVia,
            string expectedController,
            string expectedAction
            )
        {
            // Given
            var formData = new EditCompleteByDateFormData
            {
                Day             = 1,
                Month           = 1,
                Year            = 2021,
                ReturnPageQuery = ReturnPageQueryHelper.GetDefaultReturnPageQuery(itemIdToReturnTo: CardId),
            };

            A.CallTo(() => progressService.UpdateCompleteByDate(ProgressId, A <DateTime?> ._)).DoesNothing();

            // When
            var result = delegateProgressController.EditCompleteByDate(formData, ProgressId, accessedVia);

            // Then
            var expectedFragment = accessedVia.Equals(DelegateAccessRoute.CourseDelegates) ? CardId : null;

            result.Should().BeRedirectToActionResult().WithControllerName(expectedController)
            .WithActionName(expectedAction).WithFragment(expectedFragment);
        }
Exemple #7
0
        EditRolesViewModel_sets_only_NoCmsPermissions_radio_button_when_both_limits_reached_and_user_has_no_permissions()
        {
            // Given
            var adminUser      = UserTestHelper.GetDefaultAdminUser(importOnly: false, isContentManager: false);
            var numberOfAdmins =
                CentreContractAdminUsageTestHelper.GetDefaultNumberOfAdministrators(
                    cmsManagers: 5,
                    cmsManagerSpots: 5,
                    cmsAdministrators: 5,
                    cmsAdministratorSpots: 5
                    );

            // When
            var result = new EditRolesViewModel(
                adminUser,
                1,
                categories,
                numberOfAdmins,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            using (new AssertionScope())
            {
                result.Radios.Count.Should().Be(1);
                result.Radios.Contains(AdminRoleInputs.NoCmsPermissionsRadioButton).Should().BeTrue();
                result.NotAllRolesDisplayed.Should().BeTrue();
                result.NoContentManagerOptionsAvailable.Should().BeTrue();
            }
        }
Exemple #8
0
        public void GroupCourseViewModel_populates_expected_complete_within_value_for_one_month()
        {
            // Given
            var groupCourse = GroupTestHelper.GetDefaultGroupCourse(
                completeWithinMonths: 1
                );

            // When
            var result = new GroupCourseViewModel(groupCourse, ReturnPageQueryHelper.GetDefaultReturnPageQuery());

            // Then
            result.CompleteWithin.Should().Be("1 month");
        }
Exemple #9
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,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            currentCourseViewModel.HasDiagnosticScore().Should().BeFalse();
        }
Exemple #10
0
        public void Current_course_should_have_passed_sections_with_learning_assessment()
        {
            // Given
            var currentCourse = CurrentCourseHelper.CreateDefaultCurrentCourse();

            // When
            var currentCourseViewModel = new CurrentCourseViewModel(
                currentCourse,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            currentCourseViewModel.HasPassedSections().Should().BeTrue();
        }
Exemple #11
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,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            currentCourseViewModel.HasDiagnosticScore().Should().BeTrue();
        }
Exemple #12
0
        public void EditGroupName_should_redirect_to_not_found_page_when_linked_to_field_is_not_zero()
        {
            // Given
            A.CallTo(() => groupsService.GetGroupAtCentreById(1, 2))
            .Returns(new Group {
                LinkedToField = 1
            });

            // When
            var result = delegateGroupsController.EditGroupName(1, ReturnPageQueryHelper.GetDefaultReturnPageQuery());

            // Then
            A.CallTo(() => groupsService.GetGroupAtCentreById(1, 2)).MustHaveHappened();
            result.Should().BeNotFoundResult();
        }
        public void Self_assessment_should__be_due_soon_when_complete_by_date_is_in_the_future()
        {
            // Given
            var selfAssessment =
                SelfAssessmentHelper.CreateDefaultSelfAssessment(completeByDate: DateTime.Today + TimeSpan.FromDays(1));

            // When
            var selfAssessmentCardViewModel = new SelfAssessmentCardViewModel(
                selfAssessment,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            selfAssessmentCardViewModel.DateStyle().Should().Be("due-soon");
        }
Exemple #14
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,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            currentCourseViewModel.DateStyle().Should().Be("overdue");
        }
Exemple #15
0
        public void GroupCourseViewModel_populates_expected_values_with_supervisor_name()
        {
            // Given
            var groupCourse = GroupTestHelper.GetDefaultGroupCourse(
                supervisorFirstName: "Test",
                supervisorLastName: "Name",
                supervisorActive: true
                );

            // When
            var result = new GroupCourseViewModel(groupCourse, ReturnPageQueryHelper.GetDefaultReturnPageQuery());

            // Then
            result.Supervisor.Should().Be("Test Name");
        }
Exemple #16
0
        public void GroupCourseViewModel_populates_expected_values_for_mandatory_assessed_course()
        {
            // Given
            var groupCourse = GroupTestHelper.GetDefaultGroupCourse(isMandatory: true, isAssessed: true);

            // When
            var result = new GroupCourseViewModel(groupCourse, ReturnPageQueryHelper.GetDefaultReturnPageQuery());

            // Then
            using (new AssertionScope())
            {
                result.IsMandatory.Should().Be("Mandatory");
                result.IsAssessed.Should().Be("Assessed");
            }
        }
Exemple #17
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,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            currentCourseViewModel.DateStyle().Should().Be("");
        }
Exemple #18
0
        public void DeleteGroup_deletes_group_with_no_delegates_or_courses()
        {
            // Given
            A.CallTo(() => groupsService.GetGroupCentreId(A <int> ._))
            .Returns(delegateGroupsController.User.GetCentreId());
            const int groupId = 1;

            // When
            var result = delegateGroupsController.DeleteGroup(
                groupId,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            A.CallTo(() => groupsService.DeleteDelegateGroup(groupId, false)).MustHaveHappenedOnceExactly();
            result.Should().BeRedirectToActionResult().WithActionName("Index");
        }
        public void DelegateCourseInfoViewModel_without_customisation_name_sets_course_name_correctly()
        {
            // Given
            var info = new DelegateCourseInfo
            {
                ApplicationName = "my application", CustomisationName = "",
            };

            // When
            var model = new DelegateCourseInfoViewModel(
                info,
                DelegateAccessRoute.CourseDelegates,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            model.CourseName.Should().Be("my application");
        }
        public void DelegateCourseInfoViewModel_without_supervisor_surname_sets_supervisor_correctly()
        {
            // Given
            var info = new DelegateCourseInfo
            {
                SupervisorAdminId = null,
                SupervisorSurname = null,
            };

            // When
            var model = new DelegateCourseInfoViewModel(
                info,
                DelegateAccessRoute.CourseDelegates,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            model.Supervisor.Should().Be("None");
        }
        public void Delegate_removal_for_valid_delegate_returns_redirect_to_action_course_delegates()
        {
            // Given
            var delegateCourseInfo = new DelegateCourseInfo
            {
                DelegateId = DelegateId, CustomisationId = CustomisationId
            };
            var delegateCourseDetails = new DetailedCourseProgress(
                new Progress {
                CandidateId = DelegateId, CustomisationId = CustomisationId
            },
                new List <DetailedSectionProgress>(),
                delegateCourseInfo
                );

            A.CallTo(() => progressService.GetDetailedCourseProgress(ProgressId))
            .Returns(delegateCourseDetails);

            A.CallTo(() => courseService.DelegateHasCurrentProgress(ProgressId))
            .Returns(true);

            var model = new RemoveFromCourseViewModel
            {
                Confirm         = true,
                AccessedVia     = DelegateAccessRoute.CourseDelegates,
                ReturnPageQuery = ReturnPageQueryHelper.GetDefaultReturnPageQuery(),
            };

            // When
            var result = delegateProgressController.ExecuteRemoveFromCourse(
                ProgressId,
                DelegateAccessRoute.CourseDelegates,
                model
                );

            // Then
            result.Should()
            .BeRedirectToActionResult()
            .WithActionName("Index")
            .WithControllerName("CourseDelegates")
            .WithRouteValue("customisationId", CustomisationId.ToString());
        }
Exemple #22
0
        public void Removing_non_existent_course_should_return_404()
        {
            // Given
            var currentCourses = new[]
            {
                CurrentCourseHelper.CreateDefaultCurrentCourse(2),
            };

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

            // When
            var result = controller.RemoveCurrentCourseConfirmation(3, ReturnPageQueryHelper.GetDefaultReturnPageQuery());

            // Then
            result.Should()
            .BeRedirectToActionResult()
            .WithControllerName("LearningSolutions")
            .WithActionName("StatusCode")
            .WithRouteValue("code", 404);
        }
        public void RemoveGroupCourseViewModel_Constructor_CorrectlySetsProperties()
        {
            // Given
            var courseId   = 1;
            var courseName = "Test Course";
            var groupName  = "Test Group";

            // When
            var result = new RemoveGroupCourseViewModel(
                courseId,
                courseName,
                groupName,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            result.GroupCourseId.Should().Be(1);
            result.CourseName.Should().Be("Test Course");
            result.GroupName.Should().Be("Test Group");
        }
        public async Task AddResourceToActionPlan_returns_not_found_when_resource_already_in_action_plan()
        {
            // Given
            const int resourceReferenceId = 1;

            A.CallTo(() => actionPlanService.ResourceCanBeAddedToActionPlan(resourceReferenceId, DelegateId))
            .Returns(false);

            // When
            var result = await controller.AddResourceToActionPlan(
                SelfAssessmentId,
                resourceReferenceId,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            result.Should().BeNotFoundResult();
            A.CallTo(() => actionPlanService.AddResourceToActionPlan(A <int> ._, A <int> ._, A <int> ._))
            .MustNotHaveHappened();
        }
        public void DelegateCourseInfoViewModel_with_supervisor_forename_sets_supervisor_correctly()
        {
            // Given
            var info = new DelegateCourseInfo
            {
                SupervisorForename    = "firstname",
                SupervisorSurname     = "surname",
                SupervisorAdminActive = true,
            };

            // When
            var model = new DelegateCourseInfoViewModel(
                info,
                DelegateAccessRoute.CourseDelegates,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            model.Supervisor.Should().Be("firstname surname");
        }
Exemple #26
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, ReturnPageQueryHelper.GetDefaultReturnPageQuery());

            // Then
            var expectedModel = new CurrentCourseViewModel(currentCourse, ReturnPageQueryHelper.GetDefaultReturnPageQuery());

            result.Should().BeViewResult()
            .Model.Should().BeEquivalentTo(expectedModel);
        }
Exemple #27
0
        public void EditRolesViewModel_sets_ContentManagementRole_none()
        {
            // Given
            var adminUser = UserTestHelper.GetDefaultAdminUser(
                isContentManager: false,
                importOnly: false
                );
            var numberOfAdmins = CentreContractAdminUsageTestHelper.GetDefaultNumberOfAdministrators();

            // When
            var result = new EditRolesViewModel(
                adminUser,
                1,
                categories,
                numberOfAdmins,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            result.ContentManagementRole.Should().BeEquivalentTo(ContentManagementRole.NoContentManagementRole);
        }
        AddResourceToActionPlan_adds_resource_and_returns_redirect_with_correct_return_page_when_resource_not_in_action_plan()
        {
            // Given
            const int resourceReferenceId = 1;

            A.CallTo(() => actionPlanService.ResourceCanBeAddedToActionPlan(resourceReferenceId, DelegateId))
            .Returns(true);

            // When
            var result = await controller.AddResourceToActionPlan(
                SelfAssessmentId,
                resourceReferenceId,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery(3)
                );

            // Then
            A.CallTo(() => actionPlanService.AddResourceToActionPlan(resourceReferenceId, DelegateId, SelfAssessmentId))
            .MustHaveHappenedOnceExactly();
            result.Should().BeRedirectToActionResult().WithActionName("RecommendedLearning")
            .WithRouteValue("selfAssessmentId", SelfAssessmentId.ToString()).WithRouteValue("page", "3");
        }
        public void Recommendation_Rating_string_gets_populated_with_the_expected_value(
            decimal recommendationScore,
            string expectedRating
            )
        {
            // Given
            var recommendedResource = new RecommendedResource
            {
                RecommendationScore = recommendationScore, ResourceType = "Article"
            };

            // When
            var result = new SearchableRecommendedResourceViewModel(
                recommendedResource,
                1,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            result.Rating.Should().BeEquivalentTo(expectedRating);
        }
        public void SearchableDelegateGroupViewModel_populates_expected_values()
        {
            // Given
            var group = new Group
            {
                GroupId                        = 1,
                GroupLabel                     = "Group name",
                GroupDescription               = null,
                DelegateCount                  = 5,
                CoursesCount                   = 10,
                AddedByFirstName               = "Test",
                AddedByLastName                = "Person",
                AddedByAdminActive             = true,
                LinkedToField                  = 0,
                LinkedToFieldName              = "None",
                ShouldAddNewRegistrantsToGroup = false,
                ChangesToRegistrationDetailsShouldChangeGroupMembership = false,
            };

            // When
            var result = new SearchableDelegateGroupViewModel(
                group,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery(3, itemIdToReturnTo: "1-card")
                );

            // Then
            using (new AssertionScope())
            {
                result.Id.Should().Be(1);
                result.Name.Should().Be("Group name");
                result.Description.Should().BeNull();
                result.DelegateCount.Should().Be(5);
                result.CourseCount.Should().Be(10);
                result.AddedBy.Should().Be("Test Person");
                result.LinkedToField.Should().Be(0);
                result.LinkedField.Should().Be("None");
                result.ShouldAddNewRegistrantsToGroup.Should().Be("No");
                result.ChangesToRegistrationDetailsShouldChangeGroupMembership.Should().Be("No");
            }
        }