|
4 | 4 | using System; |
5 | 5 | using System.Collections.Generic; |
6 | 6 | using System.IO; |
| 7 | +using System.Linq; |
7 | 8 | using SixLabors.ImageSharp.IO; |
8 | 9 | using SixLabors.ImageSharp.Memory; |
| 10 | +using SixLabors.ImageSharp.PixelFormats; |
| 11 | +using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; |
9 | 12 | using Xunit; |
10 | 13 |
|
11 | 14 | namespace SixLabors.ImageSharp.Tests.IO |
@@ -294,6 +297,42 @@ public void CopyTo(Stream source, byte[] expected) |
294 | 297 | Assert.Equal(expected, destination.ToArray()); |
295 | 298 | } |
296 | 299 |
|
| 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 | + |
297 | 336 | public static IEnumerable<object[]> CopyToData() |
298 | 337 | { |
299 | 338 | // Stream is positioned @ beginning of data |
|
0 commit comments