Browse Source

Format tests

pull/541/head
Jason Nelson 8 years ago
parent
commit
53045ff357
  1. 10
      tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs
  2. 4
      tests/ImageSharp.Tests/BaseImageOperationsExtensionTest.cs
  3. 8
      tests/ImageSharp.Tests/Colorspaces/CieLabAndCieLchConversionTests.cs
  4. 4
      tests/ImageSharp.Tests/Colorspaces/CieLuvAndCieLchuvConversionTests.cs
  5. 10
      tests/ImageSharp.Tests/Colorspaces/CieXyzAndCieLabConversionTest.cs
  6. 8
      tests/ImageSharp.Tests/Colorspaces/CieXyzAndCieLuvConversionTest.cs
  7. 6
      tests/ImageSharp.Tests/Colorspaces/CieXyzAndCieXyyConversionTest.cs
  8. 12
      tests/ImageSharp.Tests/Colorspaces/CieXyzAndHunterLabConversionTest.cs
  9. 8
      tests/ImageSharp.Tests/Colorspaces/CieXyzAndLmsConversionTest.cs
  10. 30
      tests/ImageSharp.Tests/Colorspaces/ColorConverterAdaptTest.cs
  11. 14
      tests/ImageSharp.Tests/Colorspaces/RgbAndCieXyzConversionTest.cs
  12. 4
      tests/ImageSharp.Tests/Colorspaces/RgbAndCmykConversionTest.cs
  13. 4
      tests/ImageSharp.Tests/Colorspaces/RgbAndHslConversionTest.cs
  14. 4
      tests/ImageSharp.Tests/Colorspaces/RgbAndHsvConversionTest.cs
  15. 4
      tests/ImageSharp.Tests/Colorspaces/RgbAndYCbCrConversionTest.cs
  16. 2
      tests/ImageSharp.Tests/Common/ConstantsTests.cs
  17. 18
      tests/ImageSharp.Tests/Common/SimdUtilsTests.cs
  18. 15
      tests/ImageSharp.Tests/ComplexIntegrationTests.cs
  19. 184
      tests/ImageSharp.Tests/ConfigurationTests.cs
  20. 8
      tests/ImageSharp.Tests/Drawing/BeziersTests.cs
  21. 2
      tests/ImageSharp.Tests/Drawing/DrawImageTest.cs
  22. 1
      tests/ImageSharp.Tests/Drawing/DrawPathTests.cs
  23. 12
      tests/ImageSharp.Tests/Drawing/FillPatternTests.cs
  24. 4
      tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs
  25. 5
      tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs
  26. 23
      tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs
  27. 28
      tests/ImageSharp.Tests/Drawing/LineTests.cs
  28. 1
      tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs
  29. 3
      tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs
  30. 5
      tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs
  31. 29
      tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs
  32. 9
      tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs
  33. 4
      tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs
  34. 2
      tests/ImageSharp.Tests/Drawing/Text/DrawText.cs
  35. 2
      tests/ImageSharp.Tests/Drawing/Text/OutputText.cs
  36. 9
      tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs
  37. 8
      tests/ImageSharp.Tests/IO/LocalFileSystem.cs
  38. 4
      tests/ImageSharp.Tests/ImageOperationTests.cs
  39. 24
      tests/ImageSharp.Tests/Numerics/RationalTests.cs
  40. 25
      tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs
  41. 12
      tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs
  42. 9
      tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs
  43. 6
      tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs
  44. 9
      tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs
  45. 5
      tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs
  46. 7
      tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs
  47. 7
      tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs
  48. 8
      tests/ImageSharp.Tests/Processing/Filters/BlackWhiteTest.cs
  49. 7
      tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs
  50. 11
      tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs
  51. 8
      tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs
  52. 8
      tests/ImageSharp.Tests/Processing/Filters/HueTest.cs
  53. 7
      tests/ImageSharp.Tests/Processing/Filters/InvertTest.cs
  54. 7
      tests/ImageSharp.Tests/Processing/Filters/KodachromeTest.cs
  55. 6
      tests/ImageSharp.Tests/Processing/Filters/OpacityTest.cs
  56. 8
      tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs
  57. 7
      tests/ImageSharp.Tests/Processing/Filters/SaturateTest.cs
  58. 7
      tests/ImageSharp.Tests/Processing/Filters/SepiaTest.cs
  59. 13
      tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs
  60. 7
      tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs
  61. 7
      tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianBlurTest.cs
  62. 6
      tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianSharpenTest.cs
  63. 3
      tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs
  64. 2
      tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs
  65. 6
      tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs
  66. 6
      tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs
  67. 1
      tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs
  68. 7
      tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs
  69. 9
      tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs
  70. 8
      tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs
  71. 7
      tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs
  72. 6
      tests/ImageSharp.Tests/Processing/Transforms/RotateTests.cs
  73. 6
      tests/ImageSharp.Tests/Processing/Transforms/SkewTest.cs
  74. 4
      tests/ImageSharp.Tests/Processing/Transforms/TransformsHelpersTest.cs
  75. 13
      tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs
  76. 2
      tests/ImageSharp.Tests/TestDataIcc/IccTestDataArray.cs
  77. 7
      tests/ImageSharp.Tests/TestFileSystem.cs
  78. 8
      tests/ImageSharp.Tests/TestFont.cs
  79. 2
      tests/ImageSharp.Tests/TestFormat.cs
  80. 10
      tests/ImageSharp.Tests/TestUtilities/ArrayHelper.cs
  81. 18
      tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs
  82. 13
      tests/ImageSharp.Tests/TestUtilities/ImageComparison/Exceptions/ImageDifferenceIsOverThresholdException.cs
  83. 14
      tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs
  84. 5
      tests/ImageSharp.Tests/TestUtilities/ImageComparison/PixelDifference.cs
  85. 26
      tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs
  86. 2
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs
  87. 4
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs
  88. 9
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs
  89. 5
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs
  90. 2
      tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs
  91. 3
      tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceDecoder.cs
  92. 5
      tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceEncoder.cs
  93. 52
      tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs
  94. 1
      tests/ImageSharp.Tests/TestUtilities/TestPixel.cs
  95. 2
      tests/ImageSharp.Tests/TestUtilities/TestType.cs
  96. 8
      tests/ImageSharp.Tests/TestUtilities/TestUtils.cs
  97. 8
      tests/ImageSharp.Tests/TestUtilities/TestVector4.cs
  98. 15
      tests/ImageSharp.Tests/TestUtilities/Tests/GroupOutputTests.cs
  99. 36
      tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs
  100. 21
      tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceCodecTests.cs

10
tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs

@ -1,15 +1,13 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using Xunit;
using SixLabors.ImageSharp.Advanced;
using System.Runtime.CompilerServices;
// ReSharper disable InconsistentNaming
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Advanced
{
using SixLabors.ImageSharp.PixelFormats;
public class AdvancedImageExtensionsTests
{
[Theory]
@ -19,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Advanced
{
using (Image<TPixel> image = provider.GetImage())
{
TPixel[] targetBuffer = new TPixel[image.Width * image.Height];
var targetBuffer = new TPixel[image.Width * image.Height];
ref byte source = ref Unsafe.As<TPixel, byte>(ref targetBuffer[0]);
ref byte dest = ref Unsafe.As<TPixel, byte>(ref image.DangerousGetPinnableReferenceToPixelBuffer());

4
tests/ImageSharp.Tests/BaseImageOperationsExtensionTest.cs

@ -1,10 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using System.Collections.Generic;
using System.Text;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.Primitives;

8
tests/ImageSharp.Tests/Colorspaces/CieLabAndCieLchConversionTests.cs

@ -36,10 +36,10 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Lch_to_Lab(float l, float c, float h, float l2, float a, float b)
{
// Arrange
CieLch input = new CieLch(l, c, h);
var input = new CieLch(l, c, h);
// Act
CieLab output = Converter.ToCieLab(input);
var output = Converter.ToCieLab(input);
// Assert
Assert.Equal(l2, output.L, FloatRoundingComparer);
@ -62,10 +62,10 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Lab_to_LCHab(float l, float a, float b, float l2, float c, float h)
{
// Arrange
CieLab input = new CieLab(l, a, b);
var input = new CieLab(l, a, b);
// Act
CieLch output = Converter.ToCieLch(input);
var output = Converter.ToCieLch(input);
// Assert
Assert.Equal(l2, output.L, FloatRoundingComparer);

4
tests/ImageSharp.Tests/Colorspaces/CieLuvAndCieLchuvConversionTests.cs

@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Lchuv_to_Luv(float l, float c, float h, float l2, float u, float v)
{
// Arrange
CieLchuv input = new CieLchuv(l, c, h);
var input = new CieLchuv(l, c, h);
// Act
CieLuv output = Converter.ToCieLuv(input);
@ -63,7 +63,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Luv_to_LCHuv(float l, float u, float v, float l2, float c, float h)
{
// Arrange
CieLuv input = new CieLuv(l, u, v);
var input = new CieLuv(l, u, v);
// Act
CieLchuv output = Converter.ToCieLchuv(input);

10
tests/ImageSharp.Tests/Colorspaces/CieXyzAndCieLabConversionTest.cs

@ -34,8 +34,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Lab_to_Xyz(float l, float a, float b, float x, float y, float z)
{
// Arrange
CieLab input = new CieLab(l, a, b, Illuminants.D65);
ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65 };
var input = new CieLab(l, a, b, Illuminants.D65);
var converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65 };
// Act
CieXyz output = converter.ToCieXyz(input);
@ -59,11 +59,11 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Xyz_to_Lab(float x, float y, float z, float l, float a, float b)
{
// Arrange
CieXyz input = new CieXyz(x, y, z);
ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65 };
var input = new CieXyz(x, y, z);
var converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65 };
// Act
CieLab output = converter.ToCieLab(input);
var output = converter.ToCieLab(input);
// Assert
Assert.Equal(l, output.L, FloatRoundingComparer);

8
tests/ImageSharp.Tests/Colorspaces/CieXyzAndCieLuvConversionTest.cs

@ -33,8 +33,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Luv_to_Xyz(float l, float u, float v, float x, float y, float z)
{
// Arrange
CieLuv input = new CieLuv(l, u, v, Illuminants.D65);
ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65 };
var input = new CieLuv(l, u, v, Illuminants.D65);
var converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65 };
// Act
CieXyz output = converter.ToCieXyz(input);
@ -58,8 +58,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Xyz_to_Luv(float x, float y, float z, float l, float u, float v)
{
// Arrange
CieXyz input = new CieXyz(x, y, z);
ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65 };
var input = new CieXyz(x, y, z);
var converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65 };
// Act
CieLuv output = converter.ToCieLuv(input);

6
tests/ImageSharp.Tests/Colorspaces/CieXyzAndCieXyyConversionTest.cs

@ -28,8 +28,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
[InlineData(0, 0, 0, 0.538842, 0.000000, 0.000000)]
public void Convert_xyY_to_XYZ(float xyzX, float xyzY, float xyzZ, float x, float y, float yl)
{
// Arrange
CieXyy input = new CieXyy(x, y, yl);
var input = new CieXyy(x, y, yl);
// Act
CieXyz output = Converter.ToCieXyz(input);
@ -47,8 +46,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
[InlineData(0.231809, 0, 0.077528, 0.749374, 0.000000, 0.000000)]
public void Convert_XYZ_to_xyY(float xyzX, float xyzY, float xyzZ, float x, float y, float yl)
{
// Arrange
CieXyz input = new CieXyz(xyzX, xyzY, xyzZ);
var input = new CieXyz(xyzX, xyzY, xyzZ);
// Act
CieXyy output = Converter.ToCieXyy(input);

12
tests/ImageSharp.Tests/Colorspaces/CieXyzAndHunterLabConversionTest.cs

@ -28,8 +28,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_HunterLab_to_Xyz(float l, float a, float b, float x, float y, float z)
{
// Arrange
HunterLab input = new HunterLab(l, a, b);
ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.C };
var input = new HunterLab(l, a, b);
var converter = new ColorSpaceConverter { WhitePoint = Illuminants.C };
// Act
CieXyz output = converter.ToCieXyz(input);
@ -49,8 +49,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_HunterLab_to_Xyz_D65(float l, float a, float b, float x, float y, float z)
{
// Arrange
HunterLab input = new HunterLab(l, a, b);
ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65 };
var input = new HunterLab(l, a, b);
var converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65 };
// Act
CieXyz output = converter.ToCieXyz(input);
@ -70,8 +70,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Xyz_D65_to_HunterLab(float x, float y, float z, float l, float a, float b)
{
// Arrange
CieXyz input = new CieXyz(x, y, z);
ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65 };
var input = new CieXyz(x, y, z);
var converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65 };
// Act
HunterLab output = converter.ToHunterLab(input);

8
tests/ImageSharp.Tests/Colorspaces/CieXyzAndLmsConversionTest.cs

@ -31,8 +31,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Lms_to_CieXyz(float l, float m, float s, float x, float y, float z)
{
// Arrange
Lms input = new Lms(l, m, s);
ColorSpaceConverter converter = new ColorSpaceConverter();
var input = new Lms(l, m, s);
var converter = new ColorSpaceConverter();
// Act
CieXyz output = converter.ToCieXyz(input);
@ -56,8 +56,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_CieXyz_to_Lms(float x, float y, float z, float l, float m, float s)
{
// Arrange
CieXyz input = new CieXyz(x, y, z);
ColorSpaceConverter converter = new ColorSpaceConverter();
var input = new CieXyz(x, y, z);
var converter = new ColorSpaceConverter();
// Act
Lms output = converter.ToLms(input);

30
tests/ImageSharp.Tests/Colorspaces/ColorConverterAdaptTest.cs

@ -28,9 +28,9 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Adapt_RGB_WideGamutRGB_To_sRGB(float r1, float g1, float b1, float r2, float g2, float b2)
{
// Arrange
Rgb input = new Rgb(r1, g1, b1, RgbWorkingSpaces.WideGamutRgb);
Rgb expectedOutput = new Rgb(r2, g2, b2, RgbWorkingSpaces.SRgb);
ColorSpaceConverter converter = new ColorSpaceConverter { TargetRgbWorkingSpace = RgbWorkingSpaces.SRgb };
var input = new Rgb(r1, g1, b1, RgbWorkingSpaces.WideGamutRgb);
var expectedOutput = new Rgb(r2, g2, b2, RgbWorkingSpaces.SRgb);
var converter = new ColorSpaceConverter { TargetRgbWorkingSpace = RgbWorkingSpaces.SRgb };
// Action
Rgb output = converter.Adapt(input);
@ -49,9 +49,9 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Adapt_RGB_SRGB_To_WideGamutRGB(float r1, float g1, float b1, float r2, float g2, float b2)
{
// Arrange
Rgb input = new Rgb(r1, g1, b1, RgbWorkingSpaces.SRgb);
Rgb expectedOutput = new Rgb(r2, g2, b2, RgbWorkingSpaces.WideGamutRgb);
ColorSpaceConverter converter = new ColorSpaceConverter { TargetRgbWorkingSpace = RgbWorkingSpaces.WideGamutRgb };
var input = new Rgb(r1, g1, b1, RgbWorkingSpaces.SRgb);
var expectedOutput = new Rgb(r2, g2, b2, RgbWorkingSpaces.WideGamutRgb);
var converter = new ColorSpaceConverter { TargetRgbWorkingSpace = RgbWorkingSpaces.WideGamutRgb };
// Action
Rgb output = converter.Adapt(input);
@ -69,9 +69,9 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Adapt_Lab_D50_To_D65(float l1, float a1, float b1, float l2, float a2, float b2)
{
// Arrange
CieLab input = new CieLab(l1, a1, b1, Illuminants.D65);
CieLab expectedOutput = new CieLab(l2, a2, b2);
ColorSpaceConverter converter = new ColorSpaceConverter { TargetLabWhitePoint = Illuminants.D50 };
var input = new CieLab(l1, a1, b1, Illuminants.D65);
var expectedOutput = new CieLab(l2, a2, b2);
var converter = new ColorSpaceConverter { TargetLabWhitePoint = Illuminants.D50 };
// Action
CieLab output = converter.Adapt(input);
@ -110,9 +110,9 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Adapt_CieXyz_D65_To_D50_XyzScaling(float x1, float y1, float z1, float x2, float y2, float z2)
{
// Arrange
CieXyz input = new CieXyz(x1, y1, z1);
CieXyz expectedOutput = new CieXyz(x2, y2, z2);
ColorSpaceConverter converter = new ColorSpaceConverter
var input = new CieXyz(x1, y1, z1);
var expectedOutput = new CieXyz(x2, y2, z2);
var converter = new ColorSpaceConverter
{
ChromaticAdaptation = new VonKriesChromaticAdaptation(LmsAdaptationMatrix.XyzScaling),
WhitePoint = Illuminants.D50
@ -133,9 +133,9 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Adapt_Xyz_D65_To_D50_XyzScaling(float x1, float y1, float z1, float x2, float y2, float z2)
{
// Arrange
CieXyz input = new CieXyz(x1, y1, z1);
CieXyz expectedOutput = new CieXyz(x2, y2, z2);
ColorSpaceConverter converter = new ColorSpaceConverter
var input = new CieXyz(x1, y1, z1);
var expectedOutput = new CieXyz(x2, y2, z2);
var converter = new ColorSpaceConverter
{
ChromaticAdaptation = new VonKriesChromaticAdaptation(LmsAdaptationMatrix.XyzScaling),
WhitePoint = Illuminants.D50

14
tests/ImageSharp.Tests/Colorspaces/RgbAndCieXyzConversionTest.cs

@ -35,8 +35,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_XYZ_D50_to_SRGB(float x, float y, float z, float r, float g, float b)
{
// Arrange
CieXyz input = new CieXyz(x, y, z);
ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.D50, TargetRgbWorkingSpace = RgbWorkingSpaces.SRgb };
var input = new CieXyz(x, y, z);
var converter = new ColorSpaceConverter { WhitePoint = Illuminants.D50, TargetRgbWorkingSpace = RgbWorkingSpaces.SRgb };
// Act
Rgb output = converter.ToRgb(input);
@ -92,12 +92,12 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_SRGB_to_XYZ_D50(float r, float g, float b, float x, float y, float z)
{
// Arrange
Rgb input = new Rgb(r, g, b);
ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.D50 };
var input = new Rgb(r, g, b);
var converter = new ColorSpaceConverter { WhitePoint = Illuminants.D50 };
// Act
CieXyz output = converter.ToCieXyz(input);
// Assert
IEqualityComparer<float> comparer = new ApproximateFloatComparer(0.001f);
Assert.Equal(x, output.X, comparer);
@ -119,8 +119,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_SRGB_to_XYZ_D65(float r, float g, float b, float x, float y, float z)
{
// Arrange
Rgb input = new Rgb(r, g, b);
ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65 };
var input = new Rgb(r, g, b);
var converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65 };
// Act
CieXyz output = converter.ToCieXyz(input);

4
tests/ImageSharp.Tests/Colorspaces/RgbAndCmykConversionTest.cs

@ -34,7 +34,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Cmyk_To_Rgb(float c, float m, float y, float k, float r, float g, float b)
{
// Arrange
Cmyk input = new Cmyk(c, m, y, k);
var input = new Cmyk(c, m, y, k);
// Act
Rgb output = Converter.ToRgb(input);
@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Rgb_To_Cmyk(float r, float g, float b, float c, float m, float y, float k)
{
// Arrange
Rgb input = new Rgb(r, g, b);
var input = new Rgb(r, g, b);
// Act
Cmyk output = Converter.ToCmyk(input);

4
tests/ImageSharp.Tests/Colorspaces/RgbAndHslConversionTest.cs

@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Hsl_To_Rgb(float h, float s, float l, float r, float g, float b)
{
// Arrange
Hsl input = new Hsl(h, s, l);
var input = new Hsl(h, s, l);
// Act
Rgb output = Converter.ToRgb(input);
@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Rgb_To_Hsl(float r, float g, float b, float h, float s, float l)
{
// Arrange
Rgb input = new Rgb(r, g, b);
var input = new Rgb(r, g, b);
// Act
Hsl output = Converter.ToHsl(input);

4
tests/ImageSharp.Tests/Colorspaces/RgbAndHsvConversionTest.cs

@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Hsv_To_Rgb(float h, float s, float v, float r, float g, float b)
{
// Arrange
Hsv input = new Hsv(h, s, v);
var input = new Hsv(h, s, v);
// Act
Rgb output = Converter.ToRgb(input);
@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Rgb_To_Hsv(float r, float g, float b, float h, float s, float v)
{
// Arrange
Rgb input = new Rgb(r, g, b);
var input = new Rgb(r, g, b);
// Act
Hsv output = Converter.ToHsv(input);

4
tests/ImageSharp.Tests/Colorspaces/RgbAndYCbCrConversionTest.cs

@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_YCbCr_To_Rgb(float y, float cb, float cr, float r, float g, float b)
{
// Arrange
YCbCr input = new YCbCr(y, cb, cr);
var input = new YCbCr(y, cb, cr);
// Act
Rgb output = Converter.ToRgb(input);
@ -55,7 +55,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Rgb_To_YCbCr(float r, float g, float b, float y, float cb, float cr)
{
// Arrange
Rgb input = new Rgb(r, g, b);
var input = new Rgb(r, g, b);
// Act
YCbCr output = Converter.ToYCbCr(input);

2
tests/ImageSharp.Tests/Common/ConstantsTests.cs

@ -13,4 +13,4 @@ namespace SixLabors.ImageSharp.Tests.Common
Assert.Equal(0.001f, Constants.Epsilon);
}
}
}
}

18
tests/ImageSharp.Tests/Common/SimdUtilsTests.cs

@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Tests.Common
Random rnd = new Random();
for (int i = 0; i < Vector<float>.Count; i++)
{
float v = (float)rnd.NextDouble() * (max-min) + min;
float v = (float)rnd.NextDouble() * (max - min) + min;
data[i] = v;
}
return new Vector<float>(data);
@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp.Tests.Common
[InlineData(42, 1000f)]
public void FastRound_RandomValues(int seed, float scale)
{
Vector<float> v = CreateRandomTestVector(seed, -scale*0.5f, scale*0.5f);
Vector<float> v = CreateRandomTestVector(seed, -scale * 0.5f, scale * 0.5f);
Vector<float> r = v.FastRound();
this.Output.WriteLine(v.ToString());
@ -133,7 +133,7 @@ namespace SixLabors.ImageSharp.Tests.Common
return;
}
float[] orig = new Random(seed).GenerateRandomRoundedFloatArray(count, 0, 256);
float[] orig = new Random(seed).GenerateRandomRoundedFloatArray(count, 0, 256);
float[] normalized = orig.Select(f => f / 255f).ToArray();
byte[] dest = new byte[count];
@ -158,12 +158,12 @@ namespace SixLabors.ImageSharp.Tests.Common
}
float[] source = new Random(seed).GenerateRandomFloatArray(count, 0, 1f);
byte[] dest = new byte[count];
SimdUtils.BulkConvertNormalizedFloatToByte(source, dest);
byte[] expected = source.Select(f => (byte)Math.Round(f*255f)).ToArray();
byte[] expected = source.Select(f => (byte)Math.Round(f * 255f)).ToArray();
Assert.Equal(expected, dest);
}
@ -217,7 +217,7 @@ namespace SixLabors.ImageSharp.Tests.Common
return;
}
float[] source = {0, 7, 42, 255, 0.5f, 1.1f, 2.6f, 16f};
float[] source = { 0, 7, 42, 255, 0.5f, 1.1f, 2.6f, 16f };
byte[] expected = source.Select(f => (byte)Math.Round(f)).ToArray();
source = source.Select(f => f / 255f).ToArray();
@ -242,7 +242,7 @@ namespace SixLabors.ImageSharp.Tests.Common
Vector<float> scale = new Vector<float>(255f) / new Vector<float>(256f);
Vector<float> x = MemoryMarshal.Cast<float, Vector<float>>(source)[0];
x = (x * scale) + magick;
Tuple8.OfUInt32 ii = default;
@ -252,7 +252,7 @@ namespace SixLabors.ImageSharp.Tests.Common
iiRef = x;
//Tuple8.OfUInt32 ii = Unsafe.As<Vector<float>, Tuple8.OfUInt32>(ref x);
ref Tuple8.OfByte d = ref MemoryMarshal.Cast<byte, Tuple8.OfByte>(dest)[0];
d.LoadFrom(ref ii);

15
tests/ImageSharp.Tests/ComplexIntegrationTests.cs

@ -1,13 +1,12 @@
namespace SixLabors.ImageSharp.Tests
{
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.Primitives;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.Primitives;
using Xunit;
using Xunit;
namespace SixLabors.ImageSharp.Tests
{
/// <summary>
/// Might be useful to catch complex bugs
/// </summary>

184
tests/ImageSharp.Tests/ConfigurationTests.cs

@ -1,95 +1,95 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.IO;
using SixLabors.ImageSharp.PixelFormats;
using Moq;
using Xunit;
namespace SixLabors.ImageSharp.Tests
{
/// <summary>
/// Tests the configuration class.
/// </summary>
public class ConfigurationTests
{
public Configuration ConfigurationEmpty { get; private set; }
public Configuration DefaultConfiguration { get; private set; }
public ConfigurationTests()
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.IO;
using SixLabors.ImageSharp.PixelFormats;
using Moq;
using Xunit;
namespace SixLabors.ImageSharp.Tests
{
/// <summary>
/// Tests the configuration class.
/// </summary>
public class ConfigurationTests
{
public Configuration ConfigurationEmpty { get; private set; }
public Configuration DefaultConfiguration { get; private set; }
public ConfigurationTests()
{
// the shallow copy of configuration should behave exactly like the default configuration,
// so by using the copy, we test both the default and the copy.
this.DefaultConfiguration = Configuration.CreateDefaultInstance().ShallowCopy();
this.ConfigurationEmpty = new Configuration();
}
[Fact]
public void DefaultsToLocalFileSystem()
{
Assert.IsType<LocalFileSystem>(this.DefaultConfiguration.FileSystem);
Assert.IsType<LocalFileSystem>(this.ConfigurationEmpty.FileSystem);
}
/// <summary>
/// Test that the default configuration is not null.
/// </summary>
[Fact]
public void TestDefultConfigurationIsNotNull()
{
Assert.True(Configuration.Default != null);
}
/// <summary>
/// Test that the default configuration parallel options is not null.
/// </summary>
[Fact]
public void TestDefultConfigurationParallelOptionsIsNotNull()
{
Assert.True(Configuration.Default.ParallelOptions != null);
}
/// <summary>
/// Test that the default configuration read origin options is set to begin.
/// </summary>
[Fact]
public void TestDefultConfigurationReadOriginIsCurrent()
{
Assert.True(Configuration.Default.ReadOrigin == ReadOrigin.Current);
}
/// <summary>
/// Test that the default configuration parallel options max degrees of parallelism matches the
/// environment processor count.
/// </summary>
[Fact]
public void TestDefultConfigurationMaxDegreeOfParallelism()
{
Assert.True(Configuration.Default.ParallelOptions.MaxDegreeOfParallelism == Environment.ProcessorCount);
}
[Fact]
public void ConstructorCallConfigureOnFormatProvider()
{
var provider = new Mock<IConfigurationModule>();
var config = new Configuration(provider.Object);
provider.Verify(x => x.Configure(config));
}
[Fact]
public void AddFormatCallsConfig()
{
var provider = new Mock<IConfigurationModule>();
var config = new Configuration();
config.Configure(provider.Object);
provider.Verify(x => x.Configure(config));
}
}
// so by using the copy, we test both the default and the copy.
this.DefaultConfiguration = Configuration.CreateDefaultInstance().ShallowCopy();
this.ConfigurationEmpty = new Configuration();
}
[Fact]
public void DefaultsToLocalFileSystem()
{
Assert.IsType<LocalFileSystem>(this.DefaultConfiguration.FileSystem);
Assert.IsType<LocalFileSystem>(this.ConfigurationEmpty.FileSystem);
}
/// <summary>
/// Test that the default configuration is not null.
/// </summary>
[Fact]
public void TestDefultConfigurationIsNotNull()
{
Assert.True(Configuration.Default != null);
}
/// <summary>
/// Test that the default configuration parallel options is not null.
/// </summary>
[Fact]
public void TestDefultConfigurationParallelOptionsIsNotNull()
{
Assert.True(Configuration.Default.ParallelOptions != null);
}
/// <summary>
/// Test that the default configuration read origin options is set to begin.
/// </summary>
[Fact]
public void TestDefultConfigurationReadOriginIsCurrent()
{
Assert.True(Configuration.Default.ReadOrigin == ReadOrigin.Current);
}
/// <summary>
/// Test that the default configuration parallel options max degrees of parallelism matches the
/// environment processor count.
/// </summary>
[Fact]
public void TestDefultConfigurationMaxDegreeOfParallelism()
{
Assert.True(Configuration.Default.ParallelOptions.MaxDegreeOfParallelism == Environment.ProcessorCount);
}
[Fact]
public void ConstructorCallConfigureOnFormatProvider()
{
var provider = new Mock<IConfigurationModule>();
var config = new Configuration(provider.Object);
provider.Verify(x => x.Configure(config));
}
[Fact]
public void AddFormatCallsConfig()
{
var provider = new Mock<IConfigurationModule>();
var config = new Configuration();
config.Configure(provider.Object);
provider.Verify(x => x.Configure(config));
}
}
}

8
tests/ImageSharp.Tests/Drawing/BeziersTests.cs

@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void ImageShouldBeOverlayedByBezierLine()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "BezierLine");
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
using (var image = new Image<Rgba32>(500, 500))
{
image.Mutate(x => x.BackgroundColor(Rgba32.Blue)
.DrawBeziers(Rgba32.HotPink, 5,
@ -54,9 +54,9 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "BezierLine");
Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150);
var color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150);
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
using (var image = new Image<Rgba32>(500, 500))
{
image.Mutate(x => x.BackgroundColor(Rgba32.Blue)
.DrawBeziers(color,
@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
image.Save($"{path}/Opacity.png");
//shift background color towards foreground color by the opacity amount
Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f));
var mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{

2
tests/ImageSharp.Tests/Drawing/DrawImageTest.cs

@ -3,8 +3,8 @@
using System;
using System.Numerics;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
using SixLabors.Primitives;
using Xunit;

1
tests/ImageSharp.Tests/Drawing/DrawPathTests.cs

@ -90,7 +90,6 @@ namespace SixLabors.ImageSharp.Tests.Drawing
}
}
[Fact]
public void PathExtendingOffEdgeOfImageShouldNotBeCropped()
{

12
tests/ImageSharp.Tests/Drawing/FillPatternTests.cs

@ -3,17 +3,15 @@
using System;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Primitives;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
using SixLabors.ImageSharp.Processing.Drawing.Brushes;
using SixLabors.ImageSharp.Processing.Transforms;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Drawing
{
using SixLabors.ImageSharp.Primitives;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
public class FillPatternBrushTests : FileTestBase
{
private void Test(string name, Rgba32 background, IBrush<Rgba32> brush, Rgba32[,] expectedPattern)
@ -36,9 +34,9 @@ namespace SixLabors.ImageSharp.Tests.Drawing
int yStride = expectedPatternFast.Rows;
int offsetX = r.Next(image.Width / xStride) * xStride;
int offsetY = r.Next(image.Height / yStride) * yStride;
for (var x = 0; x < xStride; x++)
for (int x = 0; x < xStride; x++)
{
for (var y = 0; y < yStride; y++)
for (int y = 0; y < yStride; y++)
{
int actualX = x + offsetX;
int actualY = y + offsetY;

4
tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs

@ -4,7 +4,7 @@
using System.Numerics;
using Moq;
using Xunit;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Primitives;
using SixLabors.ImageSharp.Processing;
@ -14,6 +14,8 @@ using SixLabors.ImageSharp.Processing.Drawing.Pens;
using SixLabors.ImageSharp.Processing.Drawing.Processors;
using SixLabors.Primitives;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Drawing
{
public class FillRegionProcessorTests

5
tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs

@ -3,14 +3,13 @@
using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
using SixLabors.ImageSharp.Processing.Overlays;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Drawing
{
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Overlays;
public class FillSolidBrushTests : FileTestBase
{
[Fact]

23
tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs

@ -3,16 +3,16 @@
using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
using SixLabors.ImageSharp.Processing.Drawing.Pens;
using SixLabors.ImageSharp.Processing.Overlays;
using SixLabors.Shapes;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Drawing
{
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Overlays;
public class LineComplexPolygonTests : FileTestBase
{
[Fact]
@ -87,9 +87,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{
Assert.Equal(Rgba32.HotPink, sourcePixels[10, 10]);
Assert.Equal(Rgba32.HotPink, sourcePixels[200, 150]);
Assert.Equal(Rgba32.HotPink, sourcePixels[50, 300]);
@ -110,7 +108,6 @@ namespace SixLabors.ImageSharp.Tests.Drawing
}
}
[Fact]
public void ImageShouldBeOverlayedByPolygonOutlineOverlapping()
{
@ -135,13 +132,9 @@ namespace SixLabors.ImageSharp.Tests.Drawing
using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{
Assert.Equal(Rgba32.HotPink, sourcePixels[10, 10]);
Assert.Equal(Rgba32.HotPink, sourcePixels[200, 150]);
Assert.Equal(Rgba32.HotPink, sourcePixels[50, 300]);
Assert.Equal(Rgba32.Blue, sourcePixels[130, 41]);
Assert.Equal(Rgba32.Blue, sourcePixels[2, 2]);
//inside hole
@ -153,7 +146,6 @@ namespace SixLabors.ImageSharp.Tests.Drawing
}
}
[Fact]
public void ImageShouldBeOverlayedByPolygonOutlineDashed()
{
@ -177,7 +169,6 @@ namespace SixLabors.ImageSharp.Tests.Drawing
}
}
[Fact]
public void ImageShouldBeOverlayedPolygonOutlineWithOpacity()
{
@ -206,24 +197,16 @@ namespace SixLabors.ImageSharp.Tests.Drawing
using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{
Assert.Equal(mergedColor, sourcePixels[10, 10]);
Assert.Equal(mergedColor, sourcePixels[200, 150]);
Assert.Equal(mergedColor, sourcePixels[50, 300]);
Assert.Equal(mergedColor, sourcePixels[37, 85]);
Assert.Equal(mergedColor, sourcePixels[93, 85]);
Assert.Equal(mergedColor, sourcePixels[65, 137]);
Assert.Equal(Rgba32.Blue, sourcePixels[2, 2]);
//inside hole
Assert.Equal(Rgba32.Blue, sourcePixels[57, 99]);
//inside shape
Assert.Equal(Rgba32.Blue, sourcePixels[100, 192]);
}

28
tests/ImageSharp.Tests/Drawing/LineTests.cs

@ -2,24 +2,24 @@
// Licensed under the Apache License, Version 2.0.
using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
using SixLabors.ImageSharp.Processing.Drawing.Pens;
using SixLabors.ImageSharp.Processing.Overlays;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Drawing
{
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Overlays;
public class LineTests : FileTestBase
{
[Fact]
public void ImageShouldBeOverlayedByPath()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
using (var image = new Image<Rgba32>(500, 500))
{
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
@ -46,13 +46,13 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void ImageShouldBeOverlayedByPath_NoAntialias()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
using (var image = new Image<Rgba32>(500, 500))
{
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
.DrawLines(
new GraphicsOptions(false),
Rgba32.HotPink,
Rgba32.HotPink,
5,
new SixLabors.Primitives.PointF[] {
new Vector2(10, 10),
@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void ImageShouldBeOverlayedByPathDashed()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
using (var image = new Image<Rgba32>(500, 500))
{
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void ImageShouldBeOverlayedByPathDotted()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
using (var image = new Image<Rgba32>(500, 500))
{
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
@ -112,7 +112,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void ImageShouldBeOverlayedByPathDashDot()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
using (var image = new Image<Rgba32>(500, 500))
{
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
@ -130,7 +130,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void ImageShouldBeOverlayedByPathDashDotDot()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
Image<Rgba32> image = new Image<Rgba32>(500, 500);
var image = new Image<Rgba32>(500, 500);
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
@ -147,9 +147,9 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150);
var color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150);
Image<Rgba32> image = new Image<Rgba32>(500, 500);
var image = new Image<Rgba32>(500, 500);
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
@ -161,7 +161,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
image.Save($"{path}/Opacity.png");
//shift background color towards forground color by the opacity amount
Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f));
var mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{
@ -178,7 +178,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
Image<Rgba32> image = new Image<Rgba32>(500, 500);
var image = new Image<Rgba32>(500, 500);
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)

1
tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs

@ -79,7 +79,6 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
this.operations.FillPolygon(this.noneDefault, this.color, this.path);
FillRegionProcessor<Rgba32> processor = this.Verify<FillRegionProcessor<Rgba32>>();
Assert.Equal(this.noneDefault, processor.Options);
ShapeRegion region = Assert.IsType<ShapeRegion>(processor.Region);

3
tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
using SixLabors.ImageSharp.Processing.Drawing.Brushes;
using SixLabors.Primitives;
@ -9,8 +10,6 @@ using Xunit;
namespace SixLabors.ImageSharp.Tests
{
using SixLabors.ImageSharp.Processing;
public class RecolorImageTest : FileTestBase
{
[Fact]

5
tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs

@ -3,15 +3,14 @@
using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
using SixLabors.ImageSharp.Processing.Overlays;
using SixLabors.Shapes;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Drawing
{
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Overlays;
[GroupOutput("Drawing")]
public class SolidBezierTests
{

29
tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs

@ -4,33 +4,33 @@
using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
using SixLabors.ImageSharp.Processing.Overlays;
using SixLabors.Shapes;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Drawing
{
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Overlays;
public class SolidComplexPolygonTests : FileTestBase
{
[Fact]
public void ImageShouldBeOverlayedByPolygonOutline()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "ComplexPolygon");
Polygon simplePath = new Polygon(new LinearLineSegment(
var simplePath = new Polygon(new LinearLineSegment(
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300)));
Polygon hole1 = new Polygon(new LinearLineSegment(
var hole1 = new Polygon(new LinearLineSegment(
new Vector2(37, 85),
new Vector2(93, 85),
new Vector2(65, 137)));
IPath clipped = simplePath.Clip(hole1);
// var clipped = new Rectangle(10, 10, 100, 100).Clip(new Rectangle(20, 0, 20, 20));
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
using (var image = new Image<Rgba32>(500, 500))
{
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
@ -52,17 +52,17 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void ImageShouldBeOverlayedPolygonOutlineWithOverlap()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "ComplexPolygon");
Polygon simplePath = new Polygon(new LinearLineSegment(
var simplePath = new Polygon(new LinearLineSegment(
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300)));
Polygon hole1 = new Polygon(new LinearLineSegment(
var hole1 = new Polygon(new LinearLineSegment(
new Vector2(37, 85),
new Vector2(130, 40),
new Vector2(65, 137)));
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
using (var image = new Image<Rgba32>(500, 500))
{
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
@ -83,18 +83,19 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void ImageShouldBeOverlayedPolygonOutlineWithOpacity()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "ComplexPolygon");
Polygon simplePath = new Polygon(new LinearLineSegment(
var simplePath = new Polygon(new LinearLineSegment(
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300)));
Polygon hole1 = new Polygon(new LinearLineSegment(
var hole1 = new Polygon(new LinearLineSegment(
new Vector2(37, 85),
new Vector2(93, 85),
new Vector2(65, 137)));
Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150);
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
var color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150);
using (var image = new Image<Rgba32>(500, 500))
{
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
@ -102,7 +103,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
image.Save($"{path}/Opacity.png");
//shift background color towards forground color by the opacity amount
Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f));
var mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{

9
tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs

@ -3,17 +3,18 @@
using System;
using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
using SixLabors.ImageSharp.Processing.Drawing.Brushes;
using SixLabors.ImageSharp.Processing.Overlays;
using SixLabors.Shapes;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Drawing
{
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing.Brushes;
using SixLabors.ImageSharp.Processing.Overlays;
public class SolidPolygonTests : FileTestBase
{
[Fact]

4
tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs

@ -2,14 +2,14 @@
// Licensed under the Apache License, Version 2.0.
using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Fonts;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Drawing.Brushes;
using SixLabors.ImageSharp.Processing.Drawing.Pens;
using SixLabors.ImageSharp.Processing.Drawing.Processors;
using SixLabors.ImageSharp.Processing.Text;
using SixLabors.Shapes;
using Xunit;
using SixLabors.ImageSharp.Processing.Drawing.Pens;
namespace SixLabors.ImageSharp.Tests.Drawing.Text
{

2
tests/ImageSharp.Tests/Drawing/Text/DrawText.cs

@ -2,8 +2,8 @@
// Licensed under the Apache License, Version 2.0.
using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Fonts;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Drawing.Brushes;
using SixLabors.ImageSharp.Processing.Drawing.Pens;
using SixLabors.ImageSharp.Processing.Drawing.Processors;

2
tests/ImageSharp.Tests/Drawing/Text/OutputText.cs

@ -3,9 +3,9 @@
using System.Numerics;
using SixLabors.Fonts;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.Fonts;
using SixLabors.ImageSharp.Processing.Drawing;
using SixLabors.ImageSharp.Processing.Text;

9
tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs

@ -1,19 +1,14 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Bmp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using Xunit;
// ReSharper disable InconsistentNaming
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests
{
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using Xunit.Abstractions;
public class BmpEncoderTests : FileTestBase
{
public static readonly TheoryData<BmpBitsPerPixel> BitsPerPixel =

8
tests/ImageSharp.Tests/IO/LocalFileSystem.cs

@ -17,9 +17,9 @@ namespace SixLabors.ImageSharp.Tests.IO
string testData = Guid.NewGuid().ToString();
File.WriteAllText(path, testData);
LocalFileSystem fs = new LocalFileSystem();
var fs = new LocalFileSystem();
using (StreamReader r = new StreamReader(fs.OpenRead(path)))
using (var r = new StreamReader(fs.OpenRead(path)))
{
string data = r.ReadToEnd();
@ -34,9 +34,9 @@ namespace SixLabors.ImageSharp.Tests.IO
{
string path = Path.GetTempFileName();
string testData = Guid.NewGuid().ToString();
LocalFileSystem fs = new LocalFileSystem();
var fs = new LocalFileSystem();
using (StreamWriter r = new StreamWriter(fs.Create(path)))
using (var r = new StreamWriter(fs.Create(path)))
{
r.Write(testData);
}

4
tests/ImageSharp.Tests/ImageOperationTests.cs

@ -4,11 +4,11 @@
using System;
using System.Linq;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors;
using Moq;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors;
using Xunit;

24
tests/ImageSharp.Tests/Numerics/RationalTests.cs

@ -19,15 +19,15 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void AreEqual()
{
Rational r1 = new Rational(3, 2);
Rational r2 = new Rational(3, 2);
var r1 = new Rational(3, 2);
var r2 = new Rational(3, 2);
Assert.Equal(r1, r2);
Assert.True(r1 == r2);
Rational r3 = new Rational(7.55);
Rational r4 = new Rational(755, 100);
Rational r5 = new Rational(151, 20);
var r3 = new Rational(7.55);
var r4 = new Rational(755, 100);
var r5 = new Rational(151, 20);
Assert.Equal(r3, r4);
Assert.Equal(r4, r5);
@ -39,8 +39,8 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void AreNotEqual()
{
Rational first = new Rational(0, 100);
Rational second = new Rational(100, 100);
var first = new Rational(0, 100);
var second = new Rational(100, 100);
Assert.NotEqual(first, second);
Assert.True(first != second);
@ -52,7 +52,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void ConstructorAssignsProperties()
{
Rational rational = new Rational(7, 55);
var rational = new Rational(7, 55);
Assert.Equal(7U, rational.Numerator);
Assert.Equal(55U, rational.Denominator);
@ -76,15 +76,15 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void Fraction()
{
Rational first = new Rational(1.0 / 1600);
Rational second = new Rational(1.0 / 1600, true);
var first = new Rational(1.0 / 1600);
var second = new Rational(1.0 / 1600, true);
Assert.False(first.Equals(second));
}
[Fact]
public void ToDouble()
{
Rational rational = new Rational(0, 0);
var rational = new Rational(0, 0);
Assert.Equal(double.NaN, rational.ToDouble());
rational = new Rational(2, 0);
@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void ToStringRepresention()
{
Rational rational = new Rational(0, 0);
var rational = new Rational(0, 0);
Assert.Equal("[ Indeterminate ]", rational.ToString());
rational = new Rational(double.PositiveInfinity);

25
tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs

@ -1,7 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.MetaData.Profiles.Exif;
using SixLabors.ImageSharp.Primitives;
using Xunit;
@ -19,15 +18,15 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void AreEqual()
{
SignedRational r1 = new SignedRational(3, 2);
SignedRational r2 = new SignedRational(3, 2);
var r1 = new SignedRational(3, 2);
var r2 = new SignedRational(3, 2);
Assert.Equal(r1, r2);
Assert.True(r1 == r2);
SignedRational r3 = new SignedRational(7.55);
SignedRational r4 = new SignedRational(755, 100);
SignedRational r5 = new SignedRational(151, 20);
var r3 = new SignedRational(7.55);
var r4 = new SignedRational(755, 100);
var r5 = new SignedRational(151, 20);
Assert.Equal(r3, r4);
Assert.Equal(r4, r5);
@ -39,8 +38,8 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void AreNotEqual()
{
SignedRational first = new SignedRational(0, 100);
SignedRational second = new SignedRational(100, 100);
var first = new SignedRational(0, 100);
var second = new SignedRational(100, 100);
Assert.NotEqual(first, second);
Assert.True(first != second);
@ -52,7 +51,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void ConstructorAssignsProperties()
{
SignedRational rational = new SignedRational(7, -55);
var rational = new SignedRational(7, -55);
Assert.Equal(7, rational.Numerator);
Assert.Equal(-55, rational.Denominator);
@ -80,15 +79,15 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void Fraction()
{
SignedRational first = new SignedRational(1.0 / 1600);
SignedRational second = new SignedRational(1.0 / 1600, true);
var first = new SignedRational(1.0 / 1600);
var second = new SignedRational(1.0 / 1600, true);
Assert.False(first.Equals(second));
}
[Fact]
public void ToDouble()
{
SignedRational rational = new SignedRational(0, 0);
var rational = new SignedRational(0, 0);
Assert.Equal(double.NaN, rational.ToDouble());
rational = new SignedRational(2, 0);
@ -101,7 +100,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void ToStringRepresention()
{
SignedRational rational = new SignedRational(0, 0);
var rational = new SignedRational(0, 0);
Assert.Equal("[ Indeterminate ]", rational.ToString());
rational = new SignedRational(double.PositiveInfinity);

12
tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs

@ -3,16 +3,16 @@
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Binarization;
using SixLabors.ImageSharp.Processing.Binarization.Processors;
using SixLabors.ImageSharp.Processing.Dithering;
using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
using SixLabors.ImageSharp.Processing.Dithering.Ordered;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Binarization
{
using SixLabors.ImageSharp.Processing.Binarization;
using SixLabors.ImageSharp.Processing.Binarization.Processors;
using SixLabors.ImageSharp.Processing.Dithering;
using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
using SixLabors.ImageSharp.Processing.Dithering.Ordered;
public class BinaryDitherTest : BaseImageOperationsExtensionTest
{
private readonly IOrderedDither orderedDither;

9
tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs

@ -2,18 +2,15 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.Primitives;
using SixLabors.ImageSharp.Processing.Binarization;
using SixLabors.ImageSharp.Processing.Binarization.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Binarization
{
using SixLabors.ImageSharp.Processing.Binarization;
using SixLabors.ImageSharp.Processing.Binarization.Processors;
public class BinaryThresholdTest : BaseImageOperationsExtensionTest
{
[Fact]
public void BinaryThreshold_CorrectProcessor()
{

6
tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs

@ -1,13 +1,13 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Primitives;
using SixLabors.ImageSharp.Processing.Dithering.Ordered;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Binarization
{
using SixLabors.ImageSharp.Primitives;
using SixLabors.ImageSharp.Processing.Dithering.Ordered;
public class OrderedDitherFactoryTests
{
private static readonly DenseMatrix<uint> Expected2x2Matrix = new DenseMatrix<uint>(

9
tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs

@ -2,16 +2,15 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Dithering;
using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
using SixLabors.ImageSharp.Processing.Dithering.Ordered;
using SixLabors.ImageSharp.Processing.Dithering.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Binarization
{
using SixLabors.ImageSharp.Processing.Dithering;
using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
using SixLabors.ImageSharp.Processing.Dithering.Ordered;
using SixLabors.ImageSharp.Processing.Dithering.Processors;
public class DitherTest : BaseImageOperationsExtensionTest
{
private readonly IOrderedDither orderedDither;

5
tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs

@ -2,14 +2,13 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Overlays;
using SixLabors.ImageSharp.Processing.Overlays.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Effects
{
using SixLabors.ImageSharp.Processing.Overlays;
using SixLabors.ImageSharp.Processing.Overlays.Processors;
public class BackgroundColorTest : BaseImageOperationsExtensionTest
{
[Fact]

7
tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs

@ -2,15 +2,12 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.Primitives;
using SixLabors.ImageSharp.Processing.Effects;
using SixLabors.ImageSharp.Processing.Effects.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Effects
{
using SixLabors.ImageSharp.Processing.Effects;
using SixLabors.ImageSharp.Processing.Effects.Processors;
public class OilPaintTest : BaseImageOperationsExtensionTest
{
[Fact]

7
tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs

@ -2,15 +2,12 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.Primitives;
using SixLabors.ImageSharp.Processing.Effects;
using SixLabors.ImageSharp.Processing.Effects.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Effects
{
using SixLabors.ImageSharp.Processing.Effects;
using SixLabors.ImageSharp.Processing.Effects.Processors;
public class PixelateTest : BaseImageOperationsExtensionTest
{
[Fact]

8
tests/ImageSharp.Tests/Processing/Filters/BlackWhiteTest.cs

@ -2,14 +2,12 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Filters
{
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
public class BlackWhiteTest : BaseImageOperationsExtensionTest
{
[Fact]
@ -22,7 +20,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Filters
[Fact]
public void BlackWhite_rect_CorrectProcessor()
{
this.operations.BlackWhite( this.rect);
this.operations.BlackWhite(this.rect);
BlackWhiteProcessor<Rgba32> p = this.Verify<BlackWhiteProcessor<Rgba32>>(this.rect);
}
}

7
tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs

@ -2,15 +2,12 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.Primitives;
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Effects
{
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
public class BrightnessTest : BaseImageOperationsExtensionTest
{
[Fact]

11
tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs

@ -4,16 +4,15 @@
using System.Collections.Generic;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.ImageSharp.Tests.TestUtilities;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Filters
{
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
using SixLabors.ImageSharp.Processing.Processors;
public class ColorBlindnessTest : BaseImageOperationsExtensionTest
{
public static IEnumerable<object[]> TheoryData = new[] {
@ -33,7 +32,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Filters
where T : IImageProcessor<Rgba32>
{
this.operations.ColorBlindness(colorBlindness);
var p = this.Verify<T>();
T p = this.Verify<T>();
}
[Theory]
[MemberData(nameof(TheoryData))]
@ -41,7 +40,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Filters
where T : IImageProcessor<Rgba32>
{
this.operations.ColorBlindness(colorBlindness, this.rect);
var p = this.Verify<T>(this.rect);
T p = this.Verify<T>(this.rect);
}
}
}

8
tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs

@ -4,16 +4,15 @@
using System.Collections.Generic;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.ImageSharp.Tests.TestUtilities;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Filters
{
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
using SixLabors.ImageSharp.Processing.Processors;
public class GrayscaleTest : BaseImageOperationsExtensionTest
{
public static IEnumerable<object[]> ModeTheoryData = new[] {
@ -27,7 +26,6 @@ namespace SixLabors.ImageSharp.Tests.Processing.Filters
{
this.operations.Grayscale(mode);
var p = this.Verify<T>();
}
[Theory]

8
tests/ImageSharp.Tests/Processing/Filters/HueTest.cs

@ -2,15 +2,13 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.Primitives;
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Filters
{
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
public class HueTest : BaseImageOperationsExtensionTest
{
[Fact]

7
tests/ImageSharp.Tests/Processing/Filters/InvertTest.cs

@ -2,15 +2,12 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.Primitives;
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Effects
{
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
public class InvertTest : BaseImageOperationsExtensionTest
{
[Fact]

7
tests/ImageSharp.Tests/Processing/Filters/KodachromeTest.cs

@ -2,15 +2,12 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.Primitives;
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Filters
{
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
public class KodachromeTest : BaseImageOperationsExtensionTest
{
[Fact]

6
tests/ImageSharp.Tests/Processing/Filters/OpacityTest.cs

@ -2,14 +2,12 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Effects
{
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
public class OpacityTest : BaseImageOperationsExtensionTest
{
[Fact]

8
tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs

@ -2,15 +2,13 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.Primitives;
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Filters
{
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
public class PolaroidTest : BaseImageOperationsExtensionTest
{
[Fact]

7
tests/ImageSharp.Tests/Processing/Filters/SaturateTest.cs

@ -2,17 +2,14 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Filters
{
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
public class SaturateTest : BaseImageOperationsExtensionTest
{
[Fact]
public void Saturation_amount_SaturationProcessorDefaultsSet()
{

7
tests/ImageSharp.Tests/Processing/Filters/SepiaTest.cs

@ -2,15 +2,12 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.Primitives;
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Filters
{
using SixLabors.ImageSharp.Processing.Filters;
using SixLabors.ImageSharp.Processing.Filters.Processors;
public class SepiaTest : BaseImageOperationsExtensionTest
{
[Fact]

13
tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs

@ -2,20 +2,19 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Binarization;
using SixLabors.ImageSharp.Processing.Dithering;
using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
using SixLabors.ImageSharp.Processing.Dithering.Ordered;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.Primitives;
using Xunit;
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization
{
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Binarization;
using SixLabors.ImageSharp.Processing.Dithering;
using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
using SixLabors.ImageSharp.Processing.Dithering.Ordered;
public class BinaryDitherTests : FileTestBase
{
public static readonly string[] CommonTestImages =

7
tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs

@ -3,16 +3,13 @@
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Convolution;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.Primitives;
using Xunit;
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution
{
using SixLabors.ImageSharp.Processing.Convolution;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
public class DetectEdgesTest : FileTestBase
{
private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.001f);

7
tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianBlurTest.cs

@ -2,16 +2,15 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Convolution;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.Primitives;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution
{
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Convolution;
public class GaussianBlurTest : FileTestBase
{
public static readonly TheoryData<int> GaussianBlurValues = new TheoryData<int> { 3, 5 };

6
tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianSharpenTest.cs

@ -2,16 +2,14 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Convolution;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.Primitives;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution
{
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Convolution;
public class GaussianSharpenTest : FileTestBase
{
public static readonly TheoryData<int> GaussianSharpenValues

3
tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs

@ -9,12 +9,9 @@ using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
using SixLabors.ImageSharp.Processing.Dithering.Ordered;
using SixLabors.Primitives;
using Xunit;
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization
{
public class DitherTests : FileTestBase
{
public static readonly string[] CommonTestImages =

2
tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs

@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
using (Image<TPixel> image = provider.GetImage())
{
image.MetaData.ExifProfile = new ExifProfile(bytes);
image.Mutate(x=>x.AutoOrient());
image.Mutate(x => x.AutoOrient());
}
}
}

6
tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs

@ -2,13 +2,13 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
public class CropTest : FileTestBase
{
[Theory]

6
tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs

@ -2,13 +2,13 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
public class EntropyCropTest : FileTestBase
{
public static readonly TheoryData<float> EntropyCropValues

1
tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs

@ -3,6 +3,7 @@
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms

7
tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs

@ -8,15 +8,14 @@ using System.Text;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.Primitives;
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
using SixLabors.Primitives;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
public class ResizeProfilingBenchmarks : MeasureFixture
{
public ResizeProfilingBenchmarks(ITestOutputHelper output)

9
tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs

@ -2,18 +2,17 @@
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Processing.Transforms.Resamplers;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.Primitives;
using Xunit;
// ReSharper disable InconsistentNaming
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
public class ResizeTests : FileTestBase
{
public static readonly string[] CommonTestImages = { TestImages.Png.CalliphoraPartial };

8
tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs

@ -3,16 +3,12 @@
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
using Xunit;
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{
using System;
using System.Reflection;
using SixLabors.ImageSharp.Processing.Transforms;
public class RotateTests : FileTestBase
{
public static readonly TheoryData<float> RotateAngles

7
tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs

@ -1,18 +1,19 @@
using System;
using System.Numerics;
using System.Reflection;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Processing.Transforms.Resamplers;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.Primitives;
using Xunit;
using Xunit.Abstractions;
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
public class AffineTransformTests
{

6
tests/ImageSharp.Tests/Processing/Transforms/RotateTests.cs

@ -4,13 +4,13 @@
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
public class RotateTests : BaseImageOperationsExtensionTest
{
[Theory]

6
tests/ImageSharp.Tests/Processing/Transforms/SkewTest.cs

@ -3,13 +3,13 @@
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
public class SkewTest : BaseImageOperationsExtensionTest
{
[Fact]

4
tests/ImageSharp.Tests/Processing/Transforms/TransformsHelpersTest.cs

@ -3,12 +3,12 @@
using SixLabors.ImageSharp.MetaData.Profiles.Exif;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Transforms;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{
using SixLabors.ImageSharp.Processing.Transforms;
public class TransformsHelpersTest
{
[Fact]

13
tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs

@ -1,10 +1,13 @@
namespace SixLabors.ImageSharp.Tests
{
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Quantization;
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Quantization;
using Xunit;
using Xunit;
namespace SixLabors.ImageSharp.Tests
{
public class QuantizedImageTests
{
[Fact]

2
tests/ImageSharp.Tests/TestDataIcc/IccTestDataArray.cs

@ -141,4 +141,4 @@ namespace SixLabors.ImageSharp.Tests
#endregion
}
}
}

7
tests/ImageSharp.Tests/TestFileSystem.cs

@ -2,13 +2,8 @@
// Licensed under the Apache License, Version 2.0.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using SixLabors.ImageSharp.Formats;
using Xunit;
namespace SixLabors.ImageSharp.Tests
{
@ -56,7 +51,7 @@ namespace SixLabors.ImageSharp.Tests
{
if (fileSystem.ContainsKey(path))
{
Stream stream = fileSystem[path];
Stream stream = fileSystem[path];
stream.Position = 0;
return stream;
}

8
tests/ImageSharp.Tests/TestFont.cs

@ -1,8 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -33,7 +31,7 @@ namespace SixLabors.ImageSharp.Tests
{
return Path.Combine(FormatsDirectory, file);
}
/// <summary>
/// Gets the correct path to the formats directory.
/// </summary>
@ -42,7 +40,7 @@ namespace SixLabors.ImageSharp.Tests
/// </returns>
private static string GetFontsDirectory()
{
List<string> directories = new List< string > {
List<string> directories = new List<string> {
"TestFonts/", // Here for code coverage tests.
"tests/ImageSharp.Tests/TestFonts/", // from travis/build script
"../../../../../ImageSharp.Tests/TestFonts/", // from Sandbox46
@ -58,7 +56,7 @@ namespace SixLabors.ImageSharp.Tests
string directory = directories.FirstOrDefault(x => Directory.Exists(x));
if(directory != null)
if (directory != null)
{
return directory;
}

2
tests/ImageSharp.Tests/TestFormat.cs

@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.Tests
public MemoryStream CreateStream(byte[] marker = null)
{
MemoryStream ms = new MemoryStream();
var ms = new MemoryStream();
byte[] data = this.header;
ms.Write(data, 0, data.Length);
if (marker != null)

10
tests/ImageSharp.Tests/TestUtilities/ArrayHelper.cs

@ -8,14 +8,14 @@ namespace SixLabors.ImageSharp.Tests
public static class ArrayHelper
{
/// <summary>
/// Concatenates multiple arrays of the same type into one
/// Concatenates multiple arrays of the same type into one.
/// </summary>
/// <typeparam name="T">The array type</typeparam>
/// <param name="arrs">The arrays to concatenate. The order is kept</param>
/// <returns>The concatenated array</returns>
public static T[] Concat<T>(params T[][] arrs)
{
T[] result = new T[arrs.Sum(t => t.Length)];
var result = new T[arrs.Sum(t => t.Length)];
int offset = 0;
for (int i = 0; i < arrs.Length; i++)
{
@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Tests
}
/// <summary>
/// Creates an array filled with the given value
/// Creates an array filled with the given value.
/// </summary>
/// <typeparam name="T">The array type</typeparam>
/// <param name="value">The value to fill the array with</param>
@ -34,7 +34,7 @@ namespace SixLabors.ImageSharp.Tests
/// <returns>The created array filled with the given value</returns>
public static T[] Fill<T>(T value, int length)
{
T[] result = new T[length];
var result = new T[length];
for (int i = 0; i < length; i++)
{
result[i] = value;
@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Tests
}
/// <summary>
/// Creates a string from a character with a given length
/// Creates a string from a character with a given length.
/// </summary>
/// <param name="value">The character to fill the string with</param>
/// <param name="length">The wanted length of the string</param>

18
tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs

@ -1,12 +1,12 @@
namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison
{
using System;
using System.Collections.Generic;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats;
using System;
using System.Collections.Generic;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison
{
public class ExactImageComparer : ImageComparer
{
public static ExactImageComparer Instance { get; } = new ExactImageComparer();
@ -24,8 +24,8 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison
// TODO: Comparing through Rgba32 is not robust enough because of the existance of super high precision pixel types.
Rgba32[] aBuffer = new Rgba32[width];
Rgba32[] bBuffer = new Rgba32[width];
var aBuffer = new Rgba32[width];
var bBuffer = new Rgba32[width];
var differences = new List<PixelDifference>();

13
tests/ImageSharp.Tests/TestUtilities/ImageComparison/Exceptions/ImageDifferenceIsOverThresholdException.cs

@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class ImageDifferenceIsOverThresholdException : ImagesSimilarityException
{
public ImageSimilarityReport[] Reports { get; }
@ -17,7 +17,8 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison
private static string StringifyReports(IEnumerable<ImageSimilarityReport> reports)
{
StringBuilder sb = new StringBuilder();
var sb = new StringBuilder();
sb.Append(Environment.NewLine);
int i = 0;

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

@ -1,11 +1,11 @@
namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SixLabors.ImageSharp.PixelFormats;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison
{
public class ImageSimilarityReport
{
protected ImageSimilarityReport(

5
tests/ImageSharp.Tests/TestUtilities/ImageComparison/PixelDifference.cs

@ -1,10 +1,9 @@
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison
{
using SixLabors.Primitives;
public struct PixelDifference
public readonly struct PixelDifference
{
public PixelDifference(
Point position,

26
tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs

@ -1,14 +1,14 @@
namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison
{
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison
{
public class TolerantImageComparer : ImageComparer
{
// 1% of all pixels in a 100*100 pixel area are allowed to have a difference of 1 unit
@ -50,20 +50,20 @@
/// </see>
/// </summary>
public int PerPixelManhattanThreshold { get; }
public override ImageSimilarityReport<TPixelA, TPixelB> CompareImagesOrFrames<TPixelA, TPixelB>(ImageFrame<TPixelA> expected, ImageFrame<TPixelB> actual)
{
if (expected.Size() != actual.Size())
{
throw new InvalidOperationException("Calling ImageComparer is invalid when dimensions mismatch!");
}
int width = actual.Width;
// TODO: Comparing through Rgba32 is not robust enough because of the existance of super high precision pixel types.
Rgba32[] aBuffer = new Rgba32[width];
Rgba32[] bBuffer = new Rgba32[width];
var aBuffer = new Rgba32[width];
var bBuffer = new Rgba32[width];
float totalDifference = 0.0f;
@ -93,7 +93,7 @@
float normalizedDifference = totalDifference / ((float)actual.Width * (float)actual.Height);
normalizedDifference /= 4.0f * 255.0f;
if (normalizedDifference > this.ImageThreshold)
{
return new ImageSimilarityReport<TPixelA, TPixelB>(expected, actual, differences, normalizedDifference);

2
tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs

@ -115,7 +115,7 @@ namespace SixLabors.ImageSharp.Tests
{
this.FilePath = filePath;
}
/// <summary>
/// Gets the file path relative to the "~/tests/images" folder
/// </summary>

4
tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs

@ -1,17 +1,15 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
using SixLabors.ImageSharp.Processing.Overlays;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests
{
using SixLabors.ImageSharp.Processing;
/// <summary>
/// Provides <see cref="Image{TPixel}" /> instances for parametric unit tests.

9
tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs

@ -3,19 +3,16 @@
using System;
using System.Reflection;
using Castle.Core.Internal;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests
{
using Castle.Core.Internal;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.Processing;
public interface ITestImageProvider
{
PixelTypes PixelType { get; }
@ -103,7 +100,7 @@ namespace SixLabors.ImageSharp.Tests
/// </summary>
public Image<TPixel> GetImage(Action<IImageProcessingContext<TPixel>> operationsToApply)
{
var img = GetImage();
Image<TPixel> img = GetImage();
img.Mutate(operationsToApply);
return img;
}

5
tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs

@ -7,14 +7,11 @@ using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests
{
public abstract partial class TestImageProvider<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
/// A test image provider that produces test patterns.
/// </summary>
@ -199,7 +196,7 @@ namespace SixLabors.ImageSharp.Tests
int pixelCount = left * top;
uint stepsPerPixel = (uint)(uint.MaxValue / pixelCount);
TPixel c = default(TPixel);
TPixel c = default;
Rgba32 t = new Rgba32(0);
for (int x = left; x < right; x++)

2
tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs

@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.Tests
}
private ITestOutputHelper Output { get; }
public void Dispose()
{
this.stopwatch.Stop();

3
tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceDecoder.cs

@ -1,7 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.IO;
using SixLabors.ImageSharp.Formats;
@ -23,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
{
return SystemDrawingBridge.FromFromArgb32SystemDrawingBitmap<TPixel>(sourceBitmap);
}
using (var convertedBitmap = new System.Drawing.Bitmap(
sourceBitmap.Width,
sourceBitmap.Height,

5
tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceEncoder.cs

@ -1,9 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.Collections.Generic;
using System.Text;
using System.Drawing.Imaging;
using System.IO;
@ -21,7 +18,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
this.imageFormat = imageFormat;
}
public static SystemDrawingReferenceEncoder Png { get; } = new SystemDrawingReferenceEncoder(System.Drawing.Imaging.ImageFormat.Png);
public static SystemDrawingReferenceEncoder Png { get; } = new SystemDrawingReferenceEncoder(ImageFormat.Png);
public void Encode<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : struct, IPixel<TPixel>

52
tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs

@ -4,23 +4,19 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs;
using Xunit;
namespace SixLabors.ImageSharp.Tests
{
using System.Numerics;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.MetaData;
using SixLabors.ImageSharp.Processing;
using Xunit;
public static class TestImageExtensions
{
/// <summary>
@ -32,28 +28,28 @@ namespace SixLabors.ImageSharp.Tests
where TPixel : struct, IPixel<TPixel>
{
MemoryManager memoryManager = ctx.MemoryManager;
ctx.Apply(
img =>
{
using (Buffer2D<Vector4> temp = memoryManager.Allocate2D<Vector4>(img.Width, img.Height))
{
Span<Vector4> tempSpan = temp.Span;
foreach (ImageFrame<TPixel> frame in img.Frames)
{
Span<TPixel> pixelSpan = frame.GetPixelSpan();
PixelOperations<TPixel>.Instance.ToVector4(pixelSpan, tempSpan, pixelSpan.Length);
ctx.Apply(img =>
{
using (Buffer2D<Vector4> temp = memoryManager.Allocate2D<Vector4>(img.Width, img.Height))
{
Span<Vector4> tempSpan = temp.Span;
foreach (ImageFrame<TPixel> frame in img.Frames)
{
Span<TPixel> pixelSpan = frame.GetPixelSpan();
for (int i = 0; i < tempSpan.Length; i++)
{
ref Vector4 v = ref tempSpan[i];
v.W = 1.0f;
}
PixelOperations<TPixel>.Instance.ToVector4(pixelSpan, tempSpan, pixelSpan.Length);
PixelOperations<TPixel>.Instance.PackFromVector4(tempSpan, pixelSpan, pixelSpan.Length);
}
for (int i = 0; i < tempSpan.Length; i++)
{
ref Vector4 v = ref tempSpan[i];
v.W = 1.0f;
}
});
PixelOperations<TPixel>.Instance.PackFromVector4(tempSpan, pixelSpan, pixelSpan.Length);
}
}
});
}
/// <summary>

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

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Text;
using SixLabors.ImageSharp.PixelFormats;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.TestUtilities

2
tests/ImageSharp.Tests/TestUtilities/TestType.cs

@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities
public TestType()
{
}
public void Deserialize(IXunitSerializationInfo info)
{
}

8
tests/ImageSharp.Tests/TestUtilities/TestUtils.cs

@ -6,14 +6,14 @@ using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Tests
{
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.Primitives;
/// <summary>
/// Various utility and extension methods.
/// </summary>

8
tests/ImageSharp.Tests/TestUtilities/TestVector4.cs

@ -1,11 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Text;
using SixLabors.ImageSharp.PixelFormats;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.TestUtilities
@ -43,8 +39,8 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities
{
this.X = info.GetValue<float>("x");
this.Y = info.GetValue<float>("y");
this.Z= info.GetValue<float>("z");
this.W= info.GetValue<float>("w");
this.Z = info.GetValue<float>("z");
this.W = info.GetValue<float>("w");
}
public void Serialize(IXunitSerializationInfo info)

15
tests/ImageSharp.Tests/TestUtilities/Tests/GroupOutputTests.cs

@ -1,12 +1,11 @@
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests
{
using System.IO;
using System.IO;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
using Xunit;
namespace SixLabors.ImageSharp.Tests
{
[GroupOutput("Foo")]
public class GroupOutputTests
{
@ -17,9 +16,9 @@ namespace SixLabors.ImageSharp.Tests
{
Assert.Equal("Foo", provider.Utility.OutputSubfolderName);
}
[Theory]
[WithBlankImages(1,1, PixelTypes.Rgba32)]
[WithBlankImages(1, 1, PixelTypes.Rgba32)]
public void GetTestOutputDir_ShouldDefineSubfolder<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{

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

@ -1,21 +1,19 @@
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests
{
using System.Collections.Generic;
using System.Linq;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using System.Collections.Generic;
using System.Linq;
using Moq;
using Moq;
using SixLabors.Primitives;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.Primitives;
using Xunit;
using Xunit.Abstractions;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
using Xunit;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests
{
public class ImageComparerTests
{
public ImageComparerTests(ITestOutputHelper output)
@ -24,9 +22,9 @@ namespace SixLabors.ImageSharp.Tests
}
private ITestOutputHelper Output { get; }
[Theory]
[WithTestPatternImages(100,100,PixelTypes.Rgba32, 0.0001f, 1)]
[WithTestPatternImages(100, 100, PixelTypes.Rgba32, 0.0001f, 1)]
[WithTestPatternImages(100, 100, PixelTypes.Rgba32, 0, 0)]
public void TolerantImageComparer_ApprovesPerfectSimilarity<TPixel>(
TestImageProvider<TPixel> provider,
@ -85,7 +83,7 @@ namespace SixLabors.ImageSharp.Tests
}
}
}
[Theory]
[WithTestPatternImages(100, 100, PixelTypes.Rgba32)]
public void TolerantImageComparer_TestPerPixelThreshold<TPixel>(TestImageProvider<TPixel> provider)
@ -160,7 +158,7 @@ namespace SixLabors.ImageSharp.Tests
}
}
}
[Theory]
[WithTestPatternImages(100, 100, PixelTypes.Rgba32)]
public void ExactComparer_DoesNotTolerateAnyPixelDifference<TPixel>(TestImageProvider<TPixel> provider)
@ -174,7 +172,7 @@ namespace SixLabors.ImageSharp.Tests
ImagingTestCaseUtility.ModifyPixel(clone, 7, 93, 1);
IEnumerable<ImageSimilarityReport> reports = ExactImageComparer.Instance.CompareImages(image, clone);
this.Output.WriteLine(reports.Single().ToString());
PixelDifference[] differences = reports.Single().Differences;
Assert.Equal(2, differences.Length);

21
tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceCodecTests.cs

@ -1,15 +1,14 @@
namespace SixLabors.ImageSharp.Tests
{
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs;
using Xunit;
using Xunit.Abstractions;
using Xunit;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests
{
public class ReferenceCodecTests
{
private ITestOutputHelper Output { get; }
@ -73,7 +72,7 @@ namespace SixLabors.ImageSharp.Tests
if (TestEnvironment.IsLinux) return;
string path = SavePng(provider, PngColorType.RgbWithAlpha);
using (var sdBitmap = new System.Drawing.Bitmap(path))
{
using (Image<TPixel> original = provider.GetImage())

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save