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 WhenInvalidTemplateName_ShouldReturnZeroBytes() { // arrange var pdfUtil = new PdfTestUtils(); var templateName = "BootCampForm-DOESNOTEXIST-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 = 0; actual.Length.Should().Be(expectedLength); }