File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
test/DocumentFormat.OpenXml.Tests/ofapiTest Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -385,6 +385,42 @@ public void PartReaderMiscNodeTest()
385
385
reader . Close ( ) ;
386
386
}
387
387
388
+ /// <summary>
389
+ ///A test for OpenXmlPartReader to test the ignoreWhitespace option
390
+ ///</summary>
391
+ [ Theory ]
392
+ [ InlineData ( true ) ]
393
+ [ InlineData ( false ) ]
394
+ public void PartReaderIgnoreWhitespaceTest ( bool ignoreWhitespace )
395
+ {
396
+ string partText = "<w:document xmlns:w=\" http://schemas.openxmlformats.org/wordprocessingml/2006/main\" >" +
397
+ "<w:body>" +
398
+ "<w:p w:rsidP=\" 001\" ><w:r><w:t> </w:t></w:r></w:p>" +
399
+ "</w:body>" +
400
+ "</w:document>" ;
401
+
402
+ UTF8Encoding utf8Encoding = new UTF8Encoding ( ) ;
403
+ Stream stream = new MemoryStream ( utf8Encoding . GetBytes ( partText ) , false ) ;
404
+
405
+ //======== new test with a new reader ========
406
+ OpenXmlReader reader = OpenXmlReader . Create ( stream , false , ignoreWhitespace ) ; // ignore whitespaces
407
+ Assert . False ( reader . EOF ) ;
408
+
409
+ reader . Read ( ) ;
410
+ Assert . False ( reader . EOF ) ;
411
+
412
+ reader . ReadFirstChild ( ) ; // to <w:body>
413
+ reader . Read ( ) ; // to <w:p>
414
+ reader . Read ( ) ; // to <w:r>
415
+ reader . Read ( ) ; // to <w:t>
416
+ Assert . True ( reader . IsStartElement ) ;
417
+ Assert . Equal ( typeof ( Text ) , reader . ElementType ) ;
418
+ Assert . Equal ( ignoreWhitespace , reader . GetText ( ) == string . Empty ) ;
419
+
420
+ reader . Close ( ) ;
421
+ }
422
+
423
+
388
424
/// <summary>
389
425
///A test for OpenXmlPartReader
390
426
///</summary>
You can’t perform that action at this time.
0 commit comments