public void GetValueTest() { CommonPlaceholderHelper target = new CommonPlaceholderHelper(); // TODO: Initialize to an appropriate value string placeholder = string.Empty; // TODO: Initialize to an appropriate value string expected = string.Empty; // TODO: Initialize to an appropriate value string actual; actual = target.GetValue(placeholder); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public MemoryStream Process(ClassEnrollment enrollment, IEnumerable<StudentGrade> grades) { var gradeList = grades.ToList(); var placeholderHelper = new CommonPlaceholderHelper(); placeholderHelper.SetValues(enrollment.Student, enrollment.Class.Teacher); placeholderHelper.SetValues(Period, Period.ReportingPeriod, Period.School, Period.School.SchoolDistrict); //string filename = String.Format("{0}{2} {1}.pdf", @"d:\cards\", enrollment.Student.LastName, enrollment.Student.FirstName); //FileStream stream = new FileStream(filename, FileMode.Create); var stream = new MemoryStream(); var reader = new PdfReader(Template); var stamper = new PdfStamper(reader, stream); var form = stamper.AcroFields; var fieldKeys = form.Fields.Keys; foreach (var fieldKey in fieldKeys) { var match = KeyPattern.Match(fieldKey); if (match.Success) { var key = match.Groups["ph"].Value; var term = 1; var termGroup = match.Groups["term"]; if (termGroup.Success) { int.TryParse(termGroup.Value, out term); } var standard = Standards.FirstOrDefault(p => p.Placeholder == key); if (standard == null) { form.SetField(fieldKey, placeholderHelper.GetValue(fieldKey)); continue; } var gradingTerm = Terms.FirstOrDefault(p => p.TermNum == term); if (gradingTerm == null) { form.SetField(fieldKey, string.Empty); continue; } var grade = gradeList.FirstOrDefault(p => p.GradingStandard == standard && p.GradingTermID == gradingTerm.GradingTermID); if (grade == null) { form.SetField(fieldKey, string.Empty); continue; } form.SetField(fieldKey, grade.Grade); } else { form.SetField(fieldKey, string.Empty); } } // "Flatten" the form so it wont be editable/usable anymore stamper.FormFlattening = true; stamper.Close(); reader.Close(); return stream; }