示例#1
0
        public void TestReadMultipleTreeLevels()
        {
            POIDataSamples _samples = POIDataSamples.GetPublisherInstance();
            FileStream     sample   = _samples.GetFile("Sample.pub");

            DocumentInputStream stream;

            NPOIFSFileSystem npoifs = new NPOIFSFileSystem(sample);

            try
            {
                sample = _samples.GetFile("Sample.pub");
                OPOIFSFileSystem opoifs = new OPOIFSFileSystem(sample);

                // Ensure we have what we expect on the root
                Assert.AreEqual(npoifs, npoifs.Root.NFileSystem);
                Assert.AreEqual(npoifs, npoifs.Root.FileSystem);
                Assert.AreEqual(null, npoifs.Root.OFileSystem);
                Assert.AreEqual(null, opoifs.Root.FileSystem);
                Assert.AreEqual(opoifs, opoifs.Root.OFileSystem);
                Assert.AreEqual(null, opoifs.Root.NFileSystem);

                // Check inside
                foreach (DirectoryNode root in new DirectoryNode[] { opoifs.Root, npoifs.Root })
                {
                    // Top Level
                    Entry top = root.GetEntry("Contents");
                    Assert.AreEqual(true, top.IsDocumentEntry);
                    stream = root.CreateDocumentInputStream(top);
                    stream.Read();

                    // One Level Down
                    DirectoryNode escher = (DirectoryNode)root.GetEntry("Escher");
                    Entry         one    = escher.GetEntry("EscherStm");
                    Assert.AreEqual(true, one.IsDocumentEntry);
                    stream = escher.CreateDocumentInputStream(one);
                    stream.Read();

                    // Two Levels Down
                    DirectoryNode quill    = (DirectoryNode)root.GetEntry("Quill");
                    DirectoryNode quillSub = (DirectoryNode)quill.GetEntry("QuillSub");
                    Entry         two      = quillSub.GetEntry("CONTENTS");
                    Assert.AreEqual(true, two.IsDocumentEntry);
                    stream = quillSub.CreateDocumentInputStream(two);
                    stream.Read();
                }
            }
            finally
            {
                npoifs.Close();
            }
        }