Browse Source

Refactors the huge copypastas with nicer loops

Former-commit-id: 9cb72c2f30b8cd3c54f194b3c2ba71273f52e575
Former-commit-id: bfa3813ddd77c460e024e6fde9e692b8e303a28e
af/merge-core
Thomas Broust 12 years ago
parent
commit
134c08511a
  1. 134
      src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs

134
src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs

@ -300,55 +300,27 @@ namespace ImageProcessor.UnitTests
{ {
Image original = (Image)imageFactory.Image.Clone(); Image original = (Image)imageFactory.Image.Clone();
imageFactory.Filter(MatrixFilters.BlackWhite); List<IMatrixFilter> filters = new List<IMatrixFilter>()
AssertImagesAreDifferent(original, imageFactory.Image, "because the bw filter operation should have been applied on {0}", imageFactory.ImagePath); {
imageFactory.Reset(); MatrixFilters.BlackWhite,
AssertImagesAreIdentical(original, imageFactory.Image, "because the image should be reset"); MatrixFilters.Comic,
MatrixFilters.Gotham,
imageFactory.Filter(MatrixFilters.Comic); MatrixFilters.GreyScale,
AssertImagesAreDifferent(original, imageFactory.Image, "because the comic filter operation should have been applied on {0}", imageFactory.ImagePath); MatrixFilters.HiSatch,
imageFactory.Reset(); MatrixFilters.Invert,
AssertImagesAreIdentical(original, imageFactory.Image, "because the image should be reset"); MatrixFilters.Lomograph,
MatrixFilters.LoSatch,
imageFactory.Filter(MatrixFilters.Gotham); MatrixFilters.Polaroid,
AssertImagesAreDifferent(original, imageFactory.Image, "because the gotham filter operation should have been applied on {0}", imageFactory.ImagePath); MatrixFilters.Sepia
imageFactory.Reset(); };
AssertImagesAreIdentical(original, imageFactory.Image, "because the image should be reset");
foreach (IMatrixFilter filter in filters)
imageFactory.Filter(MatrixFilters.GreyScale); {
AssertImagesAreDifferent(original, imageFactory.Image, "because the greyscale filter operation should have been applied on {0}", imageFactory.ImagePath); imageFactory.Filter(filter);
imageFactory.Reset(); AssertImagesAreDifferent(original, imageFactory.Image, "because the filter operation should have been applied on {0}", imageFactory.ImagePath);
AssertImagesAreIdentical(original, imageFactory.Image, "because the image should be reset"); imageFactory.Reset();
AssertImagesAreIdentical(original, imageFactory.Image, "because the image should be reset");
imageFactory.Filter(MatrixFilters.HiSatch); }
AssertImagesAreDifferent(original, imageFactory.Image, "because the hisatch operation should have been applied on {0}", imageFactory.ImagePath);
imageFactory.Reset();
AssertImagesAreIdentical(original, imageFactory.Image, "because the image should be reset");
imageFactory.Filter(MatrixFilters.Invert);
AssertImagesAreDifferent(original, imageFactory.Image, "because the invert filter operation should have been applied on {0}", imageFactory.ImagePath);
imageFactory.Reset();
AssertImagesAreIdentical(original, imageFactory.Image, "because the image should be reset");
imageFactory.Filter(MatrixFilters.Lomograph);
AssertImagesAreDifferent(original, imageFactory.Image, "because the lomo filter operation should have been applied on {0}", imageFactory.ImagePath);
imageFactory.Reset();
AssertImagesAreIdentical(original, imageFactory.Image, "because the image should be reset");
imageFactory.Filter(MatrixFilters.LoSatch);
AssertImagesAreDifferent(original, imageFactory.Image, "because the losatch filter operation should have been applied on {0}", imageFactory.ImagePath);
imageFactory.Reset();
AssertImagesAreIdentical(original, imageFactory.Image, "because the image should be reset");
imageFactory.Filter(MatrixFilters.Polaroid);
AssertImagesAreDifferent(original, imageFactory.Image, "because the polaroid filter operation should have been applied on {0}", imageFactory.ImagePath);
imageFactory.Reset();
AssertImagesAreIdentical(original, imageFactory.Image, "because the image should be reset");
imageFactory.Filter(MatrixFilters.Sepia);
AssertImagesAreDifferent(original, imageFactory.Image, "because the sepia filter operation should have been applied on {0}", imageFactory.ImagePath);
imageFactory.Reset();
AssertImagesAreIdentical(original, imageFactory.Image, "because the image should be reset");
} }
} }
@ -562,50 +534,26 @@ namespace ImageProcessor.UnitTests
{ {
Image original = (Image)imageFactory.Image.Clone(); Image original = (Image)imageFactory.Image.Clone();
imageFactory.DetectEdges(new KayyaliEdgeFilter()); List<IEdgeFilter> filters = new List<IEdgeFilter>()
AssertImagesAreDifferent(original, imageFactory.Image, "because the kayyali edge operation should have been applied on {0}", imageFactory.ImagePath); {
imageFactory.Reset(); new KayyaliEdgeFilter(),
AssertImagesAreIdentical(original, imageFactory.Image, "because the image should be reset"); new KirschEdgeFilter(),
new Laplacian3X3EdgeFilter(),
imageFactory.DetectEdges(new KirschEdgeFilter()); new Laplacian5X5EdgeFilter(),
AssertImagesAreDifferent(original, imageFactory.Image, "because the kirsch edge operation should have been applied on {0}", imageFactory.ImagePath); new LaplacianOfGaussianEdgeFilter(),
imageFactory.Reset(); new PrewittEdgeFilter(),
AssertImagesAreIdentical(original, imageFactory.Image, "because the image should be reset"); new RobertsCrossEdgeFilter(),
new ScharrEdgeFilter(),
imageFactory.DetectEdges(new Laplacian3X3EdgeFilter()); new SobelEdgeFilter()
AssertImagesAreDifferent(original, imageFactory.Image, "because the laplacian 3x3 edge operation should have been applied on {0}", imageFactory.ImagePath); };
imageFactory.Reset();
AssertImagesAreIdentical(original, imageFactory.Image, "because the image should be reset"); foreach (IEdgeFilter filter in filters)
{
imageFactory.DetectEdges(new Laplacian5X5EdgeFilter()); imageFactory.DetectEdges(filter);
AssertImagesAreDifferent(original, imageFactory.Image, "because the laplacian 5x5 edge operation should have been applied on {0}", imageFactory.ImagePath); AssertImagesAreDifferent(original, imageFactory.Image, "because the edge operation should have been applied on {0}", imageFactory.ImagePath);
imageFactory.Reset(); imageFactory.Reset();
AssertImagesAreIdentical(original, imageFactory.Image, "because the image should be reset"); AssertImagesAreIdentical(original, imageFactory.Image, "because the image should be reset");
}
imageFactory.DetectEdges(new LaplacianOfGaussianEdgeFilter());
AssertImagesAreDifferent(original, imageFactory.Image, "because the laplacian gaussian edge operation should have been applied on {0}", imageFactory.ImagePath);
imageFactory.Reset();
AssertImagesAreIdentical(original, imageFactory.Image, "because the image should be reset");
imageFactory.DetectEdges(new PrewittEdgeFilter());
AssertImagesAreDifferent(original, imageFactory.Image, "because the prewitt edge operation should have been applied on {0}", imageFactory.ImagePath);
imageFactory.Reset();
AssertImagesAreIdentical(original, imageFactory.Image, "because the image should be reset");
imageFactory.DetectEdges(new RobertsCrossEdgeFilter());
AssertImagesAreDifferent(original, imageFactory.Image, "because the roberts edge operation should have been applied on {0}", imageFactory.ImagePath);
imageFactory.Reset();
AssertImagesAreIdentical(original, imageFactory.Image, "because the image should be reset");
imageFactory.DetectEdges(new ScharrEdgeFilter());
AssertImagesAreDifferent(original, imageFactory.Image, "because the scharr edge operation should have been applied on {0}", imageFactory.ImagePath);
imageFactory.Reset();
AssertImagesAreIdentical(original, imageFactory.Image, "because the image should be reset");
imageFactory.DetectEdges(new SobelEdgeFilter());
AssertImagesAreDifferent(original, imageFactory.Image, "because the sobel edge operation should have been applied on {0}", imageFactory.ImagePath);
imageFactory.Reset();
AssertImagesAreIdentical(original, imageFactory.Image, "because the image should be reset");
} }
} }

Loading…
Cancel
Save