protected void assertContentsMatches(byte[] expected, DocumentEntry doc)
        {
            NDocumentInputStream inp = new NDocumentInputStream(doc);
            byte[] contents = new byte[doc.Size];
            Assert.AreEqual(doc.Size, inp.Read(contents));
            inp.Close();

            if (expected != null)
                Assert.That(expected, new EqualConstraint(contents));
        }
        public void TestGetDocumentEntry()
        {
            foreach (NPOIFSFileSystem fs in get512and4kFileAndInput())
            {
                DirectoryEntry root = fs.Root;
                Entry si = root.GetEntry("\x0005SummaryInformation");

                Assert.AreEqual(true, si.IsDocumentEntry);
                DocumentNode doc = (DocumentNode)si;

                // Check we can read it
                assertContentsMatches(null, doc);

                // Now try to build the property set
                //  ByteBuffer temp = inp.GetCurrentBuffer();
                DocumentInputStream inp = new NDocumentInputStream(doc);

                PropertySet ps = PropertySetFactory.Create(inp);
                SummaryInformation inf = (SummaryInformation)ps;

                // Check some bits in it
                Assert.AreEqual(null, inf.ApplicationName);
                Assert.AreEqual(null, inf.Author);
                Assert.AreEqual(null, inf.Subject);
                Assert.AreEqual(131333, inf.OSVersion);

                // Finish
                inp.Close();

                // Try the other summary information
                si = root.GetEntry("\u0005DocumentSummaryInformation");
                Assert.AreEqual(true, si.IsDocumentEntry);
                doc = (DocumentNode)si;
                assertContentsMatches(null, doc);

                inp = new NDocumentInputStream(doc);
                ps = PropertySetFactory.Create(inp);
                DocumentSummaryInformation dinf = (DocumentSummaryInformation)ps;
                Assert.AreEqual(131333, dinf.OSVersion);

                fs.Close();
            }
        }
        public void TestAvailable()
        {
            DocumentInputStream ostream = new DocumentInputStream(_workbook_o);
            DocumentInputStream nstream = new NDocumentInputStream(_workbook_n);

            Assert.AreEqual(_workbook_size, ostream.Available());
            Assert.AreEqual(_workbook_size, nstream.Available());
            ostream.Close();
            nstream.Close();

            try
            {
                ostream.Available();
                Assert.Fail("Should have caught IOException");
            }
            catch (InvalidOperationException)
            {
                // as expected
            }
            try
            {
                nstream.Available();
                Assert.Fail("Should have caught IOException");
            }
            catch (InvalidOperationException)
            {
                // as expected
            }
        }
        public void TestGetDocumentEntry()
        {

            NPOIFSFileSystem fsB = new NPOIFSFileSystem(_inst.GetFile("BlockSize512.zvi"));
            NPOIFSFileSystem fsA = new NPOIFSFileSystem(_inst.OpenResourceAsStream("BlockSize512.zvi"));
            NPOIFSFileSystem fsC = new NPOIFSFileSystem(_inst.GetFile("BlockSize4096.zvi"));
            NPOIFSFileSystem fsD = new NPOIFSFileSystem(_inst.OpenResourceAsStream("BlockSize4096.zvi"));

            
            foreach (NPOIFSFileSystem fs in new NPOIFSFileSystem[] { fsA, fsB, fsC, fsD })
            {
                DirectoryEntry root = fs.Root;
                Entry si = root.GetEntry("\x0005SummaryInformation");

                Assert.AreEqual(true, si.IsDocumentEntry);
                DocumentNode doc = (DocumentNode)si;

                // Check we can read it
                NDocumentInputStream inp = new NDocumentInputStream(doc);
                byte[] contents = new byte[doc.Size];
                Assert.AreEqual(doc.Size, inp.Read(contents));
                
                // Now try to build the property set
              //  ByteBuffer temp = inp.GetCurrentBuffer();
                inp = new NDocumentInputStream(doc);

                PropertySet ps = PropertySetFactory.Create(inp);
                SummaryInformation inf = (SummaryInformation)ps;

                // Check some bits in it
                Assert.AreEqual(null, inf.ApplicationName);
                Assert.AreEqual(null, inf.Author);
                Assert.AreEqual(null, inf.Subject);
            }
        }
        public void TestConstructor()
        {
            DocumentInputStream ostream = new DocumentInputStream(_workbook_o);
            DocumentInputStream nstream = new NDocumentInputStream(_workbook_n);

            Assert.AreEqual(_workbook_size, _workbook_o.Size);
            Assert.AreEqual(_workbook_size, _workbook_n.Size);
            Assert.AreEqual(_workbook_size, ostream.Available());
            Assert.AreEqual(_workbook_size, nstream.Available());
        }