mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-25 00:15:15 +00:00
AsyncStream everything
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SharpCompress.Test.Mocks
|
||||
{
|
||||
@@ -22,8 +25,12 @@ namespace SharpCompress.Test.Mocks
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
stream.Dispose();
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override async ValueTask DisposeAsync()
|
||||
{
|
||||
await stream.DisposeAsync();
|
||||
IsDisposed = true;
|
||||
}
|
||||
|
||||
@@ -46,10 +53,17 @@ namespace SharpCompress.Test.Mocks
|
||||
set => stream.Position = value;
|
||||
}
|
||||
|
||||
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||
{
|
||||
return stream.ReadAsync(buffer, offset, count, cancellationToken);
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
return stream.Read(buffer, offset, count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
@@ -65,5 +79,10 @@ namespace SharpCompress.Test.Mocks
|
||||
{
|
||||
stream.Write(buffer, offset, count);
|
||||
}
|
||||
|
||||
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||
{
|
||||
return stream.WriteAsync(buffer, offset, count, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,11 +26,11 @@ namespace SharpCompress.Test
|
||||
|
||||
private async ValueTask ReadImplAsync(string testArchive, CompressionType expectedCompression, ReaderOptions options)
|
||||
{
|
||||
using (var file = File.OpenRead(testArchive))
|
||||
await using (var file = File.OpenRead(testArchive))
|
||||
{
|
||||
using (var protectedStream = new NonDisposingStream(new ForwardOnlyStream(file), throwOnDispose: true))
|
||||
await using (var protectedStream = new NonDisposingStream(new ForwardOnlyStream(file), throwOnDispose: true))
|
||||
{
|
||||
using (var testStream = new TestStream(protectedStream))
|
||||
await using (var testStream = new TestStream(protectedStream))
|
||||
{
|
||||
await using (var reader = await ReaderFactory.OpenAsync(testStream, options))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user