Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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);
            }
        }