public void TestAddParagraphsToFootnote() { // Add a run to the first paragraph: XWPFParagraph p1 = footnote.CreateParagraph(); p1.CreateRun().SetText(p1Text); // Create a second paragraph: XWPFParagraph p = footnote.CreateParagraph(); Assert.IsNotNull(p, "Paragraph is null"); p.CreateRun().SetText(p2Text); XWPFDocument docIn = XWPFTestDataSamples.WriteOutAndReadBack(docOut); XWPFFootnote testFootnote = docIn.GetFootnoteByID(footnoteId); Assert.IsNotNull(testFootnote); Assert.AreEqual(2, testFootnote.GetParagraphs().Count); XWPFParagraph testP1 = testFootnote.GetParagraphs()[0]; Assert.AreEqual(p1Text, testP1.Text); XWPFParagraph testP2 = testFootnote.GetParagraphs()[1]; Assert.AreEqual(p2Text, testP2.Text); // The first paragraph added using CreateParagraph() should // have the required footnote reference added to the first // run. // Verify that we have a footnote reference in the first paragraph and not // in the second paragraph. XWPFRun r1 = testP1.Runs[0]; Assert.IsNotNull(r1); Assert.IsTrue(r1.GetCTR().GetFootnoteRefList().Count > 0, "No footnote reference in testP1"); Assert.IsNotNull(r1.GetCTR().GetFootnoteRefArray(0), "No footnote reference in testP1"); XWPFRun r2 = testP2.Runs[0]; Assert.IsNotNull(r2, "Expected a run in testP2"); Assert.IsTrue(r2.GetCTR().GetFootnoteRefList().Count == 0, "Found a footnote reference in testP2"); }