public void SiblingTest() { Paragraph para = new Paragraph(); Run r1 = para.AppendChild(new Run()); Bold b1 = r1.AppendChild(new RunProperties()).AppendChild(new Bold()); Text t1 = r1.AppendChild(new Text()); BookmarkStart bkStart = para.AppendChild(new BookmarkStart()); Run r2 = para.AppendChild(new Run()); r2.AppendChild(new Text()); BookmarkEnd bkEnd = para.AppendChild(new BookmarkEnd()); Run r3 = para.AppendChild(new Run()); Assert.Null(para.PreviousSibling <Paragraph>()); Assert.Null(r1.PreviousSibling <BookmarkStart>()); Assert.Same(r1, bkStart.PreviousSibling <Run>()); Assert.Same(bkStart, r2.PreviousSibling <BookmarkStart>()); Assert.Same(bkStart, bkEnd.PreviousSibling <BookmarkStart>()); Assert.Same(bkStart, r3.PreviousSibling <BookmarkStart>()); Assert.Null(para.NextSibling <Paragraph>()); Assert.Null(r2.NextSibling <BookmarkStart>()); Assert.Same(r2, bkStart.NextSibling <Run>()); Assert.Same(bkEnd, r1.NextSibling <BookmarkEnd>()); Assert.Same(bkEnd, bkStart.NextSibling <BookmarkEnd>()); Assert.Same(bkEnd, r2.NextSibling <BookmarkEnd>()); }
public void InsertElementTest() { var para = new Paragraph(); var r1 = new Run(); var r2 = new Run(); var r3 = new Run(); para.InsertAt(r1, 0); para.InsertAt(r3, 1); para.InsertAt(r2, 1); Assert.Same(r1, para.FirstChild); Assert.Same(r2, r1.NextSibling()); Assert.Same(r3, para.LastChild); var pPr = new ParagraphProperties(); r1.InsertBeforeSelf(pPr); Assert.Same(pPr, para.FirstChild); Assert.Same(r1, pPr.NextSibling()); Assert.Same(pPr, r1.PreviousSibling()); var bkStart = new BookmarkStart(); r1.InsertAfterSelf(bkStart); Assert.Same(bkStart, r1.NextSibling()); Assert.Same(r1, bkStart.PreviousSibling()); }
public void InsertElementTest() { Paragraph para = new Paragraph(); Run r1 = new Run(); Run r2 = new Run(); Run r3 = new Run(); para.InsertAt(r1, 0); para.InsertAt(r3, 1); para.InsertAt(r2, 1); Assert.Same(r1, para.FirstChild); Assert.Same(r2, r1.NextSibling()); Assert.Same(r3, para.LastChild); ParagraphProperties pPr = new ParagraphProperties(); r1.InsertBeforeSelf(pPr); Assert.Same(pPr, para.FirstChild); Assert.Same(r1, pPr.NextSibling()); Assert.Same(pPr, r1.PreviousSibling()); BookmarkStart bkStart = new BookmarkStart(); r1.InsertAfterSelf(bkStart); Assert.Same(bkStart, r1.NextSibling()); Assert.Same(r1, bkStart.PreviousSibling()); }