public void GetCentreRegistrationPromptsThatHaveOptionsByCentreId_only_returns_prompts_with_options()
        {
            // Given
            const int centreId       = 29;
            var       expectedPrompt = PromptsTestHelper.GetDefaultCentreRegistrationPrompt(
                1,
                "Group",
                "Clinical\r\nNon-Clinical",
                true,
                promptId: 3
                );
            var expectedPrompts = new List <CentreRegistrationPrompt> {
                expectedPrompt
            };

            A.CallTo(() => centreRegistrationPromptsDataService.GetCentreRegistrationPromptsByCentreId(centreId))
            .Returns(PromptsTestHelper.GetDefaultCentreRegistrationPromptsResult());

            // When
            var result = centreRegistrationPromptsService.GetCentreRegistrationPromptsThatHaveOptionsByCentreId(centreId);

            // Then
            using (new AssertionScope())
            {
                A.CallTo(() => centreRegistrationPromptsDataService.GetCentreRegistrationPromptsByCentreId(centreId))
                .MustHaveHappenedOnceExactly();
                result.Should().BeEquivalentTo(expectedPrompts);
            }
        }
        public void GetCentreRegistrationPromptsByCentreId_Returns_Populated_CentreRegistrationPrompts()
        {
            // Given
            var expectedPrompt1           = PromptsTestHelper.GetDefaultCentreRegistrationPrompt(1, options: null, mandatory: true, promptId: 3);
            var expectedPrompt2           = PromptsTestHelper.GetDefaultCentreRegistrationPrompt(2, "Department / team", null, true);
            var centreRegistrationPrompts = new List <CentreRegistrationPrompt> {
                expectedPrompt1, expectedPrompt2
            };
            var expectedPrompts = PromptsTestHelper.GetDefaultCentreRegistrationPrompts(centreRegistrationPrompts);

            A.CallTo(() => centreRegistrationPromptsDataService.GetCentreRegistrationPromptsByCentreId(29))
            .Returns
            (
                PromptsTestHelper.GetDefaultCentreRegistrationPromptsResult(
                    centreRegistrationPrompt1Prompt: "Custom Prompt",
                    centreRegistrationPrompt1Options: null
                    )
            );

            // When
            var result = centreRegistrationPromptsService.GetCentreRegistrationPromptsByCentreId(29);

            // Then
            result.Should().BeEquivalentTo(expectedPrompts);
        }
        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 GetCentreRegistrationPromptsByCentreId_Returns_populated_CentreRegistrationPromptsResult()
        {
            // Given
            var expectedCentreRegistrationPromptsResult = PromptsTestHelper.GetDefaultCentreRegistrationPromptsResult();

            // When
            var returnedCentreRegistrationPromptsResult = centreRegistrationPromptsDataService.GetCentreRegistrationPromptsByCentreId(29);

            // Then
            returnedCentreRegistrationPromptsResult.Should().BeEquivalentTo(expectedCentreRegistrationPromptsResult);
        }
        public void GetCentreRegistrationPromptsByCentreId_with_options_splits_correctly()
        {
            // Given
            A.CallTo(() => centreRegistrationPromptsDataService.GetCentreRegistrationPromptsByCentreId(29))
            .Returns(PromptsTestHelper.GetDefaultCentreRegistrationPromptsResult());

            // When
            var result = centreRegistrationPromptsService.GetCentreRegistrationPromptsByCentreId(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 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);
        }