コード例 #1
0
        /// <summary>
        /// Injects default dependencies when Taupo runner is not being used
        /// </summary>
        protected void InjectDependencies()
        {
            var container = new LightweightDependencyInjectionContainer();

            this.ConfigureMSTestDependencies(container);
            container.InjectDependenciesInto(this);
        }
コード例 #2
0
        /// <summary>
        /// Injects default dependencies when Taupo runner is not being used
        /// </summary>
        protected void InjectDependencies()
        {
            var container = new LightweightDependencyInjectionContainer();

            ImplementationSelector defaultImplSelector = new ImplementationSelector();

            this.ConfigureDependencyImplentationSelector(defaultImplSelector);

            DependencyInjectionConfigurator dependInjecConfigurator = new DependencyInjectionConfigurator(defaultImplSelector, new Dictionary <string, string>());

            dependInjecConfigurator.ConfigureDefaultDependencies(container);

            this.ConfigureDependencies(container);

            // Configure MSTest only dependencies
            container.Register <Logger, TraceLogger>();

            container.RegisterInstance(container);
            container.InjectDependenciesInto(this);
        }
コード例 #3
0
ファイル: RunnerStrategy.cs プロジェクト: zhonli/odata.net
        /// <summary>
        /// Creates an instance of the ITestModuleRunner
        /// </summary>
        /// <param name="runnerType">The type of the runner to create</param>
        /// <returns>An implementation of the ITestModuleRunner </returns>
        public ITestModuleRunner CreateRunner(Type runnerType)
        {
            LightweightDependencyInjectionContainer dependencyInjectionContainer = null;
            ITestModuleRunner runner = null;

            try
            {
#if SILVERLIGHT
                runner = Activator.CreateInstance(runnerType) as ITestModuleRunner;
#else
                runner = new RunnerBridge(runnerType);
#endif
                dependencyInjectionContainer = new LightweightDependencyInjectionContainer();
                var implementationSelector = new ImplementationSelector();
                implementationSelector.AddAssembly(typeof(TestItem).GetAssembly());

                var helpGenerator       = new HelpGenerator(new LogLevelResolver(this.Parameters));
                var availableParameters = helpGenerator.GetAvailableParameters(implementationSelector.Types);
                Dictionary <string, string> availableParametersLookup = this.Parameters.Where(kvp => availableParameters.Any(p => p.ParameterName == kvp.Key)).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);

                // Any TestParameters passed in are not used for injecting dependencies into RunnerBridge
                var configurator = new DependencyInjectionConfigurator(
                    implementationSelector,
                    availableParametersLookup);

                configurator.RootLogger = Logger.Null;
                configurator.ConfigureDefaultDependencies(dependencyInjectionContainer);

                dependencyInjectionContainer.InjectDependenciesInto(runner);
            }
            finally
            {
                if (dependencyInjectionContainer != null)
                {
                    dependencyInjectionContainer.Dispose();
                }
            }

            return(runner);
        }
コード例 #4
0
        /// <summary>
        /// Injects default dependencies when Taupo runner is not being used
        /// </summary>
        protected void InjectDependencies()
        {
            var container = new LightweightDependencyInjectionContainer();

            ImplementationSelector defaultImplSelector = new ImplementationSelector();
            this.ConfigureDependencyImplentationSelector(defaultImplSelector);

            DependencyInjectionConfigurator dependInjecConfigurator = new DependencyInjectionConfigurator(defaultImplSelector, new Dictionary<string, string>());
            dependInjecConfigurator.ConfigureDefaultDependencies(container);

            this.ConfigureDependencies(container);

            // Configure MSTest only dependencies
            container.Register<Logger, TraceLogger>();

            container.RegisterInstance(container);
            container.InjectDependenciesInto(this);
        }
コード例 #5
0
 /// <summary>
 /// Injects default dependencies when Taupo runner is not being used
 /// </summary>
 protected void InjectDependencies()
 {
     var container = new LightweightDependencyInjectionContainer();
     this.ConfigureMSTestDependencies(container);
     container.InjectDependenciesInto(this);
 }