public void Placeholders_are_replaced_with_applicaton_data(string textWithPlaceholders, string textWithReplacedPlaceholders, Dictionary <string, object> applicationData) { // Act var output = ApplicationDataFormatHelper.FormatApplicationDataPropertyPlaceholders(textWithPlaceholders, applicationData); // Assert output.Should().Be(textWithReplacedPlaceholders); }
public SectionViewModel(ApplicationResponse application, Organisation organisation, Section section, ApplySection applySection, Dictionary <string, object> applicationData, string backAction, string backController, string backOrganisationId) : base(backAction, backController, backOrganisationId) { ApplicationId = application.Id; ApplicationReference = application.ApplyData.Apply.ReferenceNumber; Grade = application.FinancialGrade; LegalName = organisation.OrganisationData.LegalName; TradingName = organisation.OrganisationData.TradingName; ProviderName = organisation.OrganisationData.ProviderName; Ukprn = organisation.EndPointAssessorUkprn; CompanyNumber = organisation.OrganisationData.CompanyNumber; Section = section; ApplySection = applySection; SequenceNo = section.SequenceNo; SectionNo = section.SectionNo; Title = section.Title; Status = section.Status; if (section.Status == ApplicationSectionStatus.Evaluated) { IsSectionComplete = true; } foreach (var pg in Section.QnAData.Pages) { foreach (var answerPage in pg.PageOfAnswers) { foreach (var answer in answerPage.Answers) { var question = pg.Questions.SingleOrDefault(q => q.QuestionId == answer.QuestionId); if (question != null && question.Input.Type == "Address") { Addresses.Add(answer.QuestionId, JsonConvert.DeserializeObject <AddressViewModel>(answer.Value)); } } } foreach (var question in pg.Questions) { question.Label = ApplicationDataFormatHelper.FormatApplicationDataPropertyPlaceholders(question.Label, applicationData); question.Hint = ApplicationDataFormatHelper.FormatApplicationDataPropertyPlaceholders(question.Hint, applicationData); question.QuestionBodyText = ApplicationDataFormatHelper.FormatApplicationDataPropertyPlaceholders(question.QuestionBodyText, applicationData); question.ShortLabel = ApplicationDataFormatHelper.FormatApplicationDataPropertyPlaceholders(question.ShortLabel, applicationData); } } }
private void ReplaceApplicationDataPropertyPlaceholdersInQuestions(List <QuestionViewModel> questions, Dictionary <string, object> applicationData) { if (questions == null) { return; } foreach (var question in questions) { question.Label = ApplicationDataFormatHelper.FormatApplicationDataPropertyPlaceholders(question.Label, applicationData); question.Hint = ApplicationDataFormatHelper.FormatApplicationDataPropertyPlaceholders(question.Hint, applicationData); question.QuestionBodyText = ApplicationDataFormatHelper.FormatApplicationDataPropertyPlaceholders(question.QuestionBodyText, applicationData); question.ShortLabel = ApplicationDataFormatHelper.FormatApplicationDataPropertyPlaceholders(question.ShortLabel, applicationData); } }