Example #1
0
 private void AssertOutputFile(string outputFilePath, FileAuthentication outputAuth, string expectedFilePath, int expectedNumberOfPages, string expectedText)
 {
     Assert.IsTrue(File.Exists(outputFilePath));
     Assert.AreEqual(expectedFilePath, outputFilePath);
     PdfComparer.AssertPageCount(outputFilePath, outputAuth, this.authenticationManager, expectedNumberOfPages);
     PdfComparer.AssertText(outputFilePath, outputAuth, this.authenticationManager, expectedText, null);
 }
        public void Concatenate()
        {
            string inputFilePath1 = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.PdfOperations.Resources.Concatenate1.pdf", this.inputDirectory);

            PdfComparer.AssertPageCount(inputFilePath1, FileAuthentication.None, this.authenticationManager, 1);
            PdfComparer.AssertText(inputFilePath1, FileAuthentication.None, this.authenticationManager, "1", "function Script1()\r\n{}\n");
            string inputFilePath2 = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.PdfOperations.Resources.Concatenate2.pdf", this.inputDirectory);

            PdfComparer.AssertPageCount(inputFilePath2, FileAuthentication.None, this.authenticationManager, 1);
            PdfComparer.AssertText(inputFilePath2, FileAuthentication.None, this.authenticationManager, "2", "function Script2()\r\n{}\n");
            string outputFilePath = Path.Combine(this.outputDirectory, "Concat.pdf");

            FunctionDesigner designer = ProviderHelpers.CreateDesigner <PdfOperationsProvider>();

            designer.Properties[PropertyNames.Operation].Value  = Operation.Concatenate;
            designer.Properties[PropertyNames.InputFiles].Value = new List <string> {
                inputFilePath1, inputFilePath2
            };
            designer.Properties[PropertyNames.InputAuthenticationType].Value = AuthenticationType.None;
            designer.Properties[PropertyNames.OutputFilePath].Value          = outputFilePath;

            var tester = new FunctionTester <PdfOperationsProvider>();

            tester.Execute(designer.GetProperties(), designer.GetParameters());

            Assert.IsTrue(File.Exists(outputFilePath));
            PdfComparer.AssertPageCount(outputFilePath, FileAuthentication.None, this.authenticationManager, 2);
            PdfComparer.AssertText(outputFilePath, FileAuthentication.None, this.authenticationManager, $"1{Environment.NewLine}2", "function Script1()\r\n{}\n\nfunction Script2()\r\n{}\n\n");
        }