Browse Source

looks like ApplyOilPaintFilterInBox() is failing with a very good reason

af/merge-core
Anton Firszov 9 years ago
parent
commit
878b3802fd
  1. 4
      tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs
  2. 17
      tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImagePixelsAreDifferentException.cs
  3. 2
      tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs
  4. 1
      tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs
  5. 11
      tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs

4
tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs

@ -22,7 +22,7 @@ namespace ImageSharp.Tests.Processing.Processors.Effects
[Theory]
[WithFileCollection(nameof(DefaultFiles), nameof(OilPaintValues), DefaultPixelType)]
public void ImageShouldApplyOilPaintFilter<TPixel>(TestImageProvider<TPixel> provider, int levels, int brushSize)
public void ApplyOilPaintFilter<TPixel>(TestImageProvider<TPixel> provider, int levels, int brushSize)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage())
@ -34,7 +34,7 @@ namespace ImageSharp.Tests.Processing.Processors.Effects
[Theory]
[WithFileCollection(nameof(DefaultFiles), nameof(OilPaintValues), DefaultPixelType)]
public void ImageShouldApplyOilPaintFilterInBox<TPixel>(TestImageProvider<TPixel> provider, int levels, int brushSize)
public void ApplyOilPaintFilterInBox<TPixel>(TestImageProvider<TPixel> provider, int levels, int brushSize)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())

17
tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImagePixelsAreDifferentException.cs

@ -10,9 +10,24 @@ namespace ImageSharp.Tests.TestUtilities.ImageComparison
public ImageSimilarityReport[] Reports { get; }
public ImagePixelsAreDifferentException(IEnumerable<ImageSimilarityReport> reports)
: base("Images are not similar enough! See 'Reports' for more details! ")
: base("Images are not similar enough!" + StringifyReports(reports))
{
this.Reports = reports.ToArray();
}
private static string StringifyReports(IEnumerable<ImageSimilarityReport> reports)
{
StringBuilder sb = new StringBuilder();
sb.Append(Environment.NewLine);
int i = 0;
foreach (ImageSimilarityReport r in reports)
{
sb.Append($"Report{i}: ");
sb.Append(r);
sb.Append(Environment.NewLine);
}
return sb.ToString();
}
}
}

2
tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs

@ -29,7 +29,7 @@
{
return this.IsEmpty ? "[SimilarImages]" : StringifyDifferences(this.Differences);
}
private static string StringifyDifferences(PixelDifference[] differences)
{
var sb = new StringBuilder();

1
tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs

@ -60,7 +60,6 @@ namespace ImageSharp.Tests
// TODO: Add multi-flag entries by rules defined in PackedPixelConverterHelper
Default = Rgba32,
// "All" is handled as a separate, individual case instead of using bitwise OR
All = 30
}

11
tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs

@ -115,10 +115,17 @@ namespace ImageSharp.Tests
{
using (Image<TPixel> clone = image.Clone())
{
ModifyPixel(clone, 0, 0, 2);
ModifyPixel(clone, 3, 1, 2);
var comparer = ImageComparer.Tolerant();
comparer.VerifySimilarity(image, clone);
ImagePixelsAreDifferentException ex = Assert.ThrowsAny<ImagePixelsAreDifferentException>(
() =>
{
comparer.VerifySimilarity(image, clone);
});
PixelDifference diff = ex.Reports.Single().Differences.Single();
Assert.Equal(new Point(3, 1), diff.Position);
}
}
}

Loading…
Cancel
Save