public void PackageRelationshipTest() { var docx = new DocxFile(); AppendBody(docx); AppendHeaderFooter(docx); var stream = new MemoryStream(); docx.Save(stream); var package = Package.Open(stream); CheckRelationships( new string[] { "altChunk1.html", "altChunk2.rtf", "header1.xml", "footer1.xml" }, package.GetPart(new Uri("/word/document.xml", UriKind.Relative)).GetRelationships()); CheckRelationships( new string[] { "altChunk3.html", "altChunk4.rtf" }, package.GetPart(new Uri("/word/header1.xml", UriKind.Relative)).GetRelationships()); CheckRelationships( new string[] { "altChunk5.html", "altChunk6.rtf" }, package.GetPart(new Uri("/word/footer1.xml", UriKind.Relative)).GetRelationships()); package.Close(); }
public void PackagePartTest() { var docx = new DocxFile(); AppendBody(docx); AppendHeaderFooter(docx); var stream = new MemoryStream(); docx.Save(stream); var package = Package.Open(stream); var parts = package.GetParts(); HashSet <string> expectedParts = new HashSet <string>( new string[] { "/word/altChunk1.html", "/word/altChunk2.rtf", "/word/altChunk3.html", "/word/altChunk4.rtf", "/word/altChunk5.html", "/word/altChunk6.rtf", "/word/document.xml", "/word/footer1.xml", "/word/header1.xml", "/word/_rels/document.xml.rels", "/word/_rels/footer1.xml.rels", "/word/_rels/header1.xml.rels", "/_rels/.rels" }); foreach (PackagePart part in parts) { Assert.IsTrue(expectedParts.Remove(part.Uri.OriginalString)); } Assert.IsTrue(expectedParts.Count == 0); package.Close(); }
public void DocxRtfResultTest() { var docx = new DocxFile(); docx.Body.AppendFile(@"..\..\TestFiles\Font.rtf", ContentType.Rtf) .AppendFile(@"..\..\TestFiles\Image.rtf", ContentType.Rtf) .AppendFile(@"..\..\TestFiles\Table.rtf", ContentType.Rtf); docx.Save("DocxRtfResultTest.docx"); Process.Start("DocxRtfResultTest.docx"); }
public void DocxHtmlResultTest() { var docx = new DocxFile(); docx.Body.AppendFile(@"..\..\TestFiles\Font.html", ContentType.Html) .AppendFile(@"..\..\TestFiles\Image.html", ContentType.Html) .AppendFile(@"..\..\TestFiles\Table.html", ContentType.Html); docx.Save("DocxHtmlResultTest.docx"); Process.Start("DocxHtmlResultTest.docx"); }
public void PackagePartTest() { var docx = new DocxFile(); AppendBody(docx); AppendHeaderFooter(docx); var stream = new MemoryStream(); docx.Save(stream); var package = Package.Open(stream); var parts = package.GetParts(); HashSet<string> expectedParts = new HashSet<string>( new string[] { "/word/altChunk1.html", "/word/altChunk2.rtf", "/word/altChunk3.html", "/word/altChunk4.rtf", "/word/altChunk5.html", "/word/altChunk6.rtf", "/word/document.xml", "/word/footer1.xml", "/word/header1.xml", "/word/_rels/document.xml.rels", "/word/_rels/footer1.xml.rels", "/word/_rels/header1.xml.rels", "/_rels/.rels" }); foreach (PackagePart part in parts) Assert.IsTrue(expectedParts.Remove(part.Uri.OriginalString)); Assert.IsTrue(expectedParts.Count == 0); package.Close(); }