示例#1
0
        public void TestReadWrite()
        {
            TextPieceTable fakeTPT = new TextPieceTable();

            FileInformationBlock fib = _hWPFDocFixture._fib;

            byte[] mainStream  = _hWPFDocFixture._mainStream;
            byte[] tableStream = _hWPFDocFixture._tableStream;

            _pAPBinTable = new PAPBinTable(mainStream, tableStream, null, fib.GetFcPlcfbtePapx(), fib.GetLcbPlcfbtePapx(), fakeTPT);

            HWPFFileSystem fileSys = new HWPFFileSystem();

            _pAPBinTable.WriteTo(fileSys, fakeTPT);
            MemoryStream tableOut = fileSys.GetStream("1Table");
            MemoryStream mainOut  = fileSys.GetStream("WordDocument");

            byte[] newTableStream = tableOut.ToArray();
            byte[] newMainStream  = mainOut.ToArray();

            PAPBinTable newBinTable = new PAPBinTable(newMainStream, newTableStream, null, 0, newTableStream.Length, fakeTPT);

            List <PAPX> oldTextRuns = _pAPBinTable.GetParagraphs();
            List <PAPX> newTextRuns = newBinTable.GetParagraphs();

            Assert.AreEqual(oldTextRuns.Count, newTextRuns.Count);

            int size = oldTextRuns.Count;

            for (int x = 0; x < size; x++)
            {
                PropertyNode oldNode = (PropertyNode)oldTextRuns[x];
                PropertyNode newNode = (PropertyNode)newTextRuns[x];

                Assert.IsTrue(oldNode.Equals(newNode));
            }
        }