Beispiel #1
0
 public ExecuteBeforeAfterAttributesMessageBusInjection(IMethodInfo method, ITypeInfo typeInfo)
 {
     _beforeAfterAttributes = typeInfo.ToRuntimeType().GetTypeInfo().GetCustomAttributes(typeof(BeforeCtorAfterDisposeAttribute))
                              .Concat(method.ToRuntimeMethod().GetCustomAttributes(typeof(BeforeCtorAfterDisposeAttribute)))
                              .Cast <BeforeCtorAfterDisposeAttribute>()
                              .ToList();
 }
Beispiel #2
0
        public ScenarioInfo(IMethodInfo testMethod, object[] dataRow, string scenarioOutlineDisplayName)
        {
            var parameters     = testMethod.GetParameters().ToList();
            var typeParameters = testMethod.GetGenericArguments().ToList();

            ITypeInfo[] typeArguments;
            if (testMethod.IsGenericMethodDefinition)
            {
                typeArguments = typeParameters
                                .Select(typeParameter => InferTypeArgument(typeParameter.Name, parameters, dataRow))
                                .ToArray();

                this.MethodToRun = testMethod.MakeGenericMethod(typeArguments).ToRuntimeMethod();
            }
            else
            {
                typeArguments    = new ITypeInfo[0];
                this.MethodToRun = testMethod.ToRuntimeMethod();
            }

            var passedArguments = Reflector.ConvertArguments(
                dataRow, this.MethodToRun.GetParameters().Select(p => p.ParameterType).ToArray());

            var generatedArguments = GetGeneratedArguments(
                typeParameters, typeArguments, parameters, passedArguments.Length);

            var arguments = passedArguments
                            .Select(value => new Argument(value))
                            .Concat(generatedArguments)
                            .ToList();

            this.ScenarioDisplayName = GetScenarioDisplayName(scenarioOutlineDisplayName, typeArguments, parameters, arguments);
            this.ConvertedDataRow    = arguments.Select(argument => argument.Value).ToList();
        }
 public ExecuteBeforeAfterAttributesMessageBusInjection(IMethodInfo method, ITypeInfo typeInfo)
 {
     _beforeAfterAttributes = typeInfo.ToRuntimeType().GetTypeInfo().GetCustomAttributes(typeof(BeforeCtorAfterDisposeAttribute))
         .Concat(method.ToRuntimeMethod().GetCustomAttributes(typeof(BeforeCtorAfterDisposeAttribute)))
         .Cast<BeforeCtorAfterDisposeAttribute>()
         .ToList();
 }
        private MethodInfo GetMethodInfo(IMethodInfo testMethod)
        {
#if DNX
            var toRuntimeMethod = typeof(ReflectionAbstractionExtensions).GetMethod("ToRuntimeMethod");

            return((MethodInfo)toRuntimeMethod.Invoke(null, new object[] { testMethod }));
#else
            return(testMethod.ToRuntimeMethod());
#endif
        }
        public ScenarioInfo(IMethodInfo testMethod, object[] actualArgs, string scenarioOutlineDisplayName)
        {
            //Guard.AgainstNullArgument(nameof(testMethod), testMethod);

#if DEBUG
            testMethod = testMethod.RequiresNotNull(nameof(testMethod));
#endif

            // Which, we "do", in DEBUG mode.
#pragma warning disable CA1062 // ...validate parameter 'name' is non-null before using it...
            var parameters = testMethod.GetParameters().ToList();
#pragma warning restore CA1062 // ...validate parameter 'name' is non-null before using it...

            var typeParams = testMethod.GetGenericArguments().ToList();

            ITypeInfo[] typeArgs;
            if (testMethod.IsGenericMethodDefinition)
            {
                typeArgs = typeParams
                           .Select(typeParameter => InferTypeArgument(typeParameter.Name, parameters, actualArgs))
                           .ToArray();

                this.MethodToRun = testMethod.MakeGenericMethod(typeArgs).ToRuntimeMethod();
            }
            else
            {
                typeArgs         = Array.Empty <ITypeInfo>();
                this.MethodToRun = testMethod.ToRuntimeMethod();
            }

            var passedArgs = Reflector.ConvertArguments(actualArgs, this.MethodToRun.GetParameters().Select(p => p.ParameterType).ToArray());

            var generatedArguments = GetGeneratedArguments(typeParams, typeArgs, parameters, passedArgs.Length);

            var args = passedArgs
                       .Select(value => new Argument(value))
                       .Concat(generatedArguments)
                       .ToList();

            this.ScenarioDisplayName = GetScenarioDisplayName(scenarioOutlineDisplayName, typeArgs, parameters, args);
            this.ConvertedActualArgs = args.Select(arg => arg.Value).ToList();
        }
Beispiel #6
0
        private TestRunner CreateTestRunner(ITest test, IMethodInfo testMethod, string skipReason, Type testNotificationType, string source)
        {
            var method = testMethod.ToRuntimeMethod();

            return(new TestRunner(test, MessageBus, ConstructorArguments, method, skipReason, new ExceptionAggregator(Aggregator), CancellationTokenSource, testNotificationType, source));
        }