Browse Source

Disable caching in the FileProvider for the 32bit build.

pull/589/head
Dirk Lemstra 8 years ago
parent
commit
4a0e0e159d
  1. 25
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs
  2. 12
      tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs

25
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<TPixel> cachedImage = cache.GetOrAdd(
key,
fn =>
{
var testFile = TestFile.Create(this.FilePath);
return Image.Load<TPixel>(this.Configuration, testFile.Bytes, decoder);
});
var key = new Key(this.PixelType, this.FilePath, decoder);
Image<TPixel> 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<TPixel> LoadImage(IImageDecoder decoder)
{
var testFile = TestFile.Create(this.FilePath);
return Image.Load<TPixel>(this.Configuration, testFile.Bytes, decoder);
}
}
public static string GetFilePathOrNull(ITestImageProvider provider)

12
tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs

@ -121,6 +121,12 @@ namespace SixLabors.ImageSharp.Tests
public void GetImage_WithCustomParameterlessDecoder_ShouldUtilizeCache<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
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<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
if (!TestEnvironment.Is64BitProcess)
{
// We don't cache with the 32 bit build.
return;
}
Assert.NotNull(provider.Utility.SourceFileOrDescription);
TestDecoderWithParameters.DoTestThreadSafe(() =>

Loading…
Cancel
Save