File tree Expand file tree Collapse file tree 3 files changed +31
-9
lines changed
test/ICSharpCode.SharpZipLib.Tests Expand file tree Collapse file tree 3 files changed +31
-9
lines changed Original file line number Diff line number Diff line change @@ -177,13 +177,15 @@ public class MemoryStreamWithoutSeek : TrackedMemoryStream
177177 /// </summary>
178178 /// <value></value>
179179 /// <returns>true if the stream is open.</returns>
180- public override bool CanSeek
180+ public override bool CanSeek => false ;
181+
182+ /// <inheritdoc />
183+ public override long Position
181184 {
182- get
183- {
184- return false ;
185- }
185+ get => throw new NotSupportedException ( "Getting position is not supported" ) ;
186+ set => throw new NotSupportedException ( "Setting position is not supported" ) ;
186187 }
188+
187189 }
188190
189191 /// <summary>
Original file line number Diff line number Diff line change @@ -111,11 +111,10 @@ public void ReadAndWriteZip64NonSeekable()
111111 outStream . Close ( ) ;
112112 }
113113
114- Assert . That ( msw . ToArray ( ) , Does . PassTestArchive ( ) ) ;
115-
116- msw . Position = 0 ;
114+ var msBytes = msw . ToArray ( ) ;
115+ Assert . That ( msBytes , Does . PassTestArchive ( ) ) ;
117116
118- using ( var zis = new ZipInputStream ( msw ) )
117+ using ( var zis = new ZipInputStream ( new MemoryStream ( msBytes ) ) )
119118 {
120119 while ( zis . GetNextEntry ( ) != null )
121120 {
Original file line number Diff line number Diff line change @@ -97,5 +97,26 @@ public async Task WriteZipStreamWithZipCryptoAsync()
9797 ZipTesting . AssertValidZip ( ms , password , false ) ;
9898 }
9999
100+ [ Test ]
101+ [ Category ( "Zip" ) ]
102+ [ Category ( "Async" ) ]
103+ public async Task WriteReadOnlyZipStreamAsync ( )
104+ {
105+ using var ms = new MemoryStreamWithoutSeek ( ) ;
106+
107+ using ( var outStream = new ZipOutputStream ( ms ) { IsStreamOwner = false } )
108+ {
109+ await outStream . PutNextEntryAsync ( new ZipEntry ( "FirstFile" ) ) ;
110+ await Utils . WriteDummyDataAsync ( outStream , 12 ) ;
111+
112+ await outStream . PutNextEntryAsync ( new ZipEntry ( "SecondFile" ) ) ;
113+ await Utils . WriteDummyDataAsync ( outStream , 12 ) ;
114+
115+ await outStream . FinishAsync ( CancellationToken . None ) ;
116+ }
117+
118+ ZipTesting . AssertValidZip ( new MemoryStream ( ms . ToArray ( ) ) ) ;
119+ }
120+
100121 }
101122}
You can’t perform that action at this time.
0 commit comments