private static AssessorQuestion ToAssessorQuestion(this Question qnaQuestion, IAssessorLookupService assessorLookupService) { var question = new AssessorQuestion { QuestionId = qnaQuestion.QuestionId, Label = assessorLookupService?.GetLabelForQuestion(qnaQuestion.QuestionId) ?? qnaQuestion.Label, QuestionBodyText = qnaQuestion.QuestionBodyText, InputType = qnaQuestion.Input?.Type, InputPrefix = qnaQuestion.Input?.InputPrefix, InputSuffix = qnaQuestion.Input?.InputSuffix }; if (qnaQuestion.Input?.Options != null && qnaQuestion.Input.Options.Any()) { question.Options = new List <AssessorOption>(qnaQuestion.Input.Options.Select(opt => { return(opt.ToAssessorOption(assessorLookupService)); })); } return(question); }
public void ExtractFurtherQuestainsValueFromListOfAnswersWithMatchingPageIdWithFurtherQuestion() { var furtherQuestionId = "123"; _assessorPage.Answers = new List <AssessorAnswer> { new AssessorAnswer { QuestionId = _questionId, Value = furtherQuestionId }, new AssessorAnswer { QuestionId = $"{_questionId}x", Value = "other value" }, new AssessorAnswer { QuestionId = furtherQuestionId, Value = _value }, }; var question = new AssessorQuestion { QuestionId = _questionId, Options = new List <AssessorOption> { new AssessorOption { Value = furtherQuestionId, FurtherQuestions = new List <AssessorQuestion> { new AssessorQuestion { QuestionId = furtherQuestionId } } } } }; _assessorPage.Questions = new List <AssessorQuestion> { question }; var result = _extractService.ExtractFurtherQuestionAnswerValueFromQuestionId(_assessorPage, _questionId); Assert.AreEqual(_value, result); }