Skip to content

Commit 6f40e43

Browse files
committed
heavyweight integration test
1 parent 5aa9158 commit 6f40e43

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
using System;
55
using System.Collections.Generic;
66
using System.IO;
7+
using System.Linq;
78
using SixLabors.ImageSharp.IO;
89
using SixLabors.ImageSharp.Memory;
10+
using SixLabors.ImageSharp.PixelFormats;
11+
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
912
using Xunit;
1013

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

300+
public static TheoryData<string> GetAllTestImages()
301+
{
302+
IEnumerable<string> allImageFiles = Directory.EnumerateFiles(TestEnvironment.InputImagesDirectoryFullPath, "*.*", SearchOption.AllDirectories)
303+
.Where(s => !s.ToLower().EndsWith("txt"));
304+
var result = new TheoryData<string>();
305+
foreach (string path in allImageFiles)
306+
{
307+
result.Add(path);
308+
}
309+
310+
return result;
311+
}
312+
313+
[Theory]
314+
[MemberData(nameof(GetAllTestImages))]
315+
public void DecoderIntegrationTest(string testFileFullPath)
316+
{
317+
Image<Rgba32> expected = null;
318+
try
319+
{
320+
expected = Image.Load<Rgba32>(testFileFullPath);
321+
}
322+
catch
323+
{
324+
// The image is invalid
325+
return;
326+
}
327+
328+
using FileStream fs = File.OpenRead(testFileFullPath);
329+
using NonSeekableStream nonSeekableStream = new NonSeekableStream(fs);
330+
331+
var actual = Image.Load<Rgba32>(nonSeekableStream);
332+
333+
ImageComparer.Exact.VerifySimilarity(expected, actual);
334+
}
335+
297336
public static IEnumerable<object[]> CopyToData()
298337
{
299338
// Stream is positioned @ beginning of data

0 commit comments

Comments
 (0)