Skip to content
Prev Previous commit
Next Next commit
heavyweight integration test
  • Loading branch information
antonfirsov committed Aug 19, 2020
commit 6f40e43837e38da06a3bccd344c4166c66453ec0
39 changes: 39 additions & 0 deletions tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SixLabors.ImageSharp.IO;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using Xunit;

namespace SixLabors.ImageSharp.Tests.IO
Expand Down Expand Up @@ -294,6 +297,42 @@ public void CopyTo(Stream source, byte[] expected)
Assert.Equal(expected, destination.ToArray());
}

public static TheoryData<string> GetAllTestImages()
{
IEnumerable<string> allImageFiles = Directory.EnumerateFiles(TestEnvironment.InputImagesDirectoryFullPath, "*.*", SearchOption.AllDirectories)
.Where(s => !s.ToLower().EndsWith("txt"));
var result = new TheoryData<string>();
foreach (string path in allImageFiles)
{
result.Add(path);
}

return result;
}

[Theory]
[MemberData(nameof(GetAllTestImages))]
public void DecoderIntegrationTest(string testFileFullPath)
{
Image<Rgba32> expected = null;
try
{
expected = Image.Load<Rgba32>(testFileFullPath);

@antonfirsov antonfirsov Aug 20, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's my code, but if we leave all tests, on this line I would really like to replace Image.Load with TestFile stuff now to make the tests at least a bit faster by utilizing it's caching mechanism. Would do it, but I'm on a train now, may try later, if you also lack time.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated it to use the provider.

}
catch
{
// The image is invalid
return;
}

using FileStream fs = File.OpenRead(testFileFullPath);
using NonSeekableStream nonSeekableStream = new NonSeekableStream(fs);

var actual = Image.Load<Rgba32>(nonSeekableStream);

ImageComparer.Exact.VerifySimilarity(expected, actual);
}

public static IEnumerable<object[]> CopyToData()
{
// Stream is positioned @ beginning of data
Expand Down