public virtual void DefaultMemoryHandler()
        {
            MemoryLimitsAwareHandler handler = new MemoryLimitsAwareHandler();

            NUnit.Framework.Assert.AreEqual(int.MaxValue / 100, handler.GetMaxSizeOfSingleDecompressedPdfStream());
            NUnit.Framework.Assert.AreEqual(int.MaxValue / 20, handler.GetMaxSizeOfDecompressedPdfStreamsSum());
        }
        public virtual void CustomMemoryHandler()
        {
            MemoryLimitsAwareHandler handler = new MemoryLimitsAwareHandler(1000000);

            NUnit.Framework.Assert.AreEqual(100000000, handler.GetMaxSizeOfSingleDecompressedPdfStream());
            NUnit.Framework.Assert.AreEqual(500000000, handler.GetMaxSizeOfDecompressedPdfStreamsSum());
        }
        private static void TestMultipleStreams(MemoryLimitsAwareHandler handler)
        {
            String expectedExceptionMessage = PdfException.DuringDecompressionMultipleStreamsInSumOccupiedMoreMemoryThanAllowed;
            int    expectedFailureIndex     = 10;
            String occuredExceptionMessage  = null;
            int    i = 0;

            try {
                long limit = handler.GetMaxSizeOfDecompressedPdfStreamsSum();
                long step  = limit / 10;
                for (i = 0; i < 11; i++)
                {
                    handler.BeginDecompressedPdfStreamProcessing();
                    handler.ConsiderBytesOccupiedByDecompressedPdfStream(step);
                    handler.EndDecompressedPdfStreamProcessing();
                }
            }
            catch (MemoryLimitsAwareException e) {
                occuredExceptionMessage = e.Message;
            }
            NUnit.Framework.Assert.AreEqual(expectedFailureIndex, i);
            NUnit.Framework.Assert.AreEqual(expectedExceptionMessage, occuredExceptionMessage);
        }