diff --git a/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs b/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs index 748dcb24a..822e71513 100644 --- a/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs +++ b/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs @@ -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 @@ -294,6 +297,42 @@ namespace SixLabors.ImageSharp.Tests.IO Assert.Equal(expected, destination.ToArray()); } + public static TheoryData GetAllTestImages() + { + IEnumerable allImageFiles = Directory.EnumerateFiles(TestEnvironment.InputImagesDirectoryFullPath, "*.*", SearchOption.AllDirectories) + .Where(s => !s.ToLower().EndsWith("txt")); + var result = new TheoryData(); + foreach (string path in allImageFiles) + { + result.Add(path); + } + + return result; + } + + [Theory] + [MemberData(nameof(GetAllTestImages))] + public void DecoderIntegrationTest(string testFileFullPath) + { + Image expected = null; + try + { + expected = Image.Load(testFileFullPath); + } + catch + { + // The image is invalid + return; + } + + using FileStream fs = File.OpenRead(testFileFullPath); + using NonSeekableStream nonSeekableStream = new NonSeekableStream(fs); + + var actual = Image.Load(nonSeekableStream); + + ImageComparer.Exact.VerifySimilarity(expected, actual); + } + public static IEnumerable CopyToData() { // Stream is positioned @ beginning of data