diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs index 2dbddcc8f1..6475547a06 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs @@ -55,7 +55,7 @@ namespace SixLabors.ImageSharp.Tests public bool Equals(Key other) { - if (ReferenceEquals(null, other)) return false; + if (other is null) return false; if (ReferenceEquals(this, other)) return true; if (!this.commonValues.Equals(other.commonValues)) return false; @@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Tests public override bool Equals(object obj) { - if (ReferenceEquals(null, obj)) return false; + if (obj is null) return false; if (ReferenceEquals(this, obj)) return true; if (obj.GetType() != this.GetType()) return false; return this.Equals((Key)obj); @@ -133,15 +133,14 @@ namespace SixLabors.ImageSharp.Tests { Guard.NotNull(decoder, nameof(decoder)); - Key key = new Key(this.PixelType, this.FilePath, decoder); + if (!TestEnvironment.Is64BitProcess) + { + return LoadImage(decoder); + } - Image cachedImage = cache.GetOrAdd( - key, - fn => - { - var testFile = TestFile.Create(this.FilePath); - return Image.Load(this.Configuration, testFile.Bytes, decoder); - }); + var key = new Key(this.PixelType, this.FilePath, decoder); + + Image cachedImage = cache.GetOrAdd(key, fn => { return LoadImage(decoder); }); return cachedImage.Clone(); } @@ -158,6 +157,12 @@ namespace SixLabors.ImageSharp.Tests base.Serialize(info); info.AddValue("path", this.FilePath); } + + private Image LoadImage(IImageDecoder decoder) + { + var testFile = TestFile.Create(this.FilePath); + return Image.Load(this.Configuration, testFile.Bytes, decoder); + } } public static string GetFilePathOrNull(ITestImageProvider provider) diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs index 494c56dea2..c5d9a72481 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs @@ -121,6 +121,12 @@ namespace SixLabors.ImageSharp.Tests public void GetImage_WithCustomParameterlessDecoder_ShouldUtilizeCache(TestImageProvider provider) where TPixel : struct, IPixel { + if (!TestEnvironment.Is64BitProcess) + { + // We don't cache with the 32 bit build. + return; + } + Assert.NotNull(provider.Utility.SourceFileOrDescription); TestDecoder.DoTestThreadSafe(() => @@ -179,6 +185,12 @@ namespace SixLabors.ImageSharp.Tests public void GetImage_WithCustomParametricDecoder_ShouldUtilizeCache_WhenParametersAreEqual(TestImageProvider provider) where TPixel : struct, IPixel { + if (!TestEnvironment.Is64BitProcess) + { + // We don't cache with the 32 bit build. + return; + } + Assert.NotNull(provider.Utility.SourceFileOrDescription); TestDecoderWithParameters.DoTestThreadSafe(() =>