public void TestReadWrite() { FileInformationBlock fib = _hWPFDocFixture._fib; byte[] mainStream = _hWPFDocFixture._mainStream; byte[] tableStream = _hWPFDocFixture._tableStream; int fcMin = fib.GetFcMin(); _cHPBinTable = new CHPBinTable(mainStream, tableStream, fib.GetFcPlcfbteChpx(), fib.GetLcbPlcfbteChpx(), fcMin, fakeTPT); HWPFFileSystem fileSys = new HWPFFileSystem(); _cHPBinTable.WriteTo(fileSys, 0); MemoryStream tableOut = fileSys.GetStream("1Table"); MemoryStream mainOut = fileSys.GetStream("WordDocument"); byte[] newTableStream = tableOut.ToArray(); byte[] newMainStream = mainOut.ToArray(); CHPBinTable newBinTable = new CHPBinTable(newMainStream, newTableStream, 0, newTableStream.Length, 0, fakeTPT); List <CHPX> oldTextRuns = _cHPBinTable._textRuns; List <CHPX> newTextRuns = newBinTable._textRuns; 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)); } }
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)); } }