Skip to content

Commit ecf34fd

Browse files
committed
Refactor DocxReader to improve resource management and update test to use StringComparer for page number validation
1 parent 4b661c2 commit ecf34fd

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/MiniPdf/DocxReader.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ internal static DocxDocument Read(Stream stream)
6868
if (entry == null)
6969
return new DocxDocument([]);
7070

71-
using var docStream = entry.Open();
72-
var doc = XDocument.Load(docStream);
71+
XDocument doc;
72+
using (var docStream = entry.Open())
73+
doc = XDocument.Load(docStream);
7374
var body = doc.Descendants(W + "body").FirstOrDefault();
7475
if (body == null)
7576
return new DocxDocument([]);

tests/MiniPdf.Tests/DocxToPdfConverterTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ public void Convert_FooterPageFieldWithSwitch_RendersPageNumber()
166166
var doc = DocxToPdfConverter.Convert(docxStream);
167167

168168
Assert.True(doc.Pages.Count >= 1);
169-
Assert.Contains(doc.Pages[0].TextBlocks, b => b.Text == "1");
169+
var texts = doc.Pages[0].TextBlocks.Select(b => b.Text).ToList();
170+
Assert.Contains("1", texts, StringComparer.Ordinal);
170171
}
171172

172173
// ── Helper: Create minimal DOCX ─────────────────────────────────────

0 commit comments

Comments
 (0)