diff --git a/tests/ImageSharp.Tests/Drawing/FillLinearGradientBrushTests.cs b/tests/ImageSharp.Tests/Drawing/FillLinearGradientBrushTests.cs index 04a2417a11..9ea7ff08ad 100644 --- a/tests/ImageSharp.Tests/Drawing/FillLinearGradientBrushTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillLinearGradientBrushTests.cs @@ -20,50 +20,48 @@ namespace SixLabors.ImageSharp.Tests.Drawing { [Theory] [WithBlankImages(10, 10, PixelTypes.Rgba32)] - public void WithEqualColorsReturnsUnicolorImage( - TestImageProvider provider) + public void WithEqualColorsReturnsUnicolorImage(TestImageProvider provider) where TPixel : struct, IPixel { - TPixel red = NamedColors.Red; - using (var image = provider.GetImage()) - { - LinearGradientBrush unicolorLinearGradientBrush = - new LinearGradientBrush( - new SixLabors.Primitives.Point(0, 0), - new SixLabors.Primitives.Point(10, 0), - GradientRepetitionMode.None, - new ColorStop(0, red), - new ColorStop(1, red)); - - image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); - image.DebugSave(provider); - image.CompareToReferenceOutput(provider); - } + provider.VerifyOperation( + image => + { + TPixel red = NamedColors.Red; + var unicolorLinearGradientBrush = new LinearGradientBrush( + new SixLabors.Primitives.Point(0, 0), + new SixLabors.Primitives.Point(10, 0), + GradientRepetitionMode.None, + new ColorStop(0, red), + new ColorStop(1, red)); + + image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); + }, + false, + false); } [Theory] [WithBlankImages(500, 10, PixelTypes.Rgba32)] - public void HorizontalReturnsUnicolorColumns( - TestImageProvider provider) + public void HorizontalReturnsUnicolorColumns(TestImageProvider provider) where TPixel : struct, IPixel { - using (var image = provider.GetImage()) - { - TPixel red = NamedColors.Red; - TPixel yellow = NamedColors.Yellow; - - LinearGradientBrush unicolorLinearGradientBrush = - new LinearGradientBrush( - new SixLabors.Primitives.Point(0, 0), - new SixLabors.Primitives.Point(image.Width, 0), - GradientRepetitionMode.None, - new ColorStop(0, red), - new ColorStop(1, yellow)); - - image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); - image.DebugSave(provider); - image.CompareToReferenceOutput(provider); - } + provider.VerifyOperation( + image => + { + TPixel red = NamedColors.Red; + TPixel yellow = NamedColors.Yellow; + + LinearGradientBrush unicolorLinearGradientBrush = new LinearGradientBrush( + new SixLabors.Primitives.Point(0, 0), + new SixLabors.Primitives.Point(image.Width, 0), + GradientRepetitionMode.None, + new ColorStop(0, red), + new ColorStop(1, yellow)); + + image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); + }, + false, + false); } [Theory] @@ -76,23 +74,23 @@ namespace SixLabors.ImageSharp.Tests.Drawing GradientRepetitionMode repetitionMode) where TPixel : struct, IPixel { - using (var image = provider.GetImage()) - { - TPixel red = NamedColors.Red; - TPixel yellow = NamedColors.Yellow; - - LinearGradientBrush unicolorLinearGradientBrush = - new LinearGradientBrush( - new SixLabors.Primitives.Point(0, 0), - new SixLabors.Primitives.Point(image.Width / 10, 0), - repetitionMode, - new ColorStop(0, red), - new ColorStop(1, yellow)); - - image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); - image.DebugSave(provider, repetitionMode); - image.CompareToReferenceOutput(provider, repetitionMode); - } + provider.VerifyOperation( + image => + { + TPixel red = NamedColors.Red; + TPixel yellow = NamedColors.Yellow; + + var unicolorLinearGradientBrush = new LinearGradientBrush( + new SixLabors.Primitives.Point(0, 0), + new SixLabors.Primitives.Point(image.Width / 10, 0), + repetitionMode, + new ColorStop(0, red), + new ColorStop(1, yellow)); + + image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); + }, + false, + false); } [Theory] @@ -104,7 +102,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing float[] pattern) where TPixel : struct, IPixel { - string variant = string.Join(",", pattern.Select(i => i.ToString(CultureInfo.InvariantCulture))); + string variant = string.Join("_", pattern.Select(i => i.ToString(CultureInfo.InvariantCulture))); // ensure the input data is valid Assert.True(pattern.Length > 0); @@ -127,7 +125,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing using (Image image = provider.GetImage()) { - LinearGradientBrush unicolorLinearGradientBrush = + var unicolorLinearGradientBrush = new LinearGradientBrush( new SixLabors.Primitives.Point(0, 0), new SixLabors.Primitives.Point(image.Width, 0), @@ -135,17 +133,23 @@ namespace SixLabors.ImageSharp.Tests.Drawing colorStops); image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); - image.DebugSave(provider, variant); - - using (PixelAccessor sourcePixels = image.Lock()) - { - // the result must be a black and white pattern, no other color should occur: - Assert.All( - Enumerable.Range(0, image.Width).Select(i => sourcePixels[i, 0]), - color => Assert.True(color.Equals(black) || color.Equals(white))); - } - image.CompareToReferenceOutput(provider, variant); + image.DebugSave( + provider, + variant, + appendPixelTypeToFileName: false, + appendSourceFileOrDescription: false); + + // the result must be a black and white pattern, no other color should occur: + Assert.All( + Enumerable.Range(0, image.Width).Select(i => image[i, 0]), + color => Assert.True(color.Equals(black) || color.Equals(white))); + + image.CompareToReferenceOutput( + provider, + variant, + appendPixelTypeToFileName: false, + appendSourceFileOrDescription: false); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs b/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs index 2177551af3..bfd120fff5 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs @@ -92,7 +92,7 @@ namespace SixLabors.ImageSharp.Tests details = '_' + details; } - return $"{this.GetTestOutputDir()}/{this.TestName}{pixName}{fn}{details}{extension}"; + return TestUtils.AsInvariantString($"{this.GetTestOutputDir()}/{this.TestName}{pixName}{fn}{details}{extension}"); } ///