public QnaQuestionDetails GetQuestionDetailsForGatewayPageId(Guid applicationId, string gatewayPageId)
        {
            var questionConfig = _criminalComplianceQuestions.FirstOrDefault(q => q.GatewayPageId == gatewayPageId);

            if (questionConfig == null)
            {
                return(null);
            }

            var questionDetails = new QnaQuestionDetails
            {
                SectionId  = questionConfig.SectionId,
                PageId     = questionConfig.QnaPageId,
                QuestionId = questionConfig.QnaQuestionId
            };

            if (questionConfig.SectionId == RoatpWorkflowSectionIds.CriminalComplianceChecks.CheckOnWhosInControl)
            {
                var soleTraderAnswer = _apiClient.GetQuestionTag(applicationId, RoatpWorkflowQuestionTags.SoleTraderOrPartnership).GetAwaiter().GetResult();
                if (soleTraderAnswer == null || soleTraderAnswer != SoleTraderAnswer)
                {
                    return(questionDetails);
                }
                var overrideConfig = _soleTraderOverrides.FirstOrDefault(x => x.GatewayPageId == gatewayPageId);
                if (overrideConfig != null)
                {
                    questionDetails.SectionId  = overrideConfig.SectionId;
                    questionDetails.PageId     = overrideConfig.QnaPageId;
                    questionDetails.QuestionId = overrideConfig.QnaQuestionId;
                }
            }

            return(questionDetails);
        }
        public void Before_each_test()
        {
            _applicationId = Guid.NewGuid();
            _qnaApiClient  = new Mock <IInternalQnaApiClient>();
            _lookupService = new Mock <ICriminalComplianceChecksQuestionLookupService>();
            _controller    = new RoatpGatewayCriminalComplianceChecksController(_qnaApiClient.Object, _lookupService.Object);

            _gatewayPageId = "Page1";

            var pageDetails = new QnaQuestionDetails
            {
                PageId     = "1000",
                QuestionId = "CC-22",
                SectionId  = 3
            };

            _lookupService.Setup(x => x.GetQuestionDetailsForGatewayPageId(_applicationId, _gatewayPageId)).Returns(pageDetails);

            _qnaPageWithQuestion = new Page
            {
                PageId    = "1000",
                Questions = new List <Question>
                {
                    new Question
                    {
                        QuestionId = "CC-22",
                        Label      = "lorem ipsum",
                        Input      = new Input
                        {
                            Type    = "Radio",
                            Options = new List <Option>
                            {
                                new Option
                                {
                                    Value            = "Yes",
                                    FurtherQuestions = new List <Question>
                                    {
                                        new Question
                                        {
                                            QuestionId = "CC-22-1",
                                            Input      = new Input
                                            {
                                                Type = "Text"
                                            }
                                        }
                                    }
                                },
                                new Option
                                {
                                    Value = "No"
                                }
                            }
                        }
                    }
                },
                PageOfAnswers = new List <PageOfAnswers>
                {
                    new PageOfAnswers
                    {
                        Answers = new List <Answer>
                        {
                            new Answer
                            {
                                QuestionId = "CC-22",
                                Value      = "No"
                            }
                        }
                    }
                }
            };

            _qnaApiClient.Setup(x => x.GetPageBySectionNo(_applicationId, RoatpWorkflowSequenceIds.CriminalComplianceChecks,
                                                          pageDetails.SectionId, pageDetails.PageId))
            .ReturnsAsync(_qnaPageWithQuestion);
        }