diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Decode_Cancellation.cs b/tests/ImageSharp.Tests/Image/ImageTests.Decode_Cancellation.cs index 6b74e9b354..543dd28cd7 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Decode_Cancellation.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Decode_Cancellation.cs @@ -85,7 +85,7 @@ public partial class ImageTests Configuration configuration = Configuration.CreateDefaultInstance(); configuration.FileSystem = new SingleStreamFileSystem((Stream)pausedStream); - configuration.StreamProcessingBufferSize = 256; + configuration.StreamProcessingBufferSize = (int)Math.Min(128, pausedStream.Length / 4); DecoderOptions options = new() { diff --git a/tests/ImageSharp.Tests/TestUtilities/IPausedStream.cs b/tests/ImageSharp.Tests/TestUtilities/IPausedStream.cs index 1eedef9d09..ec9b2e7e17 100644 --- a/tests/ImageSharp.Tests/TestUtilities/IPausedStream.cs +++ b/tests/ImageSharp.Tests/TestUtilities/IPausedStream.cs @@ -12,4 +12,6 @@ public interface IPausedStream : IDisposable public void Next(); public void Release(); + + public long Length { get; } } diff --git a/tests/ImageSharp.Tests/TestUtilities/PausedMemoryStream.cs b/tests/ImageSharp.Tests/TestUtilities/PausedMemoryStream.cs index 5b285b4caa..ae4af24f14 100644 --- a/tests/ImageSharp.Tests/TestUtilities/PausedMemoryStream.cs +++ b/tests/ImageSharp.Tests/TestUtilities/PausedMemoryStream.cs @@ -12,9 +12,9 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities; /// public class PausedMemoryStream : MemoryStream, IPausedStream { - private readonly SemaphoreSlim semaphore = new SemaphoreSlim(0); + private readonly SemaphoreSlim semaphore = new(0); - private readonly CancellationTokenSource cancelationTokenSource = new CancellationTokenSource(); + private readonly CancellationTokenSource cancelationTokenSource = new(); private Action onWaitingCallback; diff --git a/tests/ImageSharp.Tests/TestUtilities/PausedStream.cs b/tests/ImageSharp.Tests/TestUtilities/PausedStream.cs index 8af168d67f..3c780f3474 100644 --- a/tests/ImageSharp.Tests/TestUtilities/PausedStream.cs +++ b/tests/ImageSharp.Tests/TestUtilities/PausedStream.cs @@ -7,9 +7,9 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities; public class PausedStream : Stream, IPausedStream { - private readonly SemaphoreSlim semaphore = new SemaphoreSlim(0); + private readonly SemaphoreSlim semaphore = new(0); - private readonly CancellationTokenSource cancelationTokenSource = new CancellationTokenSource(); + private readonly CancellationTokenSource cancelationTokenSource = new(); private readonly Stream innerStream; private Action onWaitingCallback;