Пример #1
0
        public void TestSearchTextNotFound()
        {
            XWPFDocument  doc = new XWPFDocument();
            XWPFParagraph p   = doc.CreateParagraph();

            Assert.IsNull(p.SearchText("test", new PositionInParagraph()));
            Assert.AreEqual("", p.Text);
        }
Пример #2
0
        public void TestSearchTextFound()
        {
            XWPFDocument xml = XWPFTestDataSamples.OpenSampleDocument("ThreeColHead.docx");

            IList <XWPFParagraph> ps = xml.Paragraphs;

            Assert.AreEqual(10, ps.Count);

            XWPFParagraph p = ps[(0)];

            TextSegement segment = p.SearchText("sample word document", new PositionInParagraph());

            Assert.IsNotNull(segment);

            Assert.AreEqual("sample word document", p.GetText(segment));

            Assert.IsTrue(p.RemoveRun(0));
        }