2022-12-20 15:20:49 +00:00
|
|
|
|
using System.IO;
|
2015-12-30 11:19:42 +00:00
|
|
|
|
|
2022-12-20 15:06:44 +00:00
|
|
|
|
namespace SharpCompress.Test.Mocks;
|
|
|
|
|
|
|
2024-03-14 08:57:16 +00:00
|
|
|
|
public class TestStream(Stream stream, bool read, bool write, bool seek) : Stream
|
2015-12-30 11:19:42 +00:00
|
|
|
|
{
|
2023-03-21 13:14:08 +00:00
|
|
|
|
public TestStream(Stream stream)
|
|
|
|
|
|
: this(stream, stream.CanRead, stream.CanWrite, stream.CanSeek) { }
|
2022-12-20 15:06:44 +00:00
|
|
|
|
|
|
|
|
|
|
public bool IsDisposed { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool disposing)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Dispose(disposing);
|
2024-03-14 08:57:16 +00:00
|
|
|
|
stream.Dispose();
|
2022-12-20 15:06:44 +00:00
|
|
|
|
IsDisposed = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-14 08:57:16 +00:00
|
|
|
|
public override bool CanRead { get; } = read;
|
2022-12-20 15:06:44 +00:00
|
|
|
|
|
2024-03-14 08:57:16 +00:00
|
|
|
|
public override bool CanSeek { get; } = seek;
|
2022-12-20 15:06:44 +00:00
|
|
|
|
|
2024-03-14 08:57:16 +00:00
|
|
|
|
public override bool CanWrite { get; } = write;
|
2022-12-20 15:06:44 +00:00
|
|
|
|
|
2024-03-14 08:57:16 +00:00
|
|
|
|
public override void Flush() => stream.Flush();
|
2022-12-20 15:06:44 +00:00
|
|
|
|
|
2024-03-14 08:57:16 +00:00
|
|
|
|
public override long Length => stream.Length;
|
2022-12-20 15:06:44 +00:00
|
|
|
|
|
|
|
|
|
|
public override long Position
|
|
|
|
|
|
{
|
2024-03-14 08:57:16 +00:00
|
|
|
|
get => stream.Position;
|
|
|
|
|
|
set => stream.Position = value;
|
2022-12-20 15:06:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-12-20 15:20:49 +00:00
|
|
|
|
public override int Read(byte[] buffer, int offset, int count) =>
|
2024-03-14 08:57:16 +00:00
|
|
|
|
stream.Read(buffer, offset, count);
|
2022-12-20 15:06:44 +00:00
|
|
|
|
|
2024-03-14 08:57:16 +00:00
|
|
|
|
public override long Seek(long offset, SeekOrigin origin) => stream.Seek(offset, origin);
|
2022-12-20 15:06:44 +00:00
|
|
|
|
|
2024-03-14 08:57:16 +00:00
|
|
|
|
public override void SetLength(long value) => stream.SetLength(value);
|
2022-12-20 15:06:44 +00:00
|
|
|
|
|
2022-12-20 15:20:49 +00:00
|
|
|
|
public override void Write(byte[] buffer, int offset, int count) =>
|
2024-03-14 08:57:16 +00:00
|
|
|
|
stream.Write(buffer, offset, count);
|
2015-12-30 11:19:42 +00:00
|
|
|
|
}
|