private void AddSectionInformation(QuestionAnswerListViewModel questionAnswers) { if (questionAnswers.Items != null) { foreach (var questionAnswer in questionAnswers.Items) { if (_currentStage != questionAnswer.StageDescription) { _currentStage = questionAnswer.StageDescription; _pdfHelper.AddLine(false); _pdfHelper.AddTitle(_currentStage, false); _pdfHelper.AddLine(); } _pdfHelper.AddLine(false); _pdfHelper.AddTitle(questionAnswer.Question); _pdfHelper.AddLine(); if (string.IsNullOrEmpty(questionAnswer.Answer)) { _pdfHelper.WriteText(questionAnswer.FurtherInformation); } else { var questionAnswerText = questionAnswer.Answer; if (!string.IsNullOrWhiteSpace(questionAnswer.FurtherInformation)) { questionAnswerText += ". " + questionAnswer.FurtherInformation; } _pdfHelper.WriteText(questionAnswerText); } } } }
public void CreatePdfForAssessment_CalledWithValidAssessmentAndEmptyDecisionMaker_ShouldCreatePdfContainingCommonInformation() { PdfDocument pdfDocumentCreated; var assessment = new Assessment() { AssessmentId = Guid.NewGuid(), Stage1DecisionToBeMade = "Decision", Patient = new Patient() { FirstName = "First name", LastName = "Last name", DateOfBirth = new DateTime(1956, 1, 02), NhsNumber = 4010232137, ClinicalSystemId = "1234567890" }, AssessorName = "assessor", Role = new Role { RoleId = (int)RoleIdEnum.Assessor, Description = "A random role" }, DateAssessmentStarted = _dateTimeProvider.Now, }; _pdfGenerator.CreatePdfForAssessment(assessment, out pdfDocumentCreated); A.CallTo(() => _pdfHelper.AddTitle(ApplicationStringConstants.McaSubject, false, true)).MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => _pdfHelper.AddTitle(ApplicationStringConstants.Name, true, false)).MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => _pdfHelper.AppendText(" " + assessment.Patient.FirstName + " " + assessment.Patient.LastName)).MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => _pdfHelper.AddTitle(ApplicationStringConstants.Dob, true, false)).MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => _pdfHelper.AppendText(" " + assessment.Patient.DateOfBirth.ToLongDateString())).MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => _pdfHelper.AddTitle(ApplicationStringConstants.NhsNumber, true, false)).MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => _pdfHelper.AppendText(" " + assessment.Patient.NhsNumber)).MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => _pdfHelper.AddTitle(ApplicationStringConstants.AssessmentStartDateText, true, false)).MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => _pdfHelper.AddTitle(ApplicationStringConstants.ClinicianNameText, true, false)).MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => _pdfHelper.AddTitle(ApplicationStringConstants.Stage1Text, false, false)).MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => _pdfHelper.AddTitle(ApplicationStringConstants.DecisionToBeMade, false, false)).MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => _pdfHelper.WriteText(assessment.Stage1DecisionToBeMade)).MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => _pdfHelper.AddTitle(ApplicationStringConstants.RoleText, true, false)).MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => _pdfHelper.AppendText(" " + assessment.Role.Description)).MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => _pdfHelper.AddTitle(ApplicationStringConstants.DecisionMakerText, true, false)).MustNotHaveHappened(); }