/// <summary>
 /// Triggers passing <see cref="TestImageFactory{TColor,TPacked}"/> instances which return the image produced by the given test class member method
 /// <see cref="TestImageFactory{TColor,TPacked}"/> instances will be passed for each the pixel format defined by the pixelTypes parameter
 /// </summary>
 /// <param name="memberMethodName">The name of the static test class which returns the image</param>
 /// <param name="pixelTypes">The requested pixel types</param>
 /// <param name="additionalParameters">Additional theory parameter values</param>
 public WithMemberFactoryAttribute(string memberMethodName, PixelTypes pixelTypes, params object[] additionalParameters)
     : base(pixelTypes, additionalParameters)
 {
     this.memberMethodName = memberMethodName;
 }
 public void PixelType_PropertyValueIsCorrect <TColor>(TestImageProvider <TColor> provider, PixelTypes expected)
     where TColor : struct, IPackedPixel, IEquatable <TColor>
 {
     Assert.Equal(expected, provider.PixelType);
 }
 private static void AssertContainsPixelType <T>(
     PixelTypes pt,
     IEnumerable <KeyValuePair <PixelTypes, Type> > pixelTypesExp)
 {
     Assert.Contains(new KeyValuePair <PixelTypes, Type>(pt, typeof(T)), pixelTypesExp);
 }
 /// <summary>
 /// Triggers passing an <see cref="TestImageProvider{TPixel}"/> that produces a blank image of size width * height
 /// </summary>
 /// <param name="memberData">The member data</param>
 /// <param name="width">The required width</param>
 /// <param name="height">The required height</param>
 /// <param name="pixelTypes">The requested parameter</param>
 /// <param name="additionalParameters">Additional theory parameter values</param>
 public WithBlankImageAttribute(string memberData, int width, int height, PixelTypes pixelTypes, params object[] additionalParameters)
     : base(memberData, pixelTypes, additionalParameters)
 {
     this.Width  = width;
     this.Height = height;
 }
 public static Type ToType(this PixelTypes pixelType) => PixelTypes2ClrTypes[pixelType];
 public void ToType(PixelTypes pt, Type expectedType)
 {
     Assert.Equal(pt.GetClrType(), expectedType);
 }
示例#7
0
 public static TestImageProvider <TPixel> File(
     string filePath,
     MethodInfo testMethod        = null,
     PixelTypes pixelTypeOverride = PixelTypes.Undefined)
 => new FileProvider(filePath).Init(testMethod, pixelTypeOverride);
示例#8
0
 internal static bool HasAll(this PixelTypes pixelTypes, PixelTypes flagsToCheck) =>
 (pixelTypes & flagsToCheck) == flagsToCheck;
示例#9
0
        protected TestImageProvider <TPixel> Init(string typeName, string methodName, PixelTypes pixelTypeOverride)
        {
            if (pixelTypeOverride != PixelTypes.Undefined)
            {
                this.PixelType = pixelTypeOverride;
            }
            this.TypeName   = typeName;
            this.MethodName = methodName;

            if (pixelTypeOverride == PixelTypes.Rgba32)
            {
                this.Factory = new ImageFactory() as GenericFactory <TPixel>;
            }

            this.Utility = new ImagingTestCaseUtility
            {
                SourceFileOrDescription = this.SourceFileOrDescription,
                PixelTypeName           = this.PixelType.ToString()
            };

            if (methodName != null)
            {
                this.Utility.Init(typeName, methodName);
            }

            return(this);
        }
示例#10
0
 protected TestImageProvider <TPixel> Init(MethodInfo testMethod, PixelTypes pixelTypeOverride)
 {
     return(Init(testMethod?.DeclaringType.Name, testMethod?.Name, pixelTypeOverride));
 }
 /// <summary>
 /// Triggers passing <see cref="TestImageProvider{TPixel}"/> instances which read an image for each file being enumerated by the (static) test class field/property defined by enumeratorMemberName
 /// <see cref="TestImageProvider{TPixel}"/> instances will be passed for each the pixel format defined by the pixelTypes parameter
 /// </summary>
 /// <param name="fileEnumeratorMemberName">The name of the static test class field/property enumerating the files</param>
 /// <param name="pixelTypes">The requested pixel types</param>
 /// <param name="additionalParameters">Additional theory parameter values</param>
 public WithFileCollectionAttribute(
     string fileEnumeratorMemberName,
     PixelTypes pixelTypes,
     params object[] additionalParameters)
     : base(null, pixelTypes, additionalParameters) => this.fileEnumeratorMemberName = fileEnumeratorMemberName;
 /// <summary>
 /// Triggers passing <see cref="TestImageProvider{TPixel}"/> instances which read an image from the given file
 /// One <see cref="TestImageProvider{TPixel}"/> instance will be passed for each the pixel format defined by the pixelTypes parameter
 /// </summary>
 /// <param name="fileName">The name of the file</param>
 /// <param name="pixelTypes">The requested pixel types</param>
 /// <param name="additionalParameters">Additional theory parameter values</param>
 public WithFileAttribute(string fileName, PixelTypes pixelTypes, params object[] additionalParameters)
     : base(null, pixelTypes, additionalParameters) => this.fileName = fileName;
示例#13
0
 public static TestImageProvider <TColor> TestPattern(
     int width,
     int height,
     MethodInfo testMethod        = null,
     PixelTypes pixelTypeOverride = PixelTypes.Undefined)
 => new TestPatternProvider(width, height).Init(testMethod, pixelTypeOverride);
 public static TestImageProvider <TPixel> Blank(
     int width,
     int height,
     MethodInfo testMethod        = null,
     PixelTypes pixelTypeOverride = PixelTypes.Undefined)
 => new BlankProvider(width, height).Init(testMethod, pixelTypeOverride);
示例#15
0
 public static TestImageProvider <TPixel> Lambda(
     string declaringTypeName,
     string methodName,
     MethodInfo testMethod        = null,
     PixelTypes pixelTypeOverride = PixelTypes.Undefined)
 => new MemberMethodProvider(declaringTypeName, methodName).Init(testMethod, pixelTypeOverride);
 public static TestImageProvider <TPixel> Lambda(
     Func <Image <TPixel> > factoryFunc,
     MethodInfo testMethod        = null,
     PixelTypes pixelTypeOverride = PixelTypes.Undefined)
 => new LambdaProvider(factoryFunc).Init(testMethod, pixelTypeOverride);
示例#17
0
            public static Pixel[,] InitFigureBody(FigureType type, PixelTypes pixelType)
            {
                Pixel[,] figureBody = null;

                switch (type)
                {
                case FigureType.I_block:
                {
                    figureBody = new Pixel[1, 4]
                    {
                        { new Pixel(pixelType), new Pixel(pixelType), new Pixel(pixelType), new Pixel(pixelType) }
                    };
                }
                break;

                case FigureType.J_block:
                {
                    figureBody = new Pixel[3, 2]
                    {
                        { null, new Pixel(pixelType) },
                        { null, new Pixel(pixelType) },
                        { new Pixel(pixelType), new Pixel(pixelType) },
                    };
                }
                break;

                case FigureType.L_block:
                {
                    figureBody = new Pixel[3, 2]
                    {
                        { new Pixel(pixelType), null },
                        { new Pixel(pixelType), null },
                        { new Pixel(pixelType), new Pixel(pixelType) },
                    };
                }
                break;

                case FigureType.O_block:
                    figureBody = new Pixel[2, 2]
                    {
                        { new Pixel(pixelType), new Pixel(pixelType) },
                        { new Pixel(pixelType), new Pixel(pixelType) },
                    };
                    break;

                case FigureType.S_block:
                    figureBody = new Pixel[2, 3]
                    {
                        { null, new Pixel(pixelType), new Pixel(pixelType) },
                        { new Pixel(pixelType), new Pixel(pixelType), null },
                    };
                    break;

                case FigureType.T_block:
                    figureBody = new Pixel[2, 3]
                    {
                        { new Pixel(pixelType), new Pixel(pixelType), new Pixel(pixelType) },
                        { null, new Pixel(pixelType), null },
                    };
                    break;

                case FigureType.Z_block:
                    figureBody = new Pixel[2, 3]
                    {
                        { new Pixel(pixelType), new Pixel(pixelType), null },
                        { null, new Pixel(pixelType), new Pixel(pixelType) },
                    };
                    break;
                }

                return(figureBody);
            }
示例#18
0
 public void PixelType_PropertyValueIsCorrect <TPixel>(TestImageProvider <TPixel> provider, PixelTypes expected)
     where TPixel : struct, IPixel <TPixel>
 {
     Assert.Equal(expected, provider.PixelType);
 }
 public static TestImageProvider <TColor> Lambda(
     Func <GenericFactory <TColor>, Image <TColor> > func,
     MethodInfo testMethod        = null,
     PixelTypes pixelTypeOverride = PixelTypes.Undefined)
 => new LambdaProvider(func).Init(testMethod, pixelTypeOverride);
 public static bool HasFlag(this PixelTypes pixelTypes, PixelTypes flag) => (pixelTypes & flag) == flag;
示例#21
0
 /// <summary>
 /// Triggers passing <see cref="TestImageProvider{TPixel}"/> instances which read an image from the given file
 /// One <see cref="TestImageProvider{TPixel}"/> instance will be passed for each the pixel format defined by the pixelTypes parameter
 /// </summary>
 /// <param name="fileName">The name of the file</param>
 /// <param name="pixelTypes">The requested pixel types</param>
 /// <param name="additionalParameters">Additional theory parameter values</param>
 public WithFileAttribute(string fileName, string dataMemberName, PixelTypes pixelTypes, params object[] additionalParameters)
     : base(dataMemberName, pixelTypes, additionalParameters)
 {
     this.fileName = fileName;
 }
 public void GetPixelType(Type clrType, PixelTypes expectedPixelType)
 {
     Assert.Equal(expectedPixelType, clrType.GetPixelType());
 }
示例#23
0
 public Pixel(PixelTypes type)
 {
     Color  = Console.ForegroundColor;
     Symbol = (char)type;
 }
示例#24
0
 /// <summary>
 /// Triggers passing an <see cref="TestImageProvider{TPixel}"/> that produces a blank image of size width * height
 /// </summary>
 /// <param name="width">The required width</param>
 /// <param name="height">The required height</param>
 /// <param name="pixelTypes">The requested parameter</param>
 /// <param name="additionalParameters">Additional theory parameter values</param>
 public WithBlankImagesAttribute(int width, int height, PixelTypes pixelTypes, params object[] additionalParameters)
     : base(null, pixelTypes, additionalParameters)
 {
     this.Width  = width;
     this.Height = height;
 }
示例#25
0
 public Pixel(ConsoleColor color, PixelTypes pixelType)
 {
     Symbol = (char)pixelType;
     Color  = color;
 }
示例#26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImageDataAttributeBase"/> class.
 /// </summary>
 /// <param name="memberName"></param>
 /// <param name="pixelTypes"></param>
 /// <param name="additionalParameters"></param>
 protected ImageDataAttributeBase(string memberName, PixelTypes pixelTypes, object[] additionalParameters)
 {
     this.PixelTypes           = pixelTypes;
     this.AdditionalParameters = additionalParameters;
     this.MemberName           = memberName;
 }
 protected ImageDataAttributeBase(PixelTypes pixelTypes, object[] additionalParameters)
 {
     this.PixelTypes           = pixelTypes;
     this.AdditionalParameters = additionalParameters;
 }
 public WithBasicTestPatternImagesAttribute(int width, int height, PixelTypes pixelTypes, params object[] additionalParameters)
     : this(null, width, height, pixelTypes, additionalParameters)
 {
 }
示例#29
0
 public InputImageProvider(InputImage image, PixelTypes pixelType)
 {
     Image     = image;
     PixelType = pixelType;
 }