Browse Source

Update resize tests [skip ci]

Former-commit-id: 93be57e7c664506115d8dcb098fd6f404f201332
Former-commit-id: 2dfeef90de32ea89950cf8111f3df1778c6b89ee
Former-commit-id: 1345f3f4b2dc14307f88fe9f4c1f0e477efb7054
af/merge-core
James Jackson-South 10 years ago
parent
commit
0c63d46c84
  1. 2
      tests/ImageProcessorCore.Benchmarks/Samplers/Resize.cs
  2. 65
      tests/ImageProcessorCore.Tests/Processors/Samplers/ResizeTests.cs

2
tests/ImageProcessorCore.Benchmarks/Samplers/Resize.cs

@ -38,7 +38,7 @@
}
[Benchmark(Description = "ImageProcessorCore Compand Resize")]
public CoreSize ResizeCore()
public CoreSize ResizeCoreCompand()
{
CoreImage image = new CoreImage(2000, 2000);
image.Resize(400, 400, true);

65
tests/ImageProcessorCore.Tests/Processors/Samplers/ResizeTests.cs

@ -58,10 +58,11 @@ namespace ImageProcessorCore.Tests
}
}
[Fact]
public void ImageShouldResizeWidthAndKeepAspect()
[Theory]
[MemberData("ReSamplers")]
public void ImageShouldResizeWidthAndKeepAspect(string name, IResampler sampler)
{
const string name = "FixedWidth";
name = name + "-FixedWidth";
if (!Directory.Exists(path))
{
@ -77,17 +78,18 @@ namespace ImageProcessorCore.Tests
Image image = new Image(stream);
using (FileStream output = File.OpenWrite($"{path}/{filename}"))
{
image.Resize(image.Width / 3, 0, new TriangleResampler(), false, this.ProgressUpdate)
image.Resize(image.Width / 3, 0, sampler, false, this.ProgressUpdate)
.Save(output);
}
}
}
}
[Fact]
public void ImageShouldResizeHeightAndKeepAspect()
[Theory]
[MemberData("ReSamplers")]
public void ImageShouldResizeHeightAndKeepAspect(string name, IResampler sampler)
{
const string name = "FixedHeight";
name = name + "-FixedHeight";
if (!Directory.Exists(path))
{
@ -103,17 +105,18 @@ namespace ImageProcessorCore.Tests
Image image = new Image(stream);
using (FileStream output = File.OpenWrite($"{path}/{filename}"))
{
image.Resize(0, image.Height / 3, new TriangleResampler(), false, this.ProgressUpdate)
image.Resize(0, image.Height / 3, sampler, false, this.ProgressUpdate)
.Save(output);
}
}
}
}
[Fact]
public void ImageShouldResizeWithCropMode()
[Theory]
[MemberData("ReSamplers")]
public void ImageShouldResizeWithCropMode(string name, IResampler sampler)
{
const string name = "Crop";
name = name + "-Crop";
if (!Directory.Exists(path))
{
@ -131,6 +134,7 @@ namespace ImageProcessorCore.Tests
{
ResizeOptions options = new ResizeOptions()
{
Sampler = sampler,
Size = new Size(image.Width / 2, image.Height)
};
@ -141,10 +145,11 @@ namespace ImageProcessorCore.Tests
}
}
[Fact]
public void ImageShouldResizeWithPadMode()
[Theory]
[MemberData("ReSamplers")]
public void ImageShouldResizeWithPadMode(string name, IResampler sampler)
{
const string name = "Pad";
name = name + "-Pad";
if (!Directory.Exists(path))
{
@ -173,10 +178,11 @@ namespace ImageProcessorCore.Tests
}
}
[Fact]
public void ImageShouldResizeWithBoxPadMode()
[Theory]
[MemberData("ReSamplers")]
public void ImageShouldResizeWithBoxPadMode(string name, IResampler sampler)
{
const string name = "BoxPad";
name = name + "-BoxPad";
if (!Directory.Exists(path))
{
@ -194,6 +200,7 @@ namespace ImageProcessorCore.Tests
{
ResizeOptions options = new ResizeOptions()
{
Sampler = sampler,
Size = new Size(image.Width + 200, image.Height + 200),
Mode = ResizeMode.BoxPad
};
@ -205,10 +212,11 @@ namespace ImageProcessorCore.Tests
}
}
[Fact]
public void ImageShouldResizeWithMaxMode()
[Theory]
[MemberData("ReSamplers")]
public void ImageShouldResizeWithMaxMode(string name, IResampler sampler)
{
const string name = "Max";
name = name + "Max";
if (!Directory.Exists(path))
{
@ -226,6 +234,7 @@ namespace ImageProcessorCore.Tests
{
ResizeOptions options = new ResizeOptions()
{
Sampler = sampler,
Size = new Size(300, 300),
Mode = ResizeMode.Max
};
@ -237,10 +246,11 @@ namespace ImageProcessorCore.Tests
}
}
[Fact]
public void ImageShouldResizeWithMinMode()
[Theory]
[MemberData("ReSamplers")]
public void ImageShouldResizeWithMinMode(string name, IResampler sampler)
{
const string name = "Min";
name = name + "-Min";
if (!Directory.Exists(path))
{
@ -258,6 +268,7 @@ namespace ImageProcessorCore.Tests
{
ResizeOptions options = new ResizeOptions()
{
Sampler = sampler,
Size = new Size(image.Width - 50, image.Height - 25),
Mode = ResizeMode.Min
};
@ -269,10 +280,11 @@ namespace ImageProcessorCore.Tests
}
}
[Fact]
public void ImageShouldResizeWithStretchMode()
[Theory]
[MemberData("ReSamplers")]
public void ImageShouldResizeWithStretchMode(string name, IResampler sampler)
{
const string name = "Stretch";
name = name + "Stretch";
if (!Directory.Exists(path))
{
@ -290,6 +302,7 @@ namespace ImageProcessorCore.Tests
{
ResizeOptions options = new ResizeOptions()
{
Sampler = sampler,
Size = new Size(image.Width - 200, image.Height),
Mode = ResizeMode.Stretch
};

Loading…
Cancel
Save