public void WhenValidTemplateNameAndFieldsExist_ShouldReturnPopulatedPdfAsBytes() { // arrange var pdfUtil = new PdfTestUtils(); var templateName = "BootCampForm-v2.pdf"; var localPath = pdfUtil.CreateTemplatePath(templateName); var formFields = new List <SimplePdfFormField> { new SimplePdfFormField { Name = "FirstName", Value = "Travis" }, new SimplePdfFormField { Name = "Surname", Value = "Frisinger" }, new SimplePdfFormField { Name = "DateOfBirth", Value = "1981-04-29" }, }; var pdfService = new PdfRenderingRendering(); // act var actual = pdfService .WithTemplate(templateName, localPath) .WithFormData(formFields) .Populate(); // assert var expectedLength = pdfUtil.FetchExpectedFileLength("readonly.pdf"); actual.Length.Should().Be(expectedLength); }
public void WhenProtectingNonEmptyPassword_ShouldReturnPasswordProtectedPdf() { // arrange var pdfUtil = new PdfTestUtils(); var templateName = "BootCampForm-v2.pdf"; var localPath = pdfUtil.CreateTemplatePath(templateName); var formFields = new List <SimplePdfFormField> { new SimplePdfFormField { Name = "FirstName", Value = "Travis" }, new SimplePdfFormField { Name = "Surname", Value = "Frisinger" }, new SimplePdfFormField { Name = "DateOfBirth", Value = "1981-04-29" }, }; var pdfService = new PdfRenderingRendering(); // act var actual = pdfService .WithTemplate(templateName, localPath) .WithFormData(formFields) .WithPassword("1234") .Populate(); // assert var unsignedBytesLength = pdfUtil.FetchExpectedFileLength("readonly.pdf"); actual.Length.Should().NotBe(unsignedBytesLength); }
public void WhenValidFormInformation_ShouldReturnBytesOfModifedPdf() { // arrange var pdfUtils = new PdfTestUtils(); var fileName = "BootCampForm-v2.pdf"; pdfUtils.UploadTemplateToCloud(fileName); var pdfManipuation = new PdfManipuation(); var fields = new List <SimplePdfFormField> { new SimplePdfFormField { Name = "FirstName", Value = "Travis" }, new SimplePdfFormField { Name = "Surname", Value = "Frisinger" }, new SimplePdfFormField { Name = "DateOfBirth", Value = "1981-04-29" }, }; var cloudStorageName = pdfManipuation.PopulateTemplate(fileName, fields); // act var actual = pdfManipuation.MarkFieldsAsReadOnly(cloudStorageName, fields); // assert var expectedLength = pdfUtils.FetchExpectedFileLength("readonly.pdf"); actual.Length.Should().Be(expectedLength); }