diff --git a/tests/ImageSharp.Tests/Drawing/FillLinearGradientBrushTests.cs b/tests/ImageSharp.Tests/Drawing/FillLinearGradientBrushTests.cs index 9ea7ff08ad..07bdbc74e5 100644 --- a/tests/ImageSharp.Tests/Drawing/FillLinearGradientBrushTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillLinearGradientBrushTests.cs @@ -12,9 +12,12 @@ using SixLabors.ImageSharp.Processing.Drawing; using SixLabors.ImageSharp.Processing.Drawing.Brushes.GradientBrushes; using Xunit; +// ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests.Drawing { + using SixLabors.ImageSharp.Advanced; + [GroupOutput("Drawing/GradientBrushes")] public class FillLinearGradientBrushTests { @@ -51,7 +54,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing TPixel red = NamedColors.Red; TPixel yellow = NamedColors.Yellow; - LinearGradientBrush unicolorLinearGradientBrush = new LinearGradientBrush( + var unicolorLinearGradientBrush = new LinearGradientBrush( new SixLabors.Primitives.Point(0, 0), new SixLabors.Primitives.Point(image.Width, 0), GradientRepetitionMode.None, @@ -155,57 +158,41 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Theory] [WithBlankImages(10, 500, PixelTypes.Rgba32)] - public void VerticalReturnsUnicolorColumns( + public void VerticalBrushReturnsUnicolorRows( TestImageProvider provider) where TPixel : struct, IPixel { - using (var image = provider.GetImage()) - { - int lastRowIndex = image.Height - 1; - - TPixel red = NamedColors.Red; - TPixel yellow = NamedColors.Yellow; + 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(0, image.Height), - GradientRepetitionMode.None, - new ColorStop(0, red), - new ColorStop(1, yellow)); + var unicolorLinearGradientBrush = new LinearGradientBrush( + new SixLabors.Primitives.Point(0, 0), + new SixLabors.Primitives.Point(0, image.Height), + GradientRepetitionMode.None, + new ColorStop(0, red), + new ColorStop(1, yellow)); - image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); - image.DebugSave(provider); + image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); - Random random = new Random(); + VerifyAllRowsAreUnicolor(image); + }, + false, + false); - using (PixelAccessor sourcePixels = image.Lock()) + void VerifyAllRowsAreUnicolor(Image image) + { + for (int y = 0; y < image.Height; y++) { - TPixel firstRowColor = sourcePixels[0, 0]; - - int columnA = random.Next(0, image.Height); - int columnB = random.Next(0, image.Height); - int columnC = random.Next(0, image.Height); - TPixel columnColorA = sourcePixels[0, columnA]; - TPixel columnColorB = sourcePixels[0, columnB]; - TPixel columnColorC = sourcePixels[0, columnC]; - - TPixel lastRowColor = sourcePixels[0, lastRowIndex]; - - for (int i = 0; i < image.Width; i++) + Span row = image.GetPixelRowSpan(y); + TPixel firstColorOfRow = row[0]; + foreach (TPixel p in row) { - // check first and last column, these are known: - Assert.Equal(firstRowColor, sourcePixels[i, 0]); - Assert.Equal(lastRowColor, sourcePixels[i, lastRowIndex]); - - // check the random colors: - Assert.Equal(columnColorA, sourcePixels[i, columnA]); - Assert.Equal(columnColorB, sourcePixels[i, columnB]); - Assert.Equal(columnColorC, sourcePixels[i, columnC]); + Assert.Equal(firstColorOfRow, p); } } - - image.CompareToReferenceOutput(provider); } }