Skip to content

Commit 759570e

Browse files
committed
only test where supported
1 parent 9e8d204 commit 759570e

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

test/ICSharpCode.SharpZipLib.Tests/TestSupport/Streams.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ public override long Position
189189

190190
}
191191

192+
#if NETSTANDARD2_1 || NETCOREAPP3_0_OR_GREATER
192193
/// <summary>
193194
/// A <see cref="Stream"/> that does not support non-async operations.
194195
/// </summary>
@@ -210,11 +211,10 @@ public class MemoryStreamWithoutSync : Stream
210211

211212
public override void Flush() => throw new NotSupportedException($"Non-async call to {nameof(Flush)}");
212213

213-
#if NETSTANDARD2_1 || NETCOREAPP3_0_OR_GREATER
214+
214215
public override void CopyTo(Stream destination, int bufferSize) => throw new NotSupportedException($"Non-async call to {nameof(CopyTo)}");
215216
public override void Write(ReadOnlySpan<byte> buffer) => throw new NotSupportedException($"Non-async call to {nameof(Write)}");
216217
public override int Read(Span<byte> buffer) => throw new NotSupportedException($"Non-async call to {nameof(Read)}");
217-
#endif
218218

219219
public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException($"Non-async call to {nameof(Write)}");
220220
public override void WriteByte(byte value) => throw new NotSupportedException($"Non-async call to {nameof(Write)}");
@@ -233,11 +233,8 @@ public override async Task CopyToAsync(Stream destination, int bufferSize, Cance
233233
public override Task FlushAsync(CancellationToken cancellationToken) => TaskFromBlocking(() => _inner.Flush());
234234
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) => TaskFromBlocking(() => _inner.Write(buffer, offset, count));
235235
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) => Task.FromResult(_inner.Read(buffer, offset, count));
236-
237-
#if NETSTANDARD2_1 || NETCOREAPP3_0_OR_GREATER
238236
public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default) => ValueTaskFromBlocking(() => _inner.Write(buffer.Span));
239237
public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default) => ValueTask.FromResult(_inner.Read(buffer.Span));
240-
#endif
241238

242239
static Task TaskFromBlocking(Action action)
243240
{
@@ -261,6 +258,7 @@ public override void SetLength(long value)
261258
_inner.SetLength(value);
262259
}
263260
}
261+
#endif
264262

265263
/// <summary>
266264
/// A <see cref="Stream"/> that cannot be read but supports infinite writes.

test/ICSharpCode.SharpZipLib.Tests/Zip/ZipStreamAsyncTests.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class ZipStreamAsyncTests
1515
[Category("Async")]
1616
public async Task WriteZipStreamUsingAsync()
1717
{
18-
#if NETCOREAPP3_1_OR_GREATER
18+
#if NETSTANDARD2_1 || NETCOREAPP3_0_OR_GREATER
1919
await using var ms = new MemoryStream();
2020

2121
await using (var outStream = new ZipOutputStream(ms){IsStreamOwner = false})
@@ -126,6 +126,7 @@ public async Task WriteReadOnlyZipStreamAsync ()
126126
[Category("Async")]
127127
public async Task WriteZipStreamToAsyncOnlyStream ()
128128
{
129+
#if NETSTANDARD2_1 || NETCOREAPP3_0_OR_GREATER
129130
await using(var ms = new MemoryStreamWithoutSync()){
130131
await using(var outStream = new ZipOutputStream(ms) { IsStreamOwner = false })
131132
{
@@ -141,6 +142,10 @@ public async Task WriteZipStreamToAsyncOnlyStream ()
141142

142143
ZipTesting.AssertValidZip(new MemoryStream(ms.ToArray()));
143144
}
145+
#else
146+
await Task.CompletedTask;
147+
Assert.Ignore("AsyncDispose is not supported");
148+
#endif
144149
}
145150

146151
}

0 commit comments

Comments
 (0)