Browse Source

fix tests

pull/1574/head
Anton Firszov 6 years ago
parent
commit
4fb21bb255
  1. 4
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs
  2. 4
      tests/ImageSharp.Tests/Image/ImageTests.SaveAsync.cs
  3. 14
      tests/ImageSharp.Tests/TestUtilities/Tests/SemaphoreReadMemoryStreamTests.cs

4
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs

@ -155,8 +155,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
}
[Theory]
[InlineData(TestImages.Jpeg.Issues.ExifGetString750Transform)]
[InlineData(TestImages.Jpeg.Issues.BadRstProgressive518)]
[InlineData(TestImages.Jpeg.Baseline.Exif)]
[InlineData(TestImages.Jpeg.Progressive.Bad.ExifUndefType)]
public async Task Identify_IsCancellable(string fileName)
{
string hugeFile = Path.Combine(

4
tests/ImageSharp.Tests/Image/ImageTests.SaveAsync.cs

@ -106,8 +106,8 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public async Task SaveAsync_WithNonSeekableStream_IsCancellable()
{
using var image = new Image<Rgba32>(500, 500);
IImageEncoder encoder = new BmpEncoder();
using var image = new Image<Rgba32>(2000, 2000);
var encoder = new PngEncoder() { CompressionLevel = PngCompressionLevel.BestCompression };
using var stream = new MemoryStream();
var asyncStream = new AsyncStreamWrapper(stream, () => false);
var cts = new CancellationTokenSource();

14
tests/ImageSharp.Tests/TestUtilities/Tests/SemaphoreReadMemoryStreamTests.cs

@ -36,6 +36,7 @@ namespace SixLabors.ImageSharp.Tests
{
using Stream stream = this.CreateTestStream();
stream.Read(this.buffer);
Assert.Equal(0, this.notifyWaitPositionReachedSemaphore.CurrentCount);
Task readTask = Task.Factory.StartNew(
() =>
@ -46,7 +47,7 @@ namespace SixLabors.ImageSharp.Tests
stream.Read(this.buffer);
stream.Read(this.buffer);
}, TaskCreationOptions.LongRunning);
Assert.Equal(0, this.notifyWaitPositionReachedSemaphore.CurrentCount);
await Task.Delay(5);
Assert.False(readTask.IsCompleted);
await this.notifyWaitPositionReachedSemaphore.WaitAsync();
@ -62,8 +63,15 @@ namespace SixLabors.ImageSharp.Tests
using Stream stream = this.CreateTestStream();
await stream.ReadAsync(this.buffer, 0, this.buffer.Length);
Task readTask =
Task.Factory.StartNew(() => stream.ReadAsync(new byte[512], 0, this.buffer.Length), TaskCreationOptions.LongRunning);
Task readTask = Task.Factory.StartNew(
async () =>
{
await stream.ReadAsync(this.buffer, 0, this.buffer.Length);
await stream.ReadAsync(this.buffer, 0, this.buffer.Length);
await stream.ReadAsync(this.buffer, 0, this.buffer.Length);
await stream.ReadAsync(this.buffer, 0, this.buffer.Length);
await stream.ReadAsync(this.buffer, 0, this.buffer.Length);
}, TaskCreationOptions.LongRunning);
await Task.Delay(5);
Assert.False(readTask.IsCompleted);
await this.notifyWaitPositionReachedSemaphore.WaitAsync();

Loading…
Cancel
Save