/// <summary> /// This helps the dependency injection mechanism find assemblies to look for implementations /// </summary> protected virtual void ConfigureDependencyImplentationSelector(ImplementationSelector defaultImplementationSelector) { foreach (Assembly assembly in DependencyImplementationAssemblies.GetAssemblies()) { defaultImplementationSelector.AddAssembly(assembly); } }
/// <summary> /// This injects the current assembly into the DependencyImplementationSelector /// </summary> protected override void ConfigureDependencyImplentationSelector(ImplementationSelector defaultImplementationSelector) { base.ConfigureDependencyImplentationSelector(defaultImplementationSelector); defaultImplementationSelector.AddAssembly(typeof(ODataUnitTestModule).Assembly); defaultImplementationSelector.AddAssembly(typeof(ODataReaderTestCase).Assembly); // TODO: Consider adding this to the base if we find adding spatial to other test projects. defaultImplementationSelector.AddAssembly(typeof(SpatialClrTypeResolver).Assembly); }
/// <summary> /// Initializes a new instance of the DependencyInjectionConfigurator class. /// </summary> /// <param name="implementationSelector">The implementation selector.</param> /// <param name="testParameters">The test parameters.</param> public DependencyInjectionConfigurator(ImplementationSelector implementationSelector, IDictionary <string, string> testParameters) { ExceptionUtilities.CheckArgumentNotNull(implementationSelector, "implementationSelector"); ExceptionUtilities.CheckArgumentNotNull(testParameters, "testParameters"); this.TestParameters = new Dictionary <string, string>(testParameters); this.RootLogger = Logger.Null; this.implementationSelector = implementationSelector; this.loggerResolver = new LogLevelResolver(this.TestParameters); }
/// <summary> /// Initializes a new instance of the DependencyInjectionConfigurator class. /// </summary> /// <param name="implementationSelector">The implementation selector.</param> /// <param name="testParameters">The test parameters.</param> public DependencyInjectionConfigurator(ImplementationSelector implementationSelector, IDictionary<string, string> testParameters) { ExceptionUtilities.CheckArgumentNotNull(implementationSelector, "implementationSelector"); ExceptionUtilities.CheckArgumentNotNull(testParameters, "testParameters"); this.TestParameters = new Dictionary<string, string>(testParameters); this.RootLogger = Logger.Null; this.implementationSelector = implementationSelector; this.loggerResolver = new LogLevelResolver(this.TestParameters); }
protected virtual void ConfigureMSTestDependencies(DependencyInjectionContainer container) { 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>(); // Set test parameter ApplyTransform to false for ODL tests. container.TestParameters.Add("ApplyTransform", "false"); container.RegisterInstance(container); }
/// <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); }
private void ConfigureDependencyInjectionContainer() { this.dependencyInjector = this.moduleDependencyInjectionContainer = new LightweightDependencyInjectionContainer(); var implementationSelector = new ImplementationSelector(); this.ConfigureImplementationSelector(implementationSelector); var configurator = new DependencyInjectionConfigurator(implementationSelector, this.TestParameters); configurator.RootLogger = this.rootLogger; configurator.ConfigureDefaultDependencies(this.moduleDependencyInjectionContainer); this.ConfigureDependencies(this.moduleDependencyInjectionContainer); this.dependencyInjector.InjectDependenciesInto(this); configurator.InitializeGlobalObjects(this.moduleDependencyInjectionContainer); }
private void ShowHelp() { ImplementationSelector dis = new ImplementationSelector(); this.ConfigureImplementationSelector(dis); HelpGenerator hg = new HelpGenerator(this.loggerResolver); string helpText = hg.GetHelpText(dis.Types); this.rootLogger.WriteLine(LogLevel.Info, helpText); }
/// <summary> /// Gets the available parameters for this test module. /// </summary> /// <returns>Array of <see cref="TestParameterInfo"/> that describes allowed test parameters for the test module.</returns> /// <remarks>The parameters are determined by scanning all Taupo and test assemblies /// and examining <see cref="InjectTestParameterAttribute"/>, <see cref="ImplementationSelectorAttribute"/>. /// </remarks> public TestParameterInfo[] GetAvailableParameters() { ImplementationSelector dis = new ImplementationSelector(); this.ConfigureImplementationSelector(dis); HelpGenerator hg = new HelpGenerator(this.loggerResolver); return hg.GetAvailableParameters(dis.Types); }