@@ -297,43 +297,51 @@ public void CopyTo(Stream source, byte[] expected)
297297 Assert . Equal ( expected , destination . ToArray ( ) ) ;
298298 }
299299
300- public static TheoryData < string > GetAllTestImages ( )
300+ public static IEnumerable < string > GetAllTestImages ( )
301301 {
302302 IEnumerable < string > allImageFiles = Directory . EnumerateFiles ( TestEnvironment . InputImagesDirectoryFullPath , "*.*" , SearchOption . AllDirectories )
303303 . Where ( s => ! s . EndsWith ( "txt" , StringComparison . OrdinalIgnoreCase ) ) ;
304- var result = new TheoryData < string > ( ) ;
304+
305+ var result = new List < string > ( ) ;
305306 foreach ( string path in allImageFiles )
306307 {
307- result . Add ( path ) ;
308+ result . Add ( path . Substring ( TestEnvironment . InputImagesDirectoryFullPath . Length ) ) ;
308309 }
309310
310311 return result ;
311312 }
312313
314+ public static IEnumerable < string > AllTestImages = GetAllTestImages ( ) ;
315+
313316 [ Theory ]
314- [ MemberData ( nameof ( GetAllTestImages ) ) ]
315- public void DecoderIntegrationTest ( string testFileFullPath )
317+ [ WithFileCollection ( nameof ( AllTestImages ) , PixelTypes . Rgba32 ) ]
318+ public void DecoderIntegrationTest < TPixel > ( TestImageProvider < TPixel > provider )
319+ where TPixel : unmanaged, IPixel < TPixel >
316320 {
317321 if ( ! TestEnvironment . Is64BitProcess )
318322 {
319323 return ;
320324 }
321325
322- Image < Rgba32 > expected ;
326+ Image < TPixel > expected ;
323327 try
324328 {
325- expected = Image . Load < Rgba32 > ( testFileFullPath ) ;
329+ expected = provider . GetImage ( ) ;
326330 }
327331 catch
328332 {
329333 // The image is invalid
330334 return ;
331335 }
332336
333- using FileStream fs = File . OpenRead ( testFileFullPath ) ;
337+ string fullPath = Path . Combine (
338+ TestEnvironment . InputImagesDirectoryFullPath ,
339+ ( ( TestImageProvider < TPixel > . FileProvider ) provider ) . FilePath ) ;
340+
341+ using FileStream fs = File . OpenRead ( fullPath ) ;
334342 using var nonSeekableStream = new NonSeekableStream ( fs ) ;
335343
336- var actual = Image . Load < Rgba32 > ( nonSeekableStream ) ;
344+ var actual = Image . Load < TPixel > ( nonSeekableStream ) ;
337345
338346 ImageComparer . Exact . VerifySimilarity ( expected , actual ) ;
339347 }
0 commit comments