using DocumentFormat.OpenXml.Packaging; using DocumentFormat.OpenXml.Wordprocessing; using DocxWorkbench.OpenXml; namespace DocxWorkbench.Tests; public sealed class DocumentInspectorTests { [Fact] public void InspectsSyntheticDocxStructure() { var path = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".docx"); using (var doc = WordprocessingDocument.Create(path, DocumentFormat.OpenXml.WordprocessingDocumentType.Document)) { var main = doc.AddMainDocumentPart(); main.Document = new Document(new Body(new Paragraph(new Run(new Text("{{DOC_BODY}}"))), new Table(new TableRow(new TableCell(new Paragraph(new Run(new Text("x")))))))); main.Document.Save(); } try { var result = new DocumentInspector().Inspect(path); Assert.Equal(1, result.Tables); Assert.True(result.Paragraphs >= 2); Assert.True(result.HasPageFields is false); } finally { File.Delete(path); } } }