@@ -92,6 +92,17 @@ public static IEnumerable<object[]> Get_TestPartialReads_Data()
92
92
}
93
93
}
94
94
95
+ public static IEnumerable < object [ ] > Get_BooleanCombinations_Data ( )
96
+ {
97
+ foreach ( bool async in _bools )
98
+ {
99
+ foreach ( bool useSeekMethod in _bools )
100
+ {
101
+ yield return new object [ ] { async , useSeekMethod } ;
102
+ }
103
+ }
104
+ }
105
+
95
106
[ Theory ]
96
107
[ MemberData ( nameof ( Get_TestPartialReads_Data ) ) ]
97
108
public static async Task TestPartialReads ( string zipFile , string zipFolder , bool async )
@@ -667,8 +678,8 @@ public static async Task ReadStreamSeekOps(bool async)
667
678
}
668
679
669
680
[ Theory ]
670
- [ MemberData ( nameof ( Get_Booleans_Data ) ) ]
671
- public static async Task ReadEntryContentTwice ( bool async )
681
+ [ MemberData ( nameof ( Get_BooleanCombinations_Data ) ) ]
682
+ public static async Task ReadEntryContentTwice ( bool async , bool useSeekMethod )
672
683
{
673
684
// Create a ZIP archive with stored (uncompressed) entries to test reading content twice
674
685
using ( var ms = new MemoryStream ( ) )
@@ -697,17 +708,24 @@ public static async Task ReadEntryContentTwice(bool async)
697
708
// For stored entries, SubReadStream should be seekable when underlying stream is seekable
698
709
Assert . True( s . CanSeek , $"SubReadStream should be seekable for stored entry '{e.FullName}' when underlying stream is seekable" ) ;
699
710
700
- // Test 1: Read content using Seek method
711
+ // Read content first time
701
712
byte [ ] firstRead = new byte [ e . Length ] ;
702
713
int bytesRead1 = s . Read ( firstRead , 0 , ( int ) e . Length ) ;
703
714
Assert . Equal ( e . Length , bytesRead1 ) ;
704
715
705
- // Seek back to beginning using Seek method
706
- long pos = s . Seek ( 0 , SeekOrigin . Begin ) ;
707
- Assert . Equal ( 0 , pos ) ;
716
+ // Rewind to beginning using specified method
717
+ if ( useSeekMethod )
718
+ {
719
+ long pos = s . Seek ( 0 , SeekOrigin . Begin ) ;
720
+ Assert . Equal ( 0 , pos ) ;
721
+ }
722
+ else
723
+ {
724
+ s . Position = 0 ;
725
+ }
708
726
Assert . Equal ( 0 , s . Position ) ;
709
727
710
- // Read again using Seek method reset
728
+ // Read content second time
711
729
byte [ ] secondRead = new byte [ e . Length ] ;
712
730
int bytesRead2 = s . Read ( secondRead , 0 , ( int ) e . Length ) ;
713
731
Assert . Equal ( e . Length , bytesRead2 ) ;
@@ -717,38 +735,12 @@ public static async Task ReadEntryContentTwice(bool async)
717
735
Assert . Equal ( testData , firstRead ) ;
718
736
Assert . Equal ( testData , secondRead ) ;
719
737
720
- // Test 2: Read content using Position setter
721
- s . Position = 0 ;
722
- byte [ ] thirdRead = new byte [ e . Length ] ;
723
- int bytesRead3 = s . Read ( thirdRead , 0 , ( int ) e . Length ) ;
724
- Assert . Equal ( e . Length , bytesRead3 ) ;
725
-
726
- // Reset using Position setter
727
- s . Position = 0 ;
728
- Assert . Equal ( 0 , s . Position ) ;
729
-
730
- // Read again using Position setter reset
731
- byte [ ] fourthRead = new byte [ e . Length ] ;
732
- int bytesRead4 = s . Read ( fourthRead , 0 , ( int ) e . Length ) ;
733
- Assert . Equal ( e . Length , bytesRead4 ) ;
734
-
735
- // Compare the content - should be identical
736
- Assert . Equal ( thirdRead , fourthRead ) ;
737
- Assert . Equal ( testData , thirdRead ) ;
738
- Assert . Equal ( testData , fourthRead ) ;
739
-
740
- // All reads should be identical
741
- Assert . Equal ( firstRead , thirdRead ) ;
742
- Assert . Equal ( secondRead , fourthRead ) ;
743
-
744
738
await DisposeStream ( async , s ) ;
745
739
}
746
740
}
747
741
}
748
742
}
749
743
750
-
751
-
752
744
private static byte [ ] ReverseCentralDirectoryEntries ( byte [ ] zipFile )
753
745
{
754
746
byte [ ] destinationBuffer = new byte [ zipFile . Length ] ;
0 commit comments