public void TestReadWrite() { // This document is widely available on the internet as "blair.doc". // I tried stripping the content and saving the document but my version // of Word (from Office XP) strips this table out. HWPFDocument doc = HWPFTestDataSamples.OpenSampleFile("saved-by-table.doc"); // Check what we just Read. for(int i=0;i<expected.Count;i++) { Assert.AreEqual(expected[i],doc.GetSavedByTable().GetEntries()[i], "List of saved-by entries was not as expected"); } // Now write the entire document out, and read it back in... MemoryStream byteStream = new MemoryStream(); doc.Write(byteStream); Stream copyStream = new MemoryStream(byteStream.ToArray()); HWPFDocument copy = new HWPFDocument(copyStream); // And check again. for (int i = 0; i < expected.Count; i++) { Assert.AreEqual( expected[i], copy.GetSavedByTable().GetEntries()[i], "List of saved-by entries was incorrect after writing"); } }
public void TestReadWrite() { // This document is widely available on the internet as "blair.doc". // I tried stripping the content and saving the document but my version // of Word (from Office XP) strips this table out. HWPFDocument doc = HWPFTestDataSamples.OpenSampleFile("saved-by-table.doc"); // Check what we just Read. for (int i = 0; i < expected.Count; i++) { Assert.AreEqual(expected[i], doc.GetSavedByTable().GetEntries()[i], "List of saved-by entries was not as expected"); } // Now write the entire document out, and read it back in... MemoryStream byteStream = new MemoryStream(); doc.Write(byteStream); Stream copyStream = new MemoryStream(byteStream.ToArray()); HWPFDocument copy = new HWPFDocument(copyStream); // And check again. for (int i = 0; i < expected.Count; i++) { Assert.AreEqual( expected[i], copy.GetSavedByTable().GetEntries()[i], "List of saved-by entries was incorrect after writing"); } }