public override IEnumerable <object[]> GetData(MethodInfo testMethod)
        {
            var type = testMethod.GetParameters().First().ParameterType;

            if (!typeof(ITestImageFactory).IsAssignableFrom(type))
            {
                yield return(this.AdditionalParameters);
            }
            else
            {
                foreach (var pixelType in this.PixelTypes.ToTypes())
                {
                    var    packedType  = TestUtilityExtensions.GetPackedType(pixelType);
                    Type[] args        = { pixelType, packedType };
                    var    factoryType = typeof(TestImageFactory <,>).MakeGenericType(args);

                    foreach (object[] originalFacoryMethodArgs in this.GetAllFactoryMethodArgs(testMethod, factoryType))
                    {
                        var actualFactoryMethodArgs = new object[originalFacoryMethodArgs.Length + 1];
                        Array.Copy(originalFacoryMethodArgs, actualFactoryMethodArgs, originalFacoryMethodArgs.Length);
                        actualFactoryMethodArgs[actualFactoryMethodArgs.Length - 1] = testMethod;

                        var factory = factoryType.GetMethod(this.GetFactoryMethodName(testMethod))
                                      .Invoke(null, actualFactoryMethodArgs);

                        object[] result = new object[this.AdditionalParameters.Length + 1];
                        result[0] = factory;
                        Array.Copy(this.AdditionalParameters, 0, result, 1, this.AdditionalParameters.Length);
                        yield return(result);
                    }
                }
            }
        }
예제 #2
0
        public void GetPackedType()
        {
            Type shouldBeUIint32 = TestUtilityExtensions.GetPackedType(typeof(Color));

            Assert.Equal(shouldBeUIint32, typeof(uint));
        }