Example #1
0
        public void Dispose_Test()
        {
            IStreamFilter[]   filters = _usefilters;
            PDFIndirectObject indobj  = new PDFIndirectObject(this);
            StreamProxy       proxy   = new StreamProxy(filters, indobj);
            PDFStream         target  = proxy;

            target.Dispose();
            //As the target owns the inner stream it should be disposed.
            Assert.IsNull(proxy.InnerStreamProxy());

            MemoryStream ms         = new MemoryStream();
            bool         ownsStream = false;

            proxy  = new StreamProxy(ms, filters, indobj, ownsStream);
            target = proxy;

            target.Dispose();
            Assert.IsNull(proxy.InnerStreamProxy()); //reference should have gone from the stream

            ms.WriteByte(12);                        //this will fail if the stream has been disposed.

            ms.Dispose();
            indobj.Dispose();
        }
Example #2
0
        public void PDFStreamConstructor_Test1()
        {
            IStreamFilter[]   filters = _usefilters;
            PDFIndirectObject indobj  = new PDFIndirectObject(this);
            PDFStream         target  = new StreamProxy(filters, indobj);

            Assert.IsNotNull(target);

            StreamProxy proxy = (StreamProxy)target;

            Assert.IsNotNull(proxy.InnerStreamProxy());
            Assert.IsTrue(proxy.OwnsStreamProxy());

            target.Dispose();
            indobj.Dispose();
        }