Esempio n. 1
0
        public void TestContents()
        {
            HWPFDocument doc = docAscii;

            for (int run = 0; run < 3; run++)
            {
                Range r;

                // Now check the real ranges
                r = doc.GetRange();
                Assert.AreEqual(
                    a_page_1 +
                    page_break + "\r" +
                    a_page_2,
                    r.Text
                    );

                r = doc.GetHeaderStoryRange();
                Assert.AreEqual(
                    headerDef +
                    a_header +
                    footerDef +
                    a_footer +
                    endHeaderFooter,
                    r.Text
                    );

                r = doc.GetOverallRange();
                Assert.AreEqual(
                    a_page_1 +
                    page_break + "\r" +
                    a_page_2 +
                    headerDef +
                    a_header +
                    footerDef +
                    a_footer +
                    endHeaderFooter +
                    "\r",
                    r.Text
                    );

                // Write out and read back in again, Ready for
                //  the next run of the Test
                // TODO run more than once
                if (run < 1)
                {
                    doc = HWPFTestDataSamples.WriteOutAndReadBack(doc);
                }
            }
        }
Esempio n. 2
0
        /**
         * Pending the missing files being uploaded to
         *  bug #44937
         */
        //[TestMethod]
        public void BROKENtestEscherDrawing()
        {
            HWPFDocument   docD        = HWPFTestDataSamples.OpenSampleFile(docDFile);
            List <Picture> allPictures = docD.GetPicturesTable().GetAllPictures();

            Assert.AreEqual(1, allPictures.Count);

            Picture pic = allPictures[0];

            Assert.IsNotNull(pic);
            byte[] picD = ReadFile(imgDFile);

            Assert.AreEqual(picD.Length, pic.GetContent().Length);

            assertBytesSame(picD, pic.GetContent());
        }
Esempio n. 3
0
        public void TestBasicsUnicode()
        {
            HWPFDocument doc = docUnicode;

            for (int run = 0; run < 3; run++)
            {
                // First check the start and end bits
                Assert.AreEqual(
                    0,
                    doc._cpSplit.GetMainDocumentStart()
                    );
                Assert.AreEqual(
                    u_page_1.Length +
                    2 +     // page break
                    u_page_2.Length,
                    doc._cpSplit.GetMainDocumentEnd()
                    );

                Assert.AreEqual(
                    408,
                    doc._cpSplit.GetFootnoteStart()
                    );
                Assert.AreEqual(
                    408,
                    doc._cpSplit.GetFootnoteEnd()
                    );

                Assert.AreEqual(
                    408,
                    doc._cpSplit.GetHeaderStoryStart()
                    );
                // TODO - fix this one
                Assert.AreEqual(
                    408 + headerDef.Length + u_header.Length +
                    footerDef.Length + u_footer.Length + endHeaderFooter.Length,
                    doc._cpSplit.GetHeaderStoryEnd()
                    );

                // Write out and read back in again, Ready for
                //  the next run of the Test
                // TODO run more than once
                if (run < 1)
                {
                    doc = HWPFTestDataSamples.WriteOutAndReadBack(doc);
                }
            }
        }
Esempio n. 4
0
        public void TestImageCount()
        {
            HWPFDocument docA = HWPFTestDataSamples.OpenSampleFile(docAFile);
            HWPFDocument docB = HWPFTestDataSamples.OpenSampleFile(docBFile);

            Assert.IsNotNull(docA.GetPicturesTable());
            Assert.IsNotNull(docB.GetPicturesTable());

            PicturesTable picA = docA.GetPicturesTable();
            PicturesTable picB = docB.GetPicturesTable();

            List <Picture> picturesA = picA.GetAllPictures();
            List <Picture> picturesB = picB.GetAllPictures();

            Assert.AreEqual(7, picturesA.Count);
            Assert.AreEqual(2, picturesB.Count);
        }
Esempio n. 5
0
        public void TestCompressedImageData()
        {
            HWPFDocument   docC      = HWPFTestDataSamples.OpenSampleFile(docCFile);
            PicturesTable  picC      = docC.GetPicturesTable();
            List <Picture> picturesC = picC.GetAllPictures();

            Assert.AreEqual(1, picturesC.Count);

            Picture pic = picturesC[0];

            Assert.IsNotNull(pic);

            // Check the same
            byte[] picBytes = ReadFile(imgCFile);

            Assert.AreEqual(picBytes.Length, pic.GetContent().Length);
            assertBytesSame(picBytes, pic.GetContent());
        }
Esempio n. 6
0
        public void TestImageData()
        {
            HWPFDocument   docB      = HWPFTestDataSamples.OpenSampleFile(docBFile);
            PicturesTable  picB      = docB.GetPicturesTable();
            List <Picture> picturesB = picB.GetAllPictures();

            Assert.AreEqual(2, picturesB.Count);

            Picture pic1 = picturesB[0];
            Picture pic2 = picturesB[1];

            Assert.IsNotNull(pic1);
            Assert.IsNotNull(pic2);

            // Check the same
            byte[] pic1B = ReadFile(imgAFile);
            byte[] pic2B = ReadFile(imgBFile);

            Assert.AreEqual(pic1B.Length, pic1.GetContent().Length);
            Assert.AreEqual(pic2B.Length, pic2.GetContent().Length);

            assertBytesSame(pic1B, pic1.GetContent());
            assertBytesSame(pic2B, pic2.GetContent());
        }
Esempio n. 7
0
 public void TestOpen()
 {
     HWPFTestDataSamples.OpenSampleFile(docAFile);
     HWPFTestDataSamples.OpenSampleFile(docBFile);
 }
Esempio n. 8
0
 public void SetUp()
 {
     docUnicode = HWPFTestDataSamples.OpenSampleFile("HeaderFooterUnicode.doc");
     docAscii   = HWPFTestDataSamples.OpenSampleFile("ThreeColHeadFoot.doc");
 }