Esempio n. 1
0
        public void GetCustomPromptsWithAnswersForCourse_Returns_Populated_List_of_CustomPromptWithAnswer()
        {
            // Given
            const string answer1   = "ans1";
            const string answer2   = "ans2";
            var          expected1 = CustomPromptsTestHelper.GetDefaultCustomPromptWithAnswer(
                1,
                "System Access Granted",
                "Test",
                answer: answer1
                );
            var expected2 = CustomPromptsTestHelper.GetDefaultCustomPromptWithAnswer(
                2,
                "Priority Access",
                answer: answer2
                );
            var expected = new List <CustomPromptWithAnswer> {
                expected1, expected2
            };

            A.CallTo(() => courseAdminFieldsDataService.GetCourseAdminFields(100))
            .Returns(CustomPromptsTestHelper.GetDefaultCourseAdminFieldsResult());
            var delegateCourseInfo = new DelegateCourseInfo {
                Answer1 = answer1, Answer2 = answer2
            };

            // When
            var result = courseAdminFieldsService.GetCustomPromptsWithAnswersForCourse(delegateCourseInfo, 100);

            // Then
            result.Should().BeEquivalentTo(expected);
        }
Esempio n. 2
0
        public void ValidateCustomPrompts_adds_error_for_too_long_answer()
        {
            // Given
            const string?longAnswer2 =
                "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
            var customPrompt1       = CustomPromptsTestHelper.GetDefaultCustomPrompt(1);
            var customPrompt2       = CustomPromptsTestHelper.GetDefaultCustomPrompt(2);
            var centreCustomPrompts = CustomPromptsTestHelper.GetDefaultCentreCustomPrompts(
                new List <CustomPrompt> {
                customPrompt1, customPrompt2
            },
                1
                );
            var modelState = new ModelStateDictionary();

            A.CallTo(() => centreCustomPromptsService.GetCustomPromptsForCentreByCentreId(1))
            .Returns(centreCustomPrompts);

            // When
            centreCustomPromptHelper.ValidateCustomPrompts(1, Answer1, longAnswer2, null, null, null, null, modelState);

            // Then
            modelState[Answer1].Should().BeNull();
            modelState[Answer2].Errors.Count.Should().Be(1);
        }
Esempio n. 3
0
        public void GetCustomFieldViewModelsForCentre_returns_populated_list()
        {
            // Given
            var customPrompt1       = CustomPromptsTestHelper.GetDefaultCustomPrompt(1, options: "Clinical\r\nNon-Clinical");
            var customPrompt2       = CustomPromptsTestHelper.GetDefaultCustomPrompt(2);
            var centreCustomPrompts = CustomPromptsTestHelper.GetDefaultCentreCustomPrompts(
                new List <CustomPrompt> {
                customPrompt1, customPrompt2
            },
                1
                );

            A.CallTo(() => centreCustomPromptsService.GetCustomPromptsForCentreByCentreId(1))
            .Returns(centreCustomPrompts);

            // When
            var result =
                centreCustomPromptHelper.GetCustomFieldViewModelsForCentre(1, Answer1, Answer2, null, null, null, null);

            // Then
            using (new AssertionScope())
            {
                result.Count.Should().Be(2);
                result[0].CustomFieldId.Should().Be(1);
                result[1].CustomFieldId.Should().Be(2);
            }
        }
Esempio n. 4
0
        public void UnapprovedDelegate_delegateUser_and_customPrompts_populate_expected_values()
        {
            // Given
            var delegateUser  = UserTestHelper.GetDefaultDelegateUser();
            var customPrompts = new List <CustomPromptWithAnswer>
            {
                CustomPromptsTestHelper.GetDefaultCustomPromptWithAnswer(1)
            };

            // When
            var returnedModel = new UnapprovedDelegate(delegateUser, customPrompts);

            // Then
            using (new AssertionScope())
            {
                returnedModel.Id.Should().Be(delegateUser.Id);
                returnedModel.CandidateNumber.Should().Be(delegateUser.CandidateNumber);
                returnedModel.FullName.Should().Be(delegateUser.FirstName + " " + delegateUser.LastName);
                returnedModel.DateRegistered.Should().Be(delegateUser.DateRegistered);
                returnedModel.Email.Should().Be(delegateUser.EmailAddress);
                returnedModel.JobGroup.Should().Be(delegateUser.JobGroupName);
                returnedModel.CustomPrompts.Should().NotBeNullOrEmpty();

                var promptModel = returnedModel.CustomPrompts.First();
                var promptData  = customPrompts.First();
                promptModel.Answer.Should().Be(promptData.Answer);
                promptModel.CustomPrompt.Should().Be(promptData.CustomPromptText);
                promptModel.CustomFieldId.Should().Be(promptData.CustomPromptNumber);
                promptModel.Mandatory.Should().Be(promptData.Mandatory);
            }
        }
Esempio n. 5
0
        public void GetCustomPromptsForCentreByCentreId_Returns_Populated_CentreCustomPrompts()
        {
            // Given
            var expectedPrompt1 = CustomPromptsTestHelper.GetDefaultCustomPrompt(1, options: null, mandatory: true);
            var expectedPrompt2 = CustomPromptsTestHelper.GetDefaultCustomPrompt(2, "Department / team", null, true);
            var customPrompts   = new List <CustomPrompt> {
                expectedPrompt1, expectedPrompt2
            };
            var expectedCustomerPrompts = CustomPromptsTestHelper.GetDefaultCentreCustomPrompts(customPrompts);

            A.CallTo(() => centreCustomPromptsDataService.GetCentreCustomPromptsByCentreId(29))
            .Returns
            (
                CustomPromptsTestHelper.GetDefaultCentreCustomPromptsResult(
                    customField1Prompt: "Custom Prompt",
                    customField1Options: null
                    )
            );

            // When
            var result = centreCustomPromptsService.GetCustomPromptsForCentreByCentreId(29);

            // Then
            result.Should().BeEquivalentTo(expectedCustomerPrompts);
        }
Esempio n. 6
0
        GetUnapprovedDelegatesWithCustomPromptAnswersForCentre_returns_unapproved_delegates_with_custom_prompt_answers_for_centre()
        {
            // Given
            var expectedDelegateUser = UserTestHelper.GetDefaultDelegateUser();
            var expectedUserList     = new List <DelegateUser> {
                expectedDelegateUser
            };
            var expectedCustomPrompts = new List <CustomPromptWithAnswer>
            {
                CustomPromptsTestHelper.GetDefaultCustomPromptWithAnswer(
                    1,
                    options: null,
                    mandatory: true,
                    answer: "answer"
                    )
            };

            A.CallTo(() => userDataService.GetUnapprovedDelegateUsersByCentreId(2))
            .Returns(expectedUserList);
            A.CallTo(
                () => centreCustomPromptsService.GetCentreCustomPromptsWithAnswersByCentreIdForDelegateUsers(
                    2,
                    expectedUserList
                    )
                )
            .Returns(
                new List <(DelegateUser delegateUser, List <CustomPromptWithAnswer> prompts)>
            {
                (expectedDelegateUser, expectedCustomPrompts)
            }
Esempio n. 7
0
        public void MyAccountViewModel_DelegateUser_no_AdminUser_populates_expected_values()
        {
            // Given
            var delegateUser  = UserTestHelper.GetDefaultDelegateUser();
            var customPrompts = CustomPromptsTestHelper.GetDefaultCentreCustomPromptsWithAnswers(
                new List <CustomPromptWithAnswer>
            {
                CustomPromptsTestHelper.GetDefaultCustomPromptWithAnswer(1),
            }
                );

            // When
            var returnedModel = new MyAccountViewModel(null, delegateUser, customPrompts, DlsSubApplication.Default);

            // Then
            using (new AssertionScope())
            {
                returnedModel.FirstName.Should().BeEquivalentTo(delegateUser.FirstName);
                returnedModel.Centre.Should().BeEquivalentTo(delegateUser.CentreName);
                returnedModel.Surname.Should().BeEquivalentTo(delegateUser.LastName);
                returnedModel.ProfilePicture.Should().BeEquivalentTo(delegateUser.ProfileImage);
                returnedModel.DelegateNumber.Should().BeEquivalentTo(delegateUser.CandidateNumber);
                returnedModel.User.Should().BeEquivalentTo(delegateUser.EmailAddress);
                returnedModel.JobGroup.Should().BeEquivalentTo(delegateUser.JobGroupName);
                returnedModel.CustomFields.Should().NotBeNullOrEmpty();
            }
        }
Esempio n. 8
0
        public void GetLinkedFieldOptions_returns_expected_filter_options()
        {
            // Given
            var prompt1 = CustomPromptsTestHelper.GetDefaultCustomPrompt(1, "Prompt 1");
            var prompt2 = CustomPromptsTestHelper.GetDefaultCustomPrompt(2, "Prompt 2");
            var prompt3 = CustomPromptsTestHelper.GetDefaultCustomPrompt(3, "Prompt 3");
            var prompt4 = CustomPromptsTestHelper.GetDefaultCustomPrompt(4, "Prompt 4");
            var prompt5 = CustomPromptsTestHelper.GetDefaultCustomPrompt(5, "Prompt 5");
            var prompt6 = CustomPromptsTestHelper.GetDefaultCustomPrompt(6, "Prompt 6");
            var prompts = new[] { prompt1, prompt2, prompt3, prompt4, prompt5, prompt6 };

            // When
            var result = DelegateGroupsViewModelFilterOptions.GetLinkedFieldOptions(prompts).ToList();

            // Then
            using (new AssertionScope())
            {
                result.Count.Should().Be(8);
                result.Single(f => f.DisplayText == "Prompt 1").FilterValue.Should()
                    .Be("LinkedToField|LinkedToField|1");
                result.Single(f => f.DisplayText == "Prompt 2").FilterValue.Should()
                    .Be("LinkedToField|LinkedToField|2");
                result.Single(f => f.DisplayText == "Prompt 3").FilterValue.Should()
                    .Be("LinkedToField|LinkedToField|3");
                result.Single(f => f.DisplayText == "Prompt 4").FilterValue.Should()
                    .Be("LinkedToField|LinkedToField|5");
                result.Single(f => f.DisplayText == "Prompt 5").FilterValue.Should()
                    .Be("LinkedToField|LinkedToField|6");
                result.Single(f => f.DisplayText == "Prompt 6").FilterValue.Should()
                    .Be("LinkedToField|LinkedToField|7");
            }
        }
Esempio n. 9
0
        public void MyAccountViewModel_CustomFields_ShouldBePopulated()
        {
            // Given
            var delegateUser  = UserTestHelper.GetDefaultDelegateUser();
            var customPrompts = CustomPromptsTestHelper.GetDefaultCentreCustomPromptsWithAnswers(
                new List <CustomPromptWithAnswer>
            {
                CustomPromptsTestHelper.GetDefaultCustomPromptWithAnswer(1),
                CustomPromptsTestHelper.GetDefaultCustomPromptWithAnswer(2),
            }
                );

            // When
            var returnedModel = new MyAccountViewModel(null, delegateUser, customPrompts, DlsSubApplication.Default);

            // Then
            using (new AssertionScope())
            {
                returnedModel.CustomFields.Should().NotBeNullOrEmpty();
                returnedModel.CustomFields[0].CustomFieldId.Should().Be(1);
                returnedModel.CustomFields[0].CustomPrompt.Should()
                .BeEquivalentTo(customPrompts.CustomPrompts[0].CustomPromptText);
                returnedModel.CustomFields[0].Answer.Should().BeEquivalentTo(delegateUser.Answer1);
                returnedModel.CustomFields[0].Mandatory.Should().BeFalse();

                returnedModel.CustomFields[1].CustomFieldId.Should().Be(2);
                returnedModel.CustomFields[1].CustomPrompt.Should()
                .BeEquivalentTo(customPrompts.CustomPrompts[1].CustomPromptText);
                returnedModel.CustomFields[1].Answer.Should().BeEquivalentTo(delegateUser.Answer1);
                returnedModel.CustomFields[1].Mandatory.Should().BeFalse();
            }
        }
Esempio n. 10
0
        public void GetCentreCustomPromptsWithAnswersByCentreIdForDelegateUsers_Returns_Populated_Tuple()
        {
            // Given
            const string answer1         = "Answer 1";
            const string answer2         = "Answer 2";
            var          delegateUser1   = UserTestHelper.GetDefaultDelegateUser(answer1: answer1);
            var          delegateUser2   = UserTestHelper.GetDefaultDelegateUser(answer1: answer2);
            var          expectedPrompt1 = CustomPromptsTestHelper.GetDefaultCustomPromptWithAnswer(
                1,
                options: null,
                mandatory: true,
                answer: answer1
                );
            var expectedPrompt2 =
                CustomPromptsTestHelper.GetDefaultCustomPromptWithAnswer(2, "Department / team", null, true);
            var expectedPrompt3 = CustomPromptsTestHelper.GetDefaultCustomPromptWithAnswer(
                1,
                options: null,
                mandatory: true,
                answer: answer2
                );

            A.CallTo(() => centreCustomPromptsDataService.GetCentreCustomPromptsByCentreId(29))
            .Returns(
                CustomPromptsTestHelper.GetDefaultCentreCustomPromptsResult(
                    customField1Prompt: "Custom Prompt",
                    customField1Options: null
                    )
                );

            // When
            var result = centreCustomPromptsService.GetCentreCustomPromptsWithAnswersByCentreIdForDelegateUsers(
                29,
                new[] { delegateUser1, delegateUser2 }
                );

            // Then
            using (new AssertionScope())
            {
                result.Count.Should().Be(2);

                var first = result.First();
                first.Item1.Should().BeEquivalentTo(delegateUser1);
                first.Item2.Count.Should().Be(2);
                first.Item2[0].Should().BeEquivalentTo(expectedPrompt1);
                first.Item2[1].Should().BeEquivalentTo(expectedPrompt2);

                var second = result.Last();
                second.Item1.Should().BeEquivalentTo(delegateUser2);
                second.Item2.Count.Should().Be(2);
                second.Item2[0].Should().BeEquivalentTo(expectedPrompt3);
                second.Item2[1].Should().BeEquivalentTo(expectedPrompt2);
            }
        }
Esempio n. 11
0
        public void GetCentreCustomPromptsByCentreId_Returns_populated_CentreCustomPromptsResult()
        {
            // Given
            var expectedCentreCustomPromptsResult = CustomPromptsTestHelper.GetDefaultCentreCustomPromptsResult();

            // When
            var returnedCentreCustomPromptsResult = centreCustomPromptsDataService.GetCentreCustomPromptsByCentreId(29);

            // Then
            returnedCentreCustomPromptsResult.Should().BeEquivalentTo(expectedCentreCustomPromptsResult);
        }
Esempio n. 12
0
        public void GetCustomPrompts_with_options_splits_correctly()
        {
            // Given
            A.CallTo(() => centreCustomPromptsDataService.GetCentreCustomPromptsByCentreId(29))
            .Returns(CustomPromptsTestHelper.GetDefaultCentreCustomPromptsResult());

            // When
            var result = centreCustomPromptsService.GetCustomPromptsForCentreByCentreId(29);

            // Then
            using (new AssertionScope())
            {
                result.CustomPrompts.Should().NotBeNull();
                result.CustomPrompts[0].Options.Count.Should().Be(2);
                result.CustomPrompts[0].Options[0].Should().BeEquivalentTo("Clinical");
                result.CustomPrompts[0].Options[1].Should().BeEquivalentTo("Non-Clinical");
            }
        }
Esempio n. 13
0
        public void EditDetailsPostSave_without_previewing_profile_image_fails_validation()
        {
            // Given
            var myAccountController = new MyAccountController(
                centreCustomPromptsService,
                userService,
                imageResizeService,
                jobGroupsDataService,
                centreCustomPromptHelper
                ).WithDefaultContext().WithMockUser(true, adminId: null);
            var customPromptLists = new List <CustomPrompt>
            {
                CustomPromptsTestHelper.GetDefaultCustomPrompt(1, mandatory: true)
            };

            A.CallTo
                (() => centreCustomPromptsService.GetCustomPromptsForCentreByCentreId(2)).Returns(
                CustomPromptsTestHelper.GetDefaultCentreCustomPrompts(customPromptLists, 2)
                );
            var formData = new MyAccountEditDetailsFormData
            {
                ProfileImageFile = A.Fake <FormFile>(),
            };
            var expectedPrompt = new EditCustomFieldViewModel(1, "Custom Prompt", true, new List <string>(), null);
            var expectedModel  = new MyAccountEditDetailsViewModel(
                formData,
                new List <(int id, string name)>(),
                new List <EditCustomFieldViewModel> {
                expectedPrompt
            },
                DlsSubApplication.Default
                );

            // When
            var result = myAccountController.EditDetails(formData, "save", DlsSubApplication.Default);

            // Then
            A.CallTo(() => userService.NewEmailAddressIsValid(A <string> ._, A <int?> ._, A <int?> ._, A <int> ._))
            .MustNotHaveHappened();
            result.As <ViewResult>().Model.As <MyAccountEditDetailsViewModel>().Should().BeEquivalentTo(expectedModel);
            myAccountController.ModelState[nameof(MyAccountEditDetailsFormData.ProfileImageFile)].ValidationState
            .Should().Be(ModelValidationState.Invalid);
        }
Esempio n. 14
0
        public void AdminFields_returns_AdminFields_page_when_appropriate_course_found_and_clears_TempData()
        {
            // Given
            var samplePrompt1 = CustomPromptsTestHelper.GetDefaultCustomPrompt(1, "System Access Granted", "Yes\r\nNo");
            var customPrompts = new List <CustomPrompt> {
                samplePrompt1
            };

            A.CallTo(() => courseAdminFieldsService.GetCustomPromptsForCourse(A <int> ._))
            .Returns(CustomPromptsTestHelper.GetDefaultCourseAdminFields(customPrompts));
            controller.TempData.Set(samplePrompt1);

            // When
            var result = controller.Index(1);

            // Then
            controller.TempData.Peek <CustomPrompt>().Should().BeNull();
            result.Should().BeViewResult().WithDefaultViewName().ModelAs <AdminFieldsViewModel>();
        }
Esempio n. 15
0
        public void GetEditCustomFieldViewModelsForCentre_returns_correctly_mapped_answers_with_gap_in_prompts()
        {
            // Given
            var customPrompt1       = CustomPromptsTestHelper.GetDefaultCustomPrompt(1, options: "Clinical\r\nNon-Clinical");
            var customPrompt3       = CustomPromptsTestHelper.GetDefaultCustomPrompt(3);
            var centreCustomPrompts = CustomPromptsTestHelper.GetDefaultCentreCustomPrompts(
                new List <CustomPrompt> {
                customPrompt1, customPrompt3
            },
                1
                );

            A.CallTo(() => centreCustomPromptsService.GetCustomPromptsForCentreByCentreId(1))
            .Returns(centreCustomPrompts);

            // When
            var result =
                centreCustomPromptHelper.GetEditCustomFieldViewModelsForCentre(
                    1,
                    Answer1,
                    Answer2,
                    Answer3,
                    null,
                    null,
                    null
                    );

            // Then
            using (new AssertionScope())
            {
                result.Count.Should().Be(2);

                result[0].CustomFieldId.Should().Be(1);
                result[0].Options.Count().Should().Be(2);
                result[0].Options.First().Value.Should().BeEquivalentTo("Clinical");
                result[0].Answer.Should().BeEquivalentTo(Answer1);

                result[1].CustomFieldId.Should().Be(3);
                result[1].Options.Count().Should().Be(0);
                result[1].Answer.Should().BeEquivalentTo(Answer3);
            }
        }
Esempio n. 16
0
        public void GetCustomPromptsForCourse_Returns_Populated_CourseAdminFields()
        {
            // Given
            var expectedPrompt1 =
                CustomPromptsTestHelper.GetDefaultCustomPrompt(1, "System Access Granted", "Test");
            var expectedPrompt2 = CustomPromptsTestHelper.GetDefaultCustomPrompt(2, "Priority Access");
            var customPrompts   = new List <CustomPrompt> {
                expectedPrompt1, expectedPrompt2
            };
            var expectedCourseAdminFields = CustomPromptsTestHelper.GetDefaultCourseAdminFields(customPrompts);

            A.CallTo(() => courseAdminFieldsDataService.GetCourseAdminFields(100))
            .Returns(CustomPromptsTestHelper.GetDefaultCourseAdminFieldsResult());

            // When
            var result = courseAdminFieldsService.GetCustomPromptsForCourse(100);

            // Then
            result.Should().BeEquivalentTo(expectedCourseAdminFields);
        }
Esempio n. 17
0
        public void GetCourseAdminFields_returns_populated_CourseAdminFieldsResult()
        {
            // Given
            var expectedCourseAdminFieldsResult =
                CustomPromptsTestHelper.GetDefaultCourseAdminFieldsResult(
                    "System Access Granted",
                    "Test",
                    "Priority Access",
                    null,
                    null,
                    null,
                    2
                    );

            // When
            var returnedCourseAdminFieldsResult = courseAdminFieldsDataService.GetCourseAdminFields(100);

            // Then
            returnedCourseAdminFieldsResult.Should().BeEquivalentTo(expectedCourseAdminFieldsResult);
        }
Esempio n. 18
0
        public void AddCustomPromptToCourse_adds_prompt_to_course_at_next_prompt_number()
        {
            // Given
            A.CallTo
            (
                () => courseAdminFieldsDataService.UpdateCustomPromptForCourse(100, A <int> ._, A <int> ._, null)
            ).DoesNothing();
            A.CallTo(() => courseAdminFieldsDataService.GetCourseAdminFields(100))
            .Returns(CustomPromptsTestHelper.GetDefaultCourseAdminFieldsResult());

            // When
            var result = courseAdminFieldsService.AddCustomPromptToCourse(100, 3, null);

            // Then
            A.CallTo
            (
                () => courseAdminFieldsDataService.UpdateCustomPromptForCourse(100, 3, 3, null)
            ).MustHaveHappened();
            result.Should().BeTrue();
        }
Esempio n. 19
0
        public void MyAccountViewModel_where_user_has_not_been_asked_for_prn_says_not_yet_provided()
        {
            // Given
            var delegateUser = UserTestHelper.GetDefaultDelegateUser(
                hasBeenPromptedForPrn: false,
                professionalRegistrationNumber: null
                );
            var customPrompts = CustomPromptsTestHelper.GetDefaultCentreCustomPromptsWithAnswers(
                new List <CustomPromptWithAnswer> {
            }
                );

            // When
            var returnedModel = new MyAccountViewModel(null, delegateUser, customPrompts, DlsSubApplication.Default);

            // Then
            using (new AssertionScope())
            {
                returnedModel.ProfessionalRegistrationNumber.Should().Be("Not yet provided");
            }
        }
Esempio n. 20
0
        public void AddCustomPromptToCourse_does_not_add_prompt_if_course_has_all_prompts_defined()
        {
            // Given
            A.CallTo
            (
                () => courseAdminFieldsDataService.UpdateCustomPromptForCourse(100, A <int> ._, A <int> ._, null)
            ).DoesNothing();
            A.CallTo(() => courseAdminFieldsDataService.GetCourseAdminFields(100))
            .Returns(
                CustomPromptsTestHelper.GetDefaultCourseAdminFieldsResult(
                    "System Access Granted",
                    "Test",
                    "Priority Access",
                    "",
                    "Access Permissions"
                    )
                );

            // When
            var result = courseAdminFieldsService.AddCustomPromptToCourse(
                100,
                3,
                "Adding a fourth prompt"
                );

            // Then
            using (new AssertionScope())
            {
                A.CallTo(
                    () => courseAdminFieldsDataService.UpdateCustomPromptForCourse(
                        100,
                        A <int> ._,
                        A <int> ._,
                        "Adding a fourth prompt"
                        )
                    )
                .MustNotHaveHappened();
                result.Should().BeFalse();
            }
        }
Esempio n. 21
0
        public void ValidateCustomPrompts_adds_error_for_missing_mandatory_answer()
        {
            // Given
            var customPrompt1       = CustomPromptsTestHelper.GetDefaultCustomPrompt(1, mandatory: true);
            var customPrompt2       = CustomPromptsTestHelper.GetDefaultCustomPrompt(2, mandatory: true);
            var centreCustomPrompts = CustomPromptsTestHelper.GetDefaultCentreCustomPrompts(
                new List <CustomPrompt> {
                customPrompt1, customPrompt2
            },
                1
                );
            var modelState = new ModelStateDictionary();

            A.CallTo(() => centreCustomPromptsService.GetCustomPromptsForCentreByCentreId(1))
            .Returns(centreCustomPrompts);

            // When
            centreCustomPromptHelper.ValidateCustomPrompts(1, null, Answer2, null, null, null, null, modelState);

            // Then
            modelState["Answer1"].Errors.Count.Should().Be(1);
            modelState["Answer2"].Should().BeNull();
        }
Esempio n. 22
0
        public void MyAccountViewModel_with_prn_displays_prn()
        {
            // Given
            var delegateUser = UserTestHelper.GetDefaultDelegateUser(
                hasBeenPromptedForPrn: true,
                professionalRegistrationNumber: "12345678"
                );
            var customPrompts = CustomPromptsTestHelper.GetDefaultCentreCustomPromptsWithAnswers(
                new List <CustomPromptWithAnswer>
            {
                CustomPromptsTestHelper.GetDefaultCustomPromptWithAnswer(1),
                CustomPromptsTestHelper.GetDefaultCustomPromptWithAnswer(2),
            }
                );

            // When
            var returnedModel = new MyAccountViewModel(null, delegateUser, customPrompts, DlsSubApplication.Default);

            // Then
            using (new AssertionScope())
            {
                returnedModel.ProfessionalRegistrationNumber.Should().Be(delegateUser.ProfessionalRegistrationNumber);
            }
        }
Esempio n. 23
0
        public void GetCentreCustomPromptsWithAnswersByCentreIdAndDelegateUser_Returns_Populated_CentreCustomPrompts()
        {
            // Given
            var answer1         = "Answer 1";
            var delegateUser    = UserTestHelper.GetDefaultDelegateUser(answer1: answer1);
            var expectedPrompt1 =
                CustomPromptsTestHelper.GetDefaultCustomPromptWithAnswer(
                    1,
                    options: null,
                    mandatory: true,
                    answer: answer1
                    );
            var expectedPrompt2 =
                CustomPromptsTestHelper.GetDefaultCustomPromptWithAnswer(2, "Department / team", null, true);
            var customPrompts = new List <CustomPromptWithAnswer> {
                expectedPrompt1, expectedPrompt2
            };
            var expectedCustomerPrompts =
                CustomPromptsTestHelper.GetDefaultCentreCustomPromptsWithAnswers(customPrompts);

            A.CallTo(() => centreCustomPromptsDataService.GetCentreCustomPromptsByCentreId(29))
            .Returns
            (
                CustomPromptsTestHelper.GetDefaultCentreCustomPromptsResult(
                    customField1Prompt: "Custom Prompt",
                    customField1Options: null
                    )
            );

            // When
            var result =
                centreCustomPromptsService.GetCentreCustomPromptsWithAnswersByCentreIdAndDelegateUser(29, delegateUser);

            // Then
            result.Should().BeEquivalentTo(expectedCustomerPrompts);
        }
Esempio n. 24
0
        private (List <CustomPrompt> customPrompts, List <FilterViewModel> filters) GetSampleCustomPromptsAndFilters()
        {
            var customPrompt1 = CustomPromptsTestHelper.GetDefaultCustomPrompt(
                1,
                "First prompt",
                "Clinical\r\nNon-Clinical"
                );
            var customPrompt3 = CustomPromptsTestHelper.GetDefaultCustomPrompt(3);
            var customPrompt4 = CustomPromptsTestHelper.GetDefaultCustomPrompt(4, "Fourth prompt", "C 1\r\nC 2\r\nC 3");
            var customPrompts = new List <CustomPrompt> {
                customPrompt1, customPrompt3, customPrompt4
            };

            var customPrompt1Options = new[]
            {
                new FilterOptionViewModel(
                    "Clinical",
                    "Answer1" + FilteringHelper.Separator +
                    "Answer1" + FilteringHelper.Separator + "Clinical",
                    FilterStatus.Default
                    ),
                new FilterOptionViewModel(
                    "Non-Clinical",
                    "Answer1" + FilteringHelper.Separator +
                    "Answer1" + FilteringHelper.Separator + "Non-Clinical",
                    FilterStatus.Default
                    ),
                new FilterOptionViewModel(
                    "No option selected",
                    "Answer1" + FilteringHelper.Separator +
                    "Answer1" + FilteringHelper.Separator + FilteringHelper.EmptyValue,
                    FilterStatus.Default
                    )
            };
            var customPrompt4Options = new[]
            {
                new FilterOptionViewModel(
                    "C 1",
                    "Answer4" + FilteringHelper.Separator +
                    "Answer4" + FilteringHelper.Separator + "C 1",
                    FilterStatus.Default
                    ),
                new FilterOptionViewModel(
                    "C 2",
                    "Answer4" + FilteringHelper.Separator +
                    "Answer4" + FilteringHelper.Separator + "C 2",
                    FilterStatus.Default
                    ),
                new FilterOptionViewModel(
                    "C 3",
                    "Answer4" + FilteringHelper.Separator +
                    "Answer4" + FilteringHelper.Separator + "C 3",
                    FilterStatus.Default
                    ),
                new FilterOptionViewModel(
                    "No option selected",
                    "Answer4" + FilteringHelper.Separator +
                    "Answer4" + FilteringHelper.Separator + FilteringHelper.EmptyValue,
                    FilterStatus.Default
                    )
            };
            var customPromptFilters = new List <FilterViewModel>
            {
                new FilterViewModel("CustomPrompt1", "First prompt", customPrompt1Options),
                new FilterViewModel("CustomPrompt4", "Fourth prompt", customPrompt4Options)
            };

            return(customPrompts, customPromptFilters);
        }