public void TestAddEmptyParagraphInTableCell() { const string ExpectedRsidP = "00FF12FF"; const int ExpectedAltChunkId = 1; var tableRowElement = new XElement(WordMl.TableRowName, new XAttribute(WordMl.RsidRPropertiesName, ExpectedRsidP)); var altChunkElement = DocxHelper.CreateAltChunkElement(ExpectedAltChunkId); var tableCellElement = new XElement(WordMl.TableCellName, altChunkElement); tableRowElement.Add(tableCellElement); var document = new XElement(WordMl.BodyName, new XElement(WordMl.TableName, tableRowElement)); DocxHelper.AddEmptyParagraphInTableCell(altChunkElement); Assert.IsNotNull(document); var actualElementAfterAltChunk = altChunkElement.NextElement(); Assert.IsNotNull(actualElementAfterAltChunk); Assert.AreEqual(WordMl.ParagraphName, actualElementAfterAltChunk.Name); Assert.AreEqual(ExpectedRsidP, actualElementAfterAltChunk.Attribute(WordMl.RsidPName).Value); var actualRsidRAttribute = actualElementAfterAltChunk.Attribute(WordMl.RsidRName); Assert.IsNotNull(actualRsidRAttribute); Assert.AreEqual(actualRsidRAttribute.Value.Length, 8); Assert.IsTrue(actualRsidRAttribute.Value.Take(2).All(c => c.Equals('0'))); }
public void TestCreateAltChunkElement() { const int ExpectedAltChunkId = 10; var actualAltChunkElement = DocxHelper.CreateAltChunkElement(ExpectedAltChunkId); Assert.IsNotNull(actualAltChunkElement); Assert.AreEqual(WordMl.AltChunkName, actualAltChunkElement.Name); var actualAltChunkIdAttribute = actualAltChunkElement.Attribute(RelationshipMl.IdName); Assert.IsNotNull(actualAltChunkIdAttribute); Assert.AreEqual(string.Format("altChunkId{0}", ExpectedAltChunkId), actualAltChunkIdAttribute.Value); }