public virtual void PageSumTest() { MemoryLimitsAwareHandler handler = new MemoryLimitsAwareHandler(); handler.SetMaxSizeOfDecompressedPdfStreamsSum(1500000); NUnit.Framework.Assert.That(() => { using (PdfDocument pdfDocument = new PdfDocument(new PdfReader(sourceFolder + "timing.pdf", new ReaderProperties ().SetMemoryLimitsAwareHandler(handler)), new PdfWriter(new MemoryStream()))) { pdfDocument.GetFirstPage().GetContentBytes(); } } , NUnit.Framework.Throws.InstanceOf <MemoryLimitsAwareException>().With.Message.EqualTo(PdfException.DuringDecompressionMultipleStreamsInSumOccupiedMoreMemoryThanAllowed)) ; }
public virtual void PageSumTest() { MemoryLimitsAwareHandler handler = new MemoryLimitsAwareHandler(); handler.SetMaxSizeOfDecompressedPdfStreamsSum(1500000); PdfDocument pdfDocument = new PdfDocument(new PdfReader(sourceFolder + "timing.pdf", new ReaderProperties( ).SetMemoryLimitsAwareHandler(handler)), new PdfWriter(new MemoryStream())); String expectedExceptionMessage = PdfException.DuringDecompressionMultipleStreamsInSumOccupiedMoreMemoryThanAllowed; String thrownExceptionMessage = null; try { pdfDocument.GetFirstPage().GetContentBytes(); } catch (MemoryLimitsAwareException e) { thrownExceptionMessage = e.Message; } NUnit.Framework.Assert.AreEqual(expectedExceptionMessage, thrownExceptionMessage); }