public StepArgumentTypeConverter(ITestTracer testTracer, IBindingRegistry bindingRegistry, IContextManager contextManager, IBindingInvoker bindingInvoker)
 {
     this.testTracer = testTracer;
     this.bindingRegistry = bindingRegistry;
     this.contextManager = contextManager;
     this.bindingInvoker = bindingInvoker;
 }
Exemplo n.º 2
0
        public TestRunner()
        {
            errorProvider = ObjectContainer.ErrorProvider;
            testTracer = ObjectContainer.TestTracer;
            unitTestRuntimeProvider = ObjectContainer.UnitTestRuntimeProvider;
            stepFormatter = ObjectContainer.StepFormatter;
 
            bindingRegistry = ObjectContainer.BindingRegistry;
            stepArgumentTypeConverter = ObjectContainer.StepArgumentTypeConverter;
        }
Exemplo n.º 3
0
 public StepArgumentTypeConverter(ITestTracer testTracer, IBindingRegistry bindingRegistry, IContextManager contextManager, IBindingInvoker bindingInvoker)
 {
     converters = new IStepArgumentTypeConverter[]
     {
         new IndentityConverter(),
         new StepArgumentTransformationConverter(this, testTracer, bindingRegistry, contextManager, bindingInvoker),
         new VerticalTableConverter(this),
         new HorizontalTableConverter(this),
         new SimpleConverter()
     };
 }
Exemplo n.º 4
0
        public object InvokeBinding(IBinding binding, IContextManager contextManager, object[] arguments, ITestTracer testTracer, out TimeSpan duration)
        {
            MethodInfo methodInfo;
            Delegate bindingAction;
            EnsureReflectionInfo(binding, out methodInfo, out bindingAction);

            try
            {
                object result;
                Stopwatch stopwatch = new Stopwatch();
                using (CreateCultureInfoScope(contextManager))
                {
                    stopwatch.Start();
                    object[] invokeArgs = new object[arguments == null ? 1 : arguments.Length + 1];
                    if (arguments != null)
                        Array.Copy(arguments, 0, invokeArgs, 1, arguments.Length);
                    invokeArgs[0] = contextManager;
                    result = bindingAction.DynamicInvoke(invokeArgs);

                    if (result is Task)
                    {
                        ((Task) result).Wait();
                    }

                    stopwatch.Stop();
                }

                if (runtimeConfiguration.TraceTimings && stopwatch.Elapsed >= runtimeConfiguration.MinTracedDuration)
                {
                    testTracer.TraceDuration(stopwatch.Elapsed, binding.Method, arguments);
                }

                duration = stopwatch.Elapsed;
                return result;
            }
            catch (ArgumentException ex)
            {
                throw errorProvider.GetCallError(binding.Method, ex);
            }
            catch (TargetInvocationException invEx)
            {
                var ex = invEx.InnerException;
                ex = ex.PreserveStackTrace(errorProvider.GetMethodText(binding.Method));
                throw ex;
            }
            catch (AggregateException agEx)  //from Task.Wait();
            {
                var ex = agEx.InnerExceptions.First();
                ex = ex.PreserveStackTrace(errorProvider.GetMethodText(binding.Method));
                throw ex;
            }
        }
Exemplo n.º 5
0
        public TestExecutionEngine(IStepFormatter stepFormatter, ITestTracer testTracer, IErrorProvider errorProvider, IStepArgumentTypeConverter stepArgumentTypeConverter, 
            RuntimeConfiguration runtimeConfiguration, IBindingRegistry bindingRegistry, IUnitTestRuntimeProvider unitTestRuntimeProvider, 
            IDictionary<ProgrammingLanguage, IStepDefinitionSkeletonProvider> stepDefinitionSkeletonProviders, IContextManager contextManager)
        {
            this.errorProvider = errorProvider;
            this.contextManager = contextManager;
            this.stepDefinitionSkeletonProviders = stepDefinitionSkeletonProviders;
            this.unitTestRuntimeProvider = unitTestRuntimeProvider;
            this.bindingRegistry = bindingRegistry;
            this.runtimeConfiguration = runtimeConfiguration;
            this.testTracer = testTracer;
            this.stepFormatter = stepFormatter;
            this.stepArgumentTypeConverter = stepArgumentTypeConverter;

            this.currentStepDefinitionSkeletonProvider = stepDefinitionSkeletonProviders[ProgrammingLanguage.CSharp]; // fallback if feature initialization was not proper
        }
Exemplo n.º 6
0
 public TestExecutionEngine(IStepFormatter stepFormatter, ITestTracer testTracer, IErrorProvider errorProvider, IStepArgumentTypeConverter stepArgumentTypeConverter, 
     RuntimeConfiguration runtimeConfiguration, IBindingRegistry bindingRegistry, IUnitTestRuntimeProvider unitTestRuntimeProvider, 
     IStepDefinitionSkeletonProvider stepDefinitionSkeletonProvider, IContextManager contextManager, IStepDefinitionMatchService stepDefinitionMatchService,
     IDictionary<string, IStepErrorHandler> stepErrorHandlers, IBindingInvoker bindingInvoker)
 {
     this.errorProvider = errorProvider;
     this.bindingInvoker = bindingInvoker;
     this.contextManager = contextManager;
     this.unitTestRuntimeProvider = unitTestRuntimeProvider;
     this.stepDefinitionSkeletonProvider = stepDefinitionSkeletonProvider;
     this.bindingRegistry = bindingRegistry;
     this.runtimeConfiguration = runtimeConfiguration;
     this.testTracer = testTracer;
     this.stepFormatter = stepFormatter;
     this.stepArgumentTypeConverter = stepArgumentTypeConverter;
     this.stepErrorHandlers = stepErrorHandlers == null ? null : stepErrorHandlers.Values.ToArray();
     this.stepDefinitionMatchService = stepDefinitionMatchService;
 }
Exemplo n.º 7
0
        public TestExecutionEngine(IStepFormatter stepFormatter, ITestTracer testTracer, IErrorProvider errorProvider, IStepArgumentTypeConverter stepArgumentTypeConverter, 
            RuntimeConfiguration runtimeConfiguration, IBindingRegistry bindingRegistry, IUnitTestRuntimeProvider unitTestRuntimeProvider, 
            IDictionary<ProgrammingLanguage, IStepDefinitionSkeletonProvider> stepDefinitionSkeletonProviders, IContextManager contextManager, IStepDefinitionMatchService stepDefinitionMatchService,
            IDictionary<string, IStepErrorHandler> stepErrorHandlers, IBindingInvoker bindingInvoker, IRuntimeBindingRegistryBuilder bindingRegistryBuilder)
        {
            this.errorProvider = errorProvider;
            //this.stepDefinitionMatcher = stepDefinitionMatcher;
            this.bindingInvoker = bindingInvoker;
            this.bindingRegistryBuilder = bindingRegistryBuilder;
            this.contextManager = contextManager;
            this.stepDefinitionSkeletonProviders = stepDefinitionSkeletonProviders;
            this.unitTestRuntimeProvider = unitTestRuntimeProvider;
            this.bindingRegistry = bindingRegistry;
            this.runtimeConfiguration = runtimeConfiguration;
            this.testTracer = testTracer;
            this.stepFormatter = stepFormatter;
            this.stepArgumentTypeConverter = stepArgumentTypeConverter;
            this.stepErrorHandlers = stepErrorHandlers == null ? null : stepErrorHandlers.Values.ToArray();

            this.currentStepDefinitionSkeletonProvider = stepDefinitionSkeletonProviders[ProgrammingLanguage.CSharp]; // fallback if feature initialization was not proper

            this.stepDefinitionMatchService = stepDefinitionMatchService;
        }
Exemplo n.º 8
0
 public object Transform(string value, ITestTracer testTracer)
 {
     var arguments = GetStepTransformationArguments(value);
     return InvokeAction(arguments, testTracer);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Creates a test thread object container and registers the provided test tracer.
 /// </summary>
 /// <param name="testTracer">The test tracer that will be registered.</param>
 /// <returns>An object that implements <see cref="IObjectContainer"/>.</returns>
 private IObjectContainer CreateTestThreadObjectContainer(ITestTracer testTracer)
 {
     IObjectContainer container;
     TestObjectFactories.CreateTestRunner(
         out container,
         objectContainer => objectContainer.RegisterInstanceAs<ITestTracer>(testTracer));
     return container;
 }
Exemplo n.º 10
0
 public object InvokeAction(object[] arguments, ITestTracer testTracer)
 {
     TimeSpan duration;
     return InvokeAction(arguments, testTracer, out duration);
 }
Exemplo n.º 11
0
 public static void InvokeHook(this IBindingInvoker invoker, IHookBinding hookBinding, IContextManager contextManager, ITestTracer testTracer)
 {
     TimeSpan duration;
     invoker.InvokeBinding(hookBinding, contextManager, null, testTracer, out duration);
 }
Exemplo n.º 12
0
        public object InvokeAction(IContextManager contextManager, object[] arguments, ITestTracer testTracer, out TimeSpan duration)
        {
            try
            {
                object result;
                Stopwatch stopwatch = new Stopwatch();
                using (CreateCultureInfoScope(contextManager))
                {
                    stopwatch.Start();
                    object[] invokeArgs = new object[arguments == null ? 1 : arguments.Length + 1];
                    if (arguments != null)
                        Array.Copy(arguments, 0, invokeArgs, 1, arguments.Length);
                    invokeArgs[0] = contextManager;
                    result = BindingAction.DynamicInvoke(invokeArgs);
                    stopwatch.Stop();
                }

                if (runtimeConfiguration.TraceTimings && stopwatch.Elapsed >= runtimeConfiguration.MinTracedDuration)
                {
                    testTracer.TraceDuration(stopwatch.Elapsed, MethodInfo, arguments);
                }

                duration = stopwatch.Elapsed;
                return result;
            }
            catch (ArgumentException ex)
            {
                throw errorProvider.GetCallError(MethodInfo, ex);
            }
            catch (TargetInvocationException invEx)
            {
                var ex = invEx.InnerException;
                ex = ex.PreserveStackTrace(errorProvider.GetMethodText(MethodInfo));
                throw ex;
            }
        }
Exemplo n.º 13
0
 public object InvokeAction(IContextManager contextManager, object[] arguments, ITestTracer testTracer)
 {
     TimeSpan duration;
     return InvokeAction(contextManager, arguments, testTracer, out duration);
 }
 public RuntimeBindingSourceProcessor(IBindingFactory bindingFactory, IBindingRegistry bindingRegistry, IErrorProvider errorProvider, ITestTracer testTracer) : base(bindingFactory)
 {
     this.bindingRegistry = bindingRegistry;
     this.errorProvider = errorProvider;
     this.testTracer = testTracer;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Resolves the context manager and registers the provided test tracer.
 /// </summary>
 /// <param name="testTracer">The test tracer that will be registered.</param>
 /// <returns>An object that implements <see cref="IContextManager"/>.</returns>
 private IContextManager ResolveContextManager(ITestTracer testTracer)
 {
     var container = this.CreateTestThreadObjectContainer(testTracer);
     var contextManager = container.Resolve<IContextManager>();
     return contextManager;
 }
Exemplo n.º 16
0
 public StepArgumentTypeConverter(ITestTracer testTracer, IBindingRegistry bindingRegistry, IContextManager contextManager)
 {
     this.testTracer = testTracer;
     this.contextManager = contextManager;
     StepTransformations = bindingRegistry.StepTransformations ?? new List<StepTransformationBinding>();
 }
Exemplo n.º 17
0
 public StepArgumentTypeConverter()
 {
     testTracer = ObjectContainer.TestTracer;
     StepTransformations = ObjectContainer.BindingRegistry.StepTransformations ?? new List<StepTransformationBinding>();
 }
Exemplo n.º 18
0
        public object InvokeAction(object[] arguments, ITestTracer testTracer, out TimeSpan duration)
        {
            try
            {
                object result;
                Stopwatch stopwatch = new Stopwatch();
                using (CreateCultureInfoScope())
                {
                    stopwatch.Start();
                    result = BindingAction.DynamicInvoke(arguments);
                    stopwatch.Stop();
                }

                if (RuntimeConfiguration.Current.TraceTimings && stopwatch.Elapsed >= RuntimeConfiguration.Current.MinTracedDuration)
                {
                    testTracer.TraceDuration(stopwatch.Elapsed, MethodInfo, arguments);
                }

                duration = stopwatch.Elapsed;
                return result;
            }
            catch (ArgumentException ex)
            {
                throw errorProvider.GetCallError(MethodInfo, ex);
            }
            catch (TargetInvocationException invEx)
            {
                var ex = invEx.InnerException;
                ex = ex.PreserveStackTrace(errorProvider.GetMethodText(MethodInfo));
                throw ex;
            }
        }
Exemplo n.º 19
0
 public void Invoke(IContextManager contextManager, ITestTracer testTracer)
 {
     InvokeAction(contextManager, null, testTracer);
 }