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); }
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); } }
public void GetCentreCustomPromptsByCentreId_Returns_populated_CentreCustomPromptsResult() { // Given var expectedCentreCustomPromptsResult = CustomPromptsTestHelper.GetDefaultCentreCustomPromptsResult(); // When var returnedCentreCustomPromptsResult = centreCustomPromptsDataService.GetCentreCustomPromptsByCentreId(29); // Then returnedCentreCustomPromptsResult.Should().BeEquivalentTo(expectedCentreCustomPromptsResult); }
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"); } }
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); }