diff --git a/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs index 6cd3f4e7c..2305d57b4 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs @@ -56,8 +56,7 @@ namespace ImageSharp.Tests.Formats.Png // ms.Position = 0; // using (Image img2 = Image.Load(ms, new PngDecoder())) // { - ImageComparer.VerifySimilarity(image, img2, 0.03f); - // ImageComparer.CheckSimilarity(image, img2, 0.03f); + // ImageComparer.VerifySimilarity(image, img2, 0.03f); // } // } //} diff --git a/tests/ImageSharp.Tests/TestFile.cs b/tests/ImageSharp.Tests/TestFile.cs index 7fa5a9b4e..883911db2 100644 --- a/tests/ImageSharp.Tests/TestFile.cs +++ b/tests/ImageSharp.Tests/TestFile.cs @@ -27,7 +27,8 @@ namespace ImageSharp.Tests /// /// The formats directory, as lazy value /// - private static readonly string FormatsDirectory = TestEnvironment.GetInputImagesDirectoryFullPath(); + // ReSharper disable once InconsistentNaming + private static readonly Lazy formatsDirectory = new Lazy(TestEnvironment.GetInputImagesDirectoryFullPath); /// /// The image. diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs index 05e8c6136..f9eb57ffd 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs @@ -54,7 +54,7 @@ namespace ImageSharp.Tests if (!string.IsNullOrWhiteSpace(this.MemberName)) { Type type = this.MemberType ?? testMethod.DeclaringType; - Func accessor = this.GetPropertyAccessor(type) ?? this.GetFieldAccessor(type); + Func accessor = this.GetPropertyAccessor(type, this.MemberName) ?? this.GetFieldAccessor(type, this.MemberName); if (accessor != null) { @@ -156,12 +156,12 @@ namespace ImageSharp.Tests /// /// Gets the field accessor for the given type. /// - Func GetFieldAccessor(Type type) + protected Func GetFieldAccessor(Type type, string memberName) { FieldInfo fieldInfo = null; for (Type reflectionType = type; reflectionType != null; reflectionType = reflectionType.GetTypeInfo().BaseType) { - fieldInfo = reflectionType.GetRuntimeField(this.MemberName); + fieldInfo = reflectionType.GetRuntimeField(memberName); if (fieldInfo != null) break; } @@ -175,12 +175,12 @@ namespace ImageSharp.Tests /// /// Gets the property accessor for the given type. /// - Func GetPropertyAccessor(Type type) + protected Func GetPropertyAccessor(Type type, string memberName) { PropertyInfo propInfo = null; for (Type reflectionType = type; reflectionType != null; reflectionType = reflectionType.GetTypeInfo().BaseType) { - propInfo = reflectionType.GetRuntimeProperty(this.MemberName); + propInfo = reflectionType.GetRuntimeProperty(memberName); if (propInfo != null) { break; diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileCollectionAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileCollectionAttribute.cs index 1b37c45a9..575a1a0d7 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileCollectionAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileCollectionAttribute.cs @@ -38,18 +38,18 @@ namespace ImageSharp.Tests /// Triggers passing instances which read an image for each file being enumerated by the (static) test class field/property defined by enumeratorMemberName /// instances will be passed for each the pixel format defined by the pixelTypes parameter /// - /// The name of the static test class field/property enumerating the files + /// The name of the static test class field/property enumerating the files /// The member name for enumerating method parameters /// The requested pixel types /// Additional theory parameter values public WithFileCollectionAttribute( - string enumeratorMemberName, + string fileEnumeratorMemberName, string memberName, PixelTypes pixelTypes, params object[] additionalParameters) : base(memberName, pixelTypes, additionalParameters) { - this.fileEnumeratorMemberName = enumeratorMemberName; + this.fileEnumeratorMemberName = fileEnumeratorMemberName; } /// @@ -60,8 +60,8 @@ namespace ImageSharp.Tests /// The protected override IEnumerable GetAllFactoryMethodArgs(MethodInfo testMethod, Type factoryType) { - Func accessor = this.GetPropertyAccessor(testMethod.DeclaringType); - accessor = accessor ?? this.GetFieldAccessor(testMethod.DeclaringType); + Func accessor = this.GetPropertyAccessor(testMethod.DeclaringType, this.fileEnumeratorMemberName); + accessor = accessor ?? this.GetFieldAccessor(testMethod.DeclaringType, this.fileEnumeratorMemberName); var files = (IEnumerable)accessor(); return files.Select(f => new object[] { f }); @@ -69,52 +69,5 @@ namespace ImageSharp.Tests /// protected override string GetFactoryMethodName(MethodInfo testMethod) => "File"; - - /// - /// Gets the field accessor for the given type. - /// - private Func GetFieldAccessor(Type type) - { - FieldInfo fieldInfo = null; - for (Type reflectionType = type; - reflectionType != null; - reflectionType = reflectionType.GetTypeInfo().BaseType) - { - fieldInfo = reflectionType.GetRuntimeField(this.fileEnumeratorMemberName); - if (fieldInfo != null) - { - break; - } - } - - if (fieldInfo == null || !fieldInfo.IsStatic) - { - return null; - } - - return () => fieldInfo.GetValue(null); - } - - /// - /// Gets the property accessor for the given type. - /// - private Func GetPropertyAccessor(Type type) - { - PropertyInfo propInfo = null; - for (Type reflectionType = type; - reflectionType != null; - reflectionType = reflectionType.GetTypeInfo().BaseType) - { - propInfo = reflectionType.GetRuntimeProperty(this.fileEnumeratorMemberName); - if (propInfo != null) break; - } - - if (propInfo?.GetMethod == null || !propInfo.GetMethod.IsStatic) - { - return null; - } - - return () => propInfo.GetValue(null, null); - } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs b/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs index 16b1d1bf7..5a49a2917 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs @@ -127,20 +127,16 @@ namespace ImageSharp.Tests /// The image instance /// The requested extension /// Optional encoder - /// Optional encoder options public void SaveTestOutputFile( Image image, string extension = null, IImageEncoder encoder = null, - IEncoderOptions options = null, object settings = null) where TPixel : struct, IPixel { string path = this.GetTestOutputFileName(extension: extension, settings: settings); string extension1 = Path.GetExtension(path); - encoder = encoder ?? GetImageFormatByExtension(extension); - IImageFormat format = GetImageFormatByExtension(extension1); - + encoder = encoder ?? GetImageFormatByExtension(extension1); using (FileStream stream = File.OpenWrite(path)) { @@ -172,7 +168,7 @@ namespace ImageSharp.Tests private string GetTestOutputDir() { string testGroupName = Path.GetFileNameWithoutExtension(this.TestGroupName); - return CreateOutputDirectory(testGroupName); + return this.CreateOutputDirectory(testGroupName); } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/TestUtilities/Integration/ReferenceDecoder.cs b/tests/ImageSharp.Tests/TestUtilities/Integration/ReferenceDecoder.cs index 3e905cc07..0ed3fda29 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Integration/ReferenceDecoder.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Integration/ReferenceDecoder.cs @@ -11,7 +11,7 @@ namespace ImageSharp.Tests.TestUtilities.Integration { public static ReferenceDecoder Instance { get; } = new ReferenceDecoder(); - public Image Decode(Configuration configuration, Stream stream, IDecoderOptions options) + public Image Decode(Configuration configuration, Stream stream) where TPixel : struct, IPixel { using (var sourceBitmap = new System.Drawing.Bitmap(stream)) @@ -32,8 +32,6 @@ namespace ImageSharp.Tests.TestUtilities.Integration } return IntegrationTestUtils.FromSystemDrawingBitmap(convertedBitmap); } - - } } } diff --git a/tests/ImageSharp.Tests/TestUtilities/Integration/ReferencePngEncoder.cs b/tests/ImageSharp.Tests/TestUtilities/Integration/ReferencePngEncoder.cs index b206197db..3629f03e5 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Integration/ReferencePngEncoder.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Integration/ReferencePngEncoder.cs @@ -12,7 +12,7 @@ namespace ImageSharp.Tests.TestUtilities.Integration { public static ReferencePngEncoder Instance { get; } = new ReferencePngEncoder(); - public void Encode(Image image, Stream stream, IEncoderOptions options) + public void Encode(Image image, Stream stream) where TPixel : struct, IPixel { using (System.Drawing.Bitmap sdBitmap = IntegrationTestUtils.ToSystemDrawingBitmap(image))