66using System . IO ;
77using System . Linq ;
88using System . Text ;
9+ using Does = ICSharpCode . SharpZipLib . Tests . TestSupport . Does ;
910using TimeSetting = ICSharpCode . SharpZipLib . Zip . ZipEntryFactory . TimeSetting ;
1011
1112namespace ICSharpCode . SharpZipLib . Tests . Zip
@@ -40,7 +41,7 @@ public void Basics()
4041 ZipEntry entry = zf [ 0 ] ;
4142 Assert . AreEqual ( tempName1 , entry . Name ) ;
4243 Assert . AreEqual ( 1 , entry . Size ) ;
43- Assert . IsTrue ( zf . TestArchive ( true ) ) ;
44+ Assert . That ( zf , Does . PassTestArchive ( ) ) ;
4445
4546 zf . Close ( ) ;
4647 }
@@ -128,7 +129,7 @@ public void CreateEmptyDirectories(string password)
128129 var folderEntry = zipFile . GetEntry ( "floyd/" ) ;
129130 Assert . That ( folderEntry . IsDirectory , Is . True , "The entry must be a folder" ) ;
130131
131- Assert . IsTrue ( zipFile . TestArchive ( testData : true ) ) ;
132+ Assert . That ( zipFile , Does . PassTestArchive ( ) ) ;
132133 }
133134 }
134135 }
@@ -166,14 +167,15 @@ public void ContentEqualAfterAfterArchived([Values(0, 1, 64)]int contentSize)
166167 public void Encryption ( ZipEncryptionMethod encryptionMethod )
167168 {
168169 const string tempName1 = "a.dat" ;
170+ const int tempSize = 1 ;
169171
170172 var target = new MemoryStream ( ) ;
171173
172174 string tempFilePath = GetTempFilePath ( ) ;
173175 Assert . IsNotNull ( tempFilePath , "No permission to execute this test?" ) ;
174176
175177 string addFile = Path . Combine ( tempFilePath , tempName1 ) ;
176- MakeTempFile ( addFile , 1 ) ;
178+ MakeTempFile ( addFile , tempSize ) ;
177179
178180 try
179181 {
@@ -189,17 +191,13 @@ public void Encryption(ZipEncryptionMethod encryptionMethod)
189191 using ( ZipFile zf = new ZipFile ( archive ) )
190192 {
191193 zf . Password = "Ahoy" ;
192- Assert . AreEqual ( 1 , zf . Count ) ;
193- ZipEntry entry = zf [ 0 ] ;
194- Assert . AreEqual ( tempName1 , entry . Name ) ;
195- Assert . AreEqual ( 1 , entry . Size ) ;
196- Assert . IsTrue ( zf . TestArchive ( true , TestStrategy . FindFirstError , ( status , message ) =>
197- {
198- if ( ! string . IsNullOrEmpty ( message ) ) {
199- Console . WriteLine ( $ "{ message } ({ status . Entry ? . Name ?? "-" } )") ;
200- }
201- } ) ) ;
202- Assert . IsTrue ( entry . IsCrypted ) ;
194+ Assert . That ( zf . Count , Is . EqualTo ( 1 ) ) ;
195+ var entry = zf [ 0 ] ;
196+ Assert . That ( entry . Name , Is . EqualTo ( tempName1 ) ) ;
197+ Assert . That ( entry . Size , Is . EqualTo ( tempSize ) ) ;
198+ Assert . That ( entry . IsCrypted ) ;
199+
200+ Assert . That ( zf , Does . PassTestArchive ( ) ) ;
203201
204202 switch ( encryptionMethod )
205203 {
@@ -363,14 +361,15 @@ public void ExtractExceptions()
363361 public void ReadingOfLockedDataFiles ( )
364362 {
365363 const string tempName1 = "a.dat" ;
364+ const int tempSize = 1 ;
366365
367366 var target = new MemoryStream ( ) ;
368367
369368 string tempFilePath = GetTempFilePath ( ) ;
370369 Assert . IsNotNull ( tempFilePath , "No permission to execute this test?" ) ;
371370
372371 string addFile = Path . Combine ( tempFilePath , tempName1 ) ;
373- MakeTempFile ( addFile , 1 ) ;
372+ MakeTempFile ( addFile , tempSize ) ;
374373
375374 try
376375 {
@@ -383,11 +382,11 @@ public void ReadingOfLockedDataFiles()
383382 var archive = new MemoryStream ( target . ToArray ( ) ) ;
384383 using ( ZipFile zf = new ZipFile ( archive ) )
385384 {
386- Assert . AreEqual ( 1 , zf . Count ) ;
387- ZipEntry entry = zf [ 0 ] ;
388- Assert . AreEqual ( tempName1 , entry . Name ) ;
389- Assert . AreEqual ( 1 , entry . Size ) ;
390- Assert . IsTrue ( zf . TestArchive ( true ) ) ;
385+ Assert . That ( zf . Count , Is . EqualTo ( 1 ) ) ;
386+ var entry = zf [ 0 ] ;
387+ Assert . That ( entry . Name , Is . EqualTo ( tempName1 ) ) ;
388+ Assert . That ( entry . Size , Is . EqualTo ( tempSize ) ) ;
389+ Assert . That ( zf , Does . PassTestArchive ( ) ) ;
391390
392391 zf . Close ( ) ;
393392 }
@@ -404,14 +403,15 @@ public void ReadingOfLockedDataFiles()
404403 public void NonAsciiPasswords ( )
405404 {
406405 const string tempName1 = "a.dat" ;
406+ const int tempSize = 1 ;
407407
408408 var target = new MemoryStream ( ) ;
409409
410410 string tempFilePath = GetTempFilePath ( ) ;
411411 Assert . IsNotNull ( tempFilePath , "No permission to execute this test?" ) ;
412412
413413 string addFile = Path . Combine ( tempFilePath , tempName1 ) ;
414- MakeTempFile ( addFile , 1 ) ;
414+ MakeTempFile ( addFile , tempSize ) ;
415415
416416 string password = "abc\u0066 \u0393 " ;
417417 try
@@ -425,12 +425,12 @@ public void NonAsciiPasswords()
425425 using ( ZipFile zf = new ZipFile ( archive ) )
426426 {
427427 zf . Password = password ;
428- Assert . AreEqual ( 1 , zf . Count ) ;
429- ZipEntry entry = zf [ 0 ] ;
430- Assert . AreEqual ( tempName1 , entry . Name ) ;
431- Assert . AreEqual ( 1 , entry . Size ) ;
432- Assert . IsTrue ( zf . TestArchive ( true ) ) ;
433- Assert . IsTrue ( entry . IsCrypted ) ;
428+ Assert . That ( zf . Count , Is . EqualTo ( 1 ) ) ;
429+ var entry = zf [ 0 ] ;
430+ Assert . That ( entry . Name , Is . EqualTo ( tempName1 ) ) ;
431+ Assert . That ( entry . Size , Is . EqualTo ( tempSize ) ) ;
432+ Assert . That ( zf , Does . PassTestArchive ( ) ) ;
433+ Assert . That ( entry . IsCrypted ) ;
434434 }
435435 }
436436 finally
@@ -636,10 +636,11 @@ public void SetDirectoryModifiedDate()
636636 public void CreateZipShouldLeaveOutputStreamOpenIfRequested ( bool leaveOpen )
637637 {
638638 const string tempFileName = "a(2).dat" ;
639+ const int tempSize = 16 ;
639640
640641 using var tempFolder = Utils . GetTempDir ( ) ;
641642 // Create test input file
642- tempFolder . CreateDummyFile ( tempFileName , size : 16 ) ;
643+ tempFolder . CreateDummyFile ( tempFileName , tempSize ) ;
643644
644645 // Create the zip with fast zip
645646 var target = new TrackedMemoryStream ( ) ;
@@ -653,11 +654,11 @@ public void CreateZipShouldLeaveOutputStreamOpenIfRequested(bool leaveOpen)
653654 // Check that the file contents are correct in both cases
654655 var archive = new MemoryStream ( target . ToArray ( ) ) ;
655656 using var zf = new ZipFile ( archive ) ;
656- Assert . AreEqual ( expected : 1 , zf . Count ) ;
657+ Assert . That ( zf . Count , Is . EqualTo ( 1 ) ) ;
657658 var entry = zf [ 0 ] ;
658- Assert . AreEqual ( tempFileName , entry . Name ) ;
659- Assert . AreEqual ( expected : 16 , entry . Size ) ;
660- Assert . IsTrue ( zf . TestArchive ( testData : true ) ) ;
659+ Assert . That ( entry . Name , Is . EqualTo ( tempFileName ) ) ;
660+ Assert . That ( entry . Size , Is . EqualTo ( tempSize ) ) ;
661+ Assert . That ( zf , Does . PassTestArchive ( ) ) ;
661662 }
662663
663664 [ Category ( "Zip" ) ]
0 commit comments