// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; using System.Reflection; namespace SixLabors.ImageSharp.Tests { using SixLabors.ImageSharp.PixelFormats; /// /// Triggers passing instances which produce an image of size width * height filled with the requested color. /// One instance will be passed for each the pixel format defined by the pixelTypes parameter /// public class WithSolidFilledImagesAttribute : WithBlankImagesAttribute { /// /// Triggers passing instances which produce an image of size width * height filled with the requested color. /// One instance will be passed for each the pixel format defined by the pixelTypes parameter /// /// The width of the requested image /// The height of the requested image /// Red /// Green /// Blue /// The requested pixel types /// Additional theory parameter values public WithSolidFilledImagesAttribute( int width, int height, byte r, byte g, byte b, PixelTypes pixelTypes, params object[] additionalParameters) : this(width, height, r, g, b, 255, pixelTypes, additionalParameters) { } /// /// Triggers passing instances which produce an image of size width * height filled with the requested color. /// One instance will be passed for each the pixel format defined by the pixelTypes parameter /// /// The width of the requested image /// The height of the requested image /// Red /// Green /// Blue /// /// Alpha /// The requested pixel types /// Additional theory parameter values public WithSolidFilledImagesAttribute( int width, int height, byte r, byte g, byte b, byte a, PixelTypes pixelTypes, params object[] additionalParameters) : this(null, width, height, r, g, b, a, pixelTypes, additionalParameters) { } /// /// Triggers passing instances which produce an image of size width * height filled with the requested color. /// One instance will be passed for each the pixel format defined by the pixelTypes parameter /// /// The member data to apply to theories /// The width of the requested image /// The height of the requested image /// Red /// Green /// Blue /// /// Alpha /// The requested pixel types /// Additional theory parameter values public WithSolidFilledImagesAttribute( string memberData, int width, int height, byte r, byte g, byte b, byte a, PixelTypes pixelTypes, params object[] additionalParameters) : base(memberData, width, height, pixelTypes, additionalParameters) { this.R = r; this.G = g; this.B = b; this.A = a; } /// /// Triggers passing instances which produce an image of size width * height filled with the requested color. /// One instance will be passed for each the pixel format defined by the pixelTypes parameter /// /// The width of the requested image /// The height of the requested image /// The referenced color name (name of property in ). /// The requested pixel types /// Additional theory parameter values public WithSolidFilledImagesAttribute( int width, int height, string colorName, PixelTypes pixelTypes, params object[] additionalParameters) : this(null, width, height, colorName, pixelTypes, additionalParameters) { } /// /// Triggers passing instances which produce an image of size width * height filled with the requested color. /// One instance will be passed for each the pixel format defined by the pixelTypes parameter /// /// The member data to apply to theories /// The width of the requested image /// The height of the requested image /// The referenced color name (name of property in ). /// The requested pixel types /// Additional theory parameter values public WithSolidFilledImagesAttribute( string memberData, int width, int height, string colorName, PixelTypes pixelTypes, params object[] additionalParameters) : base(memberData, width, height, pixelTypes, additionalParameters) { Guard.NotNull(colorName, nameof(colorName)); Rgba32 c = TestUtils.GetPixelOfNamedColor(colorName); this.R = c.R; this.G = c.G; this.B = c.B; this.A = c.A; } /// /// Red /// public byte R { get; } /// /// Green /// public byte G { get; } /// /// Blue /// public byte B { get; } /// /// Alpha /// public byte A { get; } protected override object[] GetFactoryMethodArgs(MethodInfo testMethod, Type factoryType) => new object[] { this.Width, this.Height, this.R, this.G, this.B, this.A }; protected override string GetFactoryMethodName(MethodInfo testMethod) => "Solid"; } }