Exemple #1
0
 private static DummyConsumer ReadDocument(string fileName)
 {
     Reader r = new Reader();
     r.Source = new DocumentSource();
     DummyConsumer consumer = new DummyConsumer();
     using (r.Source.Data = File.Open(TestFilePath + fileName, FileMode.Open))
     {
         r.Consumer = consumer;
         r.Execute();
     }
     return consumer;
 }
Exemple #2
0
        public void TestReadDocxHeaderFooters()
        {
            Reader r = new Reader();
            r.Source = new DocumentSource();
            DummyConsumer consumer = new DummyConsumer();
            using (r.Source.Data = File.Open(TestFilePath + "testheaders.docx", FileMode.Open))
            {
                r.Consumer = consumer;
                r.Execute();


            }


            Assert.AreEqual(16, consumer.Counts["HeaderFooter"]);

            bool bExpectStart = true;
            int iCount = 0;
            foreach (DocElement de in consumer.elements)
            {
                if (de is Section)
                {
                    Assert.IsTrue(de.IsStart, "Expect to get all the hdr/footer stuff done before the end of hte first section");
                }

                if (de is HeaderFooter)
                {
                    Assert.AreEqual(bExpectStart, de.IsStart);
                    bExpectStart = !bExpectStart;
                    iCount++;
                    if (iCount == 12)
                        break;

                }
            }
        }