Пример #1
0
        public static async Task ShouldThrowExplainableExceptionOnTooLongCommandLineOnWindows()
        {
            var expectedLocalizedMessage = "The command line is too long.";

            if (Thread.CurrentThread.CurrentUICulture.Name.StartsWith("de"))
            {
                expectedLocalizedMessage = "Die Befehlszeile ist zu lang.";
            }

            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                return;
            }

            using var pdfAValidator = new PdfAValidator();
            var tooLongFileList        = new List <string>();
            var path                   = Path.GetFullPath("./TestPdfFiles/FromLibreOffice.pdf");
            var necessaryNumberOfFiles = 10000 / path.Length;

            for (var i = 1; i <= necessaryNumberOfFiles; i++)
            {
                tooLongFileList.Add(path);
            }

            var actualException = await Assert.ThrowsAsync <VeraPdfException>(() => pdfAValidator.ValidateBatchWithDetailedReportAsync(tooLongFileList, string.Empty));

            Assert.Contains("Calling VeraPdf exited with 1 without any output.", actualException.Message);
            Assert.Contains(expectedLocalizedMessage, actualException.Message);
        }
Пример #2
0
        public static async Task ShouldBatchValidatePdfsWithoutThrowingException()
        {
            using var pdfAValidator = new PdfAValidator();
            var files = new[]
            {
                "./TestPdfFiles/FromLibreOffice.pdf",
                "./TestPdfFiles/FromLibreOfficeNonPdfA.pdf"
            };

            Assert.True(files.All(f => File.Exists(f)));
            var result = await pdfAValidator.ValidateBatchWithDetailedReportAsync(files, "");

            Assert.Equal("2", result.BatchSummary.TotalJobs);
            Assert.Equal(2, result.Jobs.AllJobs.Count);
            Assert.Equal("1", result.BatchSummary.ValidationReports.Compliant);
            Assert.Equal("1", result.BatchSummary.ValidationReports.NonCompliant);
            var fromLibreOfficeJob = result.Jobs.AllJobs[0];

            Assert.True(fromLibreOfficeJob.ValidationReport.IsCompliant);
            var nonPdfAJob = result.Jobs.AllJobs[1];

            Assert.False(nonPdfAJob.ValidationReport.IsCompliant);
        }