public void MyAccountViewModel_CustomFields_ShouldBePopulated() { // Given var delegateUser = UserTestHelper.GetDefaultDelegateUser(); var customPrompts = PromptsTestHelper.GetDefaultCentreRegistrationPromptsWithAnswers( new List <CentreRegistrationPromptWithAnswer> { PromptsTestHelper.GetDefaultCentreRegistrationPromptWithAnswer(1), PromptsTestHelper.GetDefaultCentreRegistrationPromptWithAnswer(2), } ); // When var returnedModel = new MyAccountViewModel(null, delegateUser, customPrompts, DlsSubApplication.Default); // Then using (new AssertionScope()) { returnedModel.DelegateRegistrationPrompts.Should().NotBeNullOrEmpty(); returnedModel.DelegateRegistrationPrompts[0].PromptNumber.Should().Be(1); returnedModel.DelegateRegistrationPrompts[0].Prompt.Should() .BeEquivalentTo(customPrompts.CustomPrompts[0].PromptText); returnedModel.DelegateRegistrationPrompts[0].Answer.Should().BeEquivalentTo(delegateUser.Answer1); returnedModel.DelegateRegistrationPrompts[0].Mandatory.Should().BeFalse(); returnedModel.DelegateRegistrationPrompts[1].PromptNumber.Should().Be(2); returnedModel.DelegateRegistrationPrompts[1].Prompt.Should() .BeEquivalentTo(customPrompts.CustomPrompts[1].PromptText); returnedModel.DelegateRegistrationPrompts[1].Answer.Should().BeEquivalentTo(delegateUser.Answer1); returnedModel.DelegateRegistrationPrompts[1].Mandatory.Should().BeFalse(); } }
public void MyAccountViewModel_DelegateUser_no_AdminUser_populates_expected_values() { // Given var delegateUser = UserTestHelper.GetDefaultDelegateUser(); var customPrompts = PromptsTestHelper.GetDefaultCentreRegistrationPromptsWithAnswers( new List <CentreRegistrationPromptWithAnswer> { PromptsTestHelper.GetDefaultCentreRegistrationPromptWithAnswer(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.DelegateRegistrationPrompts.Should().NotBeNullOrEmpty(); } }
GetUnapprovedDelegatesWithRegistrationPromptAnswersForCentre_returns_unapproved_delegates_with_registration_prompt_answers_for_centre() { // Given var expectedDelegateUser = UserTestHelper.GetDefaultDelegateUser(); var expectedUserList = new List <DelegateUser> { expectedDelegateUser }; var expectedRegistrationPrompts = new List <CentreRegistrationPromptWithAnswer> { PromptsTestHelper.GetDefaultCentreRegistrationPromptWithAnswer( 1, options: null, mandatory: true, answer: "answer" ) }; A.CallTo(() => userDataService.GetUnapprovedDelegateUsersByCentreId(2)) .Returns(expectedUserList); A.CallTo( () => centreRegistrationPromptsService.GetCentreRegistrationPromptsWithAnswersByCentreIdForDelegateUsers( 2, expectedUserList ) ) .Returns( new List <(DelegateUser delegateUser, List <CentreRegistrationPromptWithAnswer> prompts)> { (expectedDelegateUser, expectedRegistrationPrompts) }
public void UnapprovedDelegate_delegateUser_and_customPrompts_populate_expected_values() { // Given var delegateUser = UserTestHelper.GetDefaultDelegateUser(); var customPrompts = new List <CentreRegistrationPromptWithAnswer> { PromptsTestHelper.GetDefaultCentreRegistrationPromptWithAnswer(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.TitleName.Should().Be( $"{delegateUser.FirstName} {delegateUser.LastName}" ); returnedModel.Email.Should().Be(delegateUser.EmailAddress); returnedModel.DateRegistered.Should().Be(delegateUser.DateRegistered); returnedModel.JobGroup.Should().Be(delegateUser.JobGroupName); returnedModel.DelegateRegistrationPrompts.Should().NotBeNullOrEmpty(); var promptModel = returnedModel.DelegateRegistrationPrompts.First(); var promptData = customPrompts.First(); promptModel.Answer.Should().Be(promptData.Answer); promptModel.Prompt.Should().Be(promptData.PromptText); promptModel.PromptNumber.Should().Be(promptData.RegistrationField.Id); promptModel.Mandatory.Should().Be(promptData.Mandatory); } }
public void GetCentreRegistrationPromptsWithAnswersByCentreIdForDelegateUsers_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 = PromptsTestHelper.GetDefaultCentreRegistrationPromptWithAnswer( 1, options: null, mandatory: true, answer: answer1, promptId: 3 ); var expectedPrompt2 = PromptsTestHelper.GetDefaultCentreRegistrationPromptWithAnswer(2, "Department / team", null, true); var expectedPrompt3 = PromptsTestHelper.GetDefaultCentreRegistrationPromptWithAnswer( 1, options: null, mandatory: true, answer: answer2, promptId: 3 ); A.CallTo(() => centreRegistrationPromptsDataService.GetCentreRegistrationPromptsByCentreId(29)) .Returns( PromptsTestHelper.GetDefaultCentreRegistrationPromptsResult( centreRegistrationPrompt1Prompt: "Custom Prompt", centreRegistrationPrompt1Options: null ) ); // When var result = centreRegistrationPromptsService.GetCentreRegistrationPromptsWithAnswersByCentreIdForDelegateUsers( 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); } }
public void GetCentreRegistrationPromptsWithAnswersByCentreIdAndDelegateUser_Returns_Populated_CentreRegistrationPrompts() { // Given var answer1 = "Answer 1"; var delegateUser = UserTestHelper.GetDefaultDelegateUser(answer1: answer1); var expectedPrompt1 = PromptsTestHelper.GetDefaultCentreRegistrationPromptWithAnswer( 1, options: null, mandatory: true, answer: answer1, promptId: 3 ); var expectedPrompt2 = PromptsTestHelper.GetDefaultCentreRegistrationPromptWithAnswer(2, "Department / team", null, true); var centreRegistrationPrompts = new List <CentreRegistrationPromptWithAnswer> { expectedPrompt1, expectedPrompt2 }; var expectedCustomerPrompts = PromptsTestHelper.GetDefaultCentreRegistrationPromptsWithAnswers(centreRegistrationPrompts); A.CallTo(() => centreRegistrationPromptsDataService.GetCentreRegistrationPromptsByCentreId(29)) .Returns ( PromptsTestHelper.GetDefaultCentreRegistrationPromptsResult( centreRegistrationPrompt1Prompt: "Custom Prompt", centreRegistrationPrompt1Options: null ) ); // When var result = centreRegistrationPromptsService.GetCentreRegistrationPromptsWithAnswersByCentreIdAndDelegateUser(29, delegateUser); // Then result.Should().BeEquivalentTo(expectedCustomerPrompts); }
public void MyAccountViewModel_with_prn_displays_prn() { // Given var delegateUser = UserTestHelper.GetDefaultDelegateUser( hasBeenPromptedForPrn: true, professionalRegistrationNumber: "12345678" ); var customPrompts = PromptsTestHelper.GetDefaultCentreRegistrationPromptsWithAnswers( new List <CentreRegistrationPromptWithAnswer> { PromptsTestHelper.GetDefaultCentreRegistrationPromptWithAnswer(1), PromptsTestHelper.GetDefaultCentreRegistrationPromptWithAnswer(2), } ); // When var returnedModel = new MyAccountViewModel(null, delegateUser, customPrompts, DlsSubApplication.Default); // Then using (new AssertionScope()) { returnedModel.ProfessionalRegistrationNumber.Should().Be(delegateUser.ProfessionalRegistrationNumber); } }