Exemplo n.º 1
0
        internal void UpdateFromConfigFile(ConfigurationSectionHandler configSection)
        {
            if (configSection == null) throw new ArgumentNullException("configSection");

            if (configSection.Language != null)
            {
                FeatureLanguage = CultureInfo.GetCultureInfo(configSection.Language.Feature);
                ToolLanguage = string.IsNullOrEmpty(configSection.Language.Tool) ? FeatureLanguage :
                    CultureInfo.GetCultureInfo(configSection.Language.Tool);
            }

            if (configSection.UnitTestProvider != null)
            {
                SetUnitTestDefaultsByName(configSection.UnitTestProvider.Name);

                if (!string.IsNullOrEmpty(configSection.UnitTestProvider.GeneratorProvider))
                    GeneratorUnitTestProviderType = GetTypeConfig(configSection.UnitTestProvider.GeneratorProvider);

                //TODO: config.CheckUnitTestConfig();
            }

            if (configSection.Generator != null)
            {
                AllowDebugGeneratedFiles = configSection.Generator.AllowDebugGeneratedFiles;
            }
        }
 static public ConfigurationSectionHandler CreateFromXml(string xmlContent)
 {
     ConfigurationSectionHandler section = new ConfigurationSectionHandler();
     section.Init();
     section.Reset(null);
     using (var reader = new XmlTextReader(new StringReader(xmlContent.Trim())))
     {
         section.DeserializeSection(reader);
     }
     section.ResetModified();
     return section;
 }
 static public ConfigurationSectionHandler CreateFromXml(XmlNode xmlContent)
 {
     ConfigurationSectionHandler section = new ConfigurationSectionHandler();
     section.Init();
     section.Reset(null);
     using (var reader = new XmlNodeReader(xmlContent))
     {
         section.DeserializeSection(reader);
     }
     section.ResetModified();
     return section;
 }
        internal RuntimeConfigurationForGenerator UpdateFromConfigFile(ConfigurationSectionHandler configSection)
        {
            if (configSection == null) throw new ArgumentNullException("configSection");

            var config = this;
            if (configSection.Language != null)
            {
                config.ToolLanguage = string.IsNullOrEmpty(configSection.Language.Tool) ?
                    CultureInfo.GetCultureInfo(configSection.Language.Feature) :
                    CultureInfo.GetCultureInfo(configSection.Language.Tool);
            }

            if (configSection.BindingCulture.ElementInformation.IsPresent)
            {
                config.BindingCulture = CultureInfo.GetCultureInfo(configSection.BindingCulture.Name);
            }

//            if (configSection.UnitTestProvider != null)
//            {
//                config.SetUnitTestDefaultsByName(configSection.UnitTestProvider.Name);
//
//                if (!string.IsNullOrEmpty(configSection.UnitTestProvider.RuntimeProvider))
//                    config.RuntimeUnitTestProviderType = GetTypeConfig(configSection.UnitTestProvider.RuntimeProvider);
//
                //TODO: config.CheckUnitTestConfig();
//            }

            if (configSection.Runtime != null)
            {
                config.DetectAmbiguousMatches = configSection.Runtime.DetectAmbiguousMatches;
                config.StopAtFirstError = configSection.Runtime.StopAtFirstError;
                config.MissingOrPendingStepsOutcome = configSection.Runtime.MissingOrPendingStepsOutcome;
            }

            if (configSection.Trace != null)
            {
//                if (!string.IsNullOrEmpty(configSection.Trace.Listener))
//                    config.TraceListenerType = GetTypeConfig(configSection.Trace.Listener);

                config.TraceSuccessfulSteps = configSection.Trace.TraceSuccessfulSteps;
                config.TraceTimings = configSection.Trace.TraceTimings;
                config.MinTracedDuration = configSection.Trace.MinTracedDuration;
            }

            foreach (var element in configSection.StepAssemblies)
            {
                var stepAssembly = ((StepAssemblyConfigElement)element).Assembly;
                config._additionalStepAssemblies.Add(stepAssembly);
            }

            return config;
        }
        static public ConfigurationSectionHandler CreateFromXml(string xmlContent)
        {
            ConfigurationSectionHandler section = new ConfigurationSectionHandler();

            section.Init();
            section.Reset(null);
            using (var reader = new XmlTextReader(new StringReader(xmlContent.Trim())))
            {
                section.DeserializeSection(reader);
            }
            section.ResetModified();
            return(section);
        }
        static public ConfigurationSectionHandler CreateFromXml(XmlNode xmlContent)
        {
            ConfigurationSectionHandler section = new ConfigurationSectionHandler();

            section.Init();
            section.Reset(null);
            using (var reader = new XmlNodeReader(xmlContent))
            {
                section.DeserializeSection(reader);
            }
            section.ResetModified();
            return(section);
        }
Exemplo n.º 7
0
        internal RuntimeConfigurationForGenerator UpdateFromConfigFile(ConfigurationSectionHandler configSection)
        {
            if (configSection == null) throw new ArgumentNullException("configSection");

            var config = this;

            foreach (var element in configSection.StepAssemblies)
            {
                var stepAssembly = ((StepAssemblyConfigElement)element).Assembly;
                config.additionalStepAssemblies.Add(stepAssembly);
            }

            return config;
        }
Exemplo n.º 8
0
        internal void UpdateFromConfigFile(ConfigurationSectionHandler configSection)
        {
            if (configSection == null) throw new ArgumentNullException("configSection");

            if (IsSpecified(configSection.Language))
            {
                FeatureLanguage = CultureInfo.GetCultureInfo(configSection.Language.Feature);
                ToolLanguage = string.IsNullOrEmpty(configSection.Language.Tool) ?
                    CultureInfo.GetCultureInfo(configSection.Language.Feature) :
                    CultureInfo.GetCultureInfo(configSection.Language.Tool);
            }

            if (IsSpecified(configSection.Generator))
            {
                AllowDebugGeneratedFiles = configSection.Generator.AllowDebugGeneratedFiles;
                AllowRowTests = configSection.Generator.AllowRowTests;
                GenerateAsyncTests = configSection.Generator.GenerateAsyncTests;
                GeneratorPath = configSection.Generator.GeneratorPath;

                if (IsSpecified(configSection.Generator.Dependencies))
                {
                    this.CustomDependencies = configSection.Generator.Dependencies;
                    UsesPlugins = true;
                }
            }

            if (IsSpecified(configSection.UnitTestProvider))
            {
                if (!string.IsNullOrEmpty(configSection.UnitTestProvider.GeneratorProvider))
                {
                    //compatibility mode, we simulate a custom dependency

                    if (this.CustomDependencies == null)
                        this.CustomDependencies = new ContainerRegistrationCollection();

                    this.GeneratorUnitTestProvider = "custom";
                    this.CustomDependencies.Add(configSection.UnitTestProvider.GeneratorProvider, typeof(IUnitTestGeneratorProvider).AssemblyQualifiedName, this.GeneratorUnitTestProvider);

                    UsesPlugins = true;
                }
                else
                {
                    this.GeneratorUnitTestProvider = configSection.UnitTestProvider.Name;
                }
            }

            if (IsSpecified(configSection.Plugins))
                UsesPlugins = true;
        }
Exemplo n.º 9
0
        public static RuntimeConfiguration LoadFromConfigFile(ConfigurationSectionHandler configSection)
        {
            if (configSection == null) throw new ArgumentNullException("configSection");

            var config = new RuntimeConfiguration();
            if (configSection.Language != null)
            {
                config.ToolLanguage = string.IsNullOrEmpty(configSection.Language.Tool) ?
                    CultureInfo.GetCultureInfo(configSection.Language.Feature) :
                    CultureInfo.GetCultureInfo(configSection.Language.Tool);
            }

            if (configSection.UnitTestProvider != null)
            {
                config.SetUnitTestDefaultsByName(configSection.UnitTestProvider.Name);

                if (!string.IsNullOrEmpty(configSection.UnitTestProvider.RuntimeProvider))
                    config.RuntimeUnitTestProviderType = GetTypeConfig(configSection.UnitTestProvider.RuntimeProvider);

                //TODO: config.CheckUnitTestConfig();
            }

            if (configSection.Runtime != null)
            {
                config.DetectAmbiguousMatches = configSection.Runtime.DetectAmbiguousMatches;
                config.StopAtFirstError = configSection.Runtime.StopAtFirstError;
                config.MissingOrPendingStepsOutcome = configSection.Runtime.MissingOrPendingStepsOutcome;
            }

            if (configSection.Trace != null)
            {
                if (!string.IsNullOrEmpty(configSection.Trace.Listener))
                    config.TraceListenerType = GetTypeConfig(configSection.Trace.Listener);

                config.TraceSuccessfulSteps = configSection.Trace.TraceSuccessfulSteps;
                config.TraceTimings = configSection.Trace.TraceTimings;
                config.MinTracedDuration = configSection.Trace.MinTracedDuration;
            }

            foreach (var element in configSection.StepAssemblies)
            {
                string stepAssemblyFileName = ((StepAssemblyConfigElement)element).File;
                string fullPath = Path.GetFullPath(stepAssemblyFileName);
                Assembly stepAssembly = Assembly.LoadFile(fullPath);
                config._additionalStepAssemblies.Add(stepAssembly);
            }

            return config;
        }
Exemplo n.º 10
0
        internal void LoadConfiguration(ConfigurationSectionHandler configSection)
        {
            if (configSection == null) throw new ArgumentNullException("configSection");

            if (IsSpecified(configSection.BindingCulture))
            {
                this.BindingCulture = CultureInfo.GetCultureInfo(configSection.BindingCulture.Name);
            }

            foreach (var element in configSection.StepAssemblies)
            {
                var stepAssembly = ((StepAssemblyConfigElement)element).Assembly;
                this.additionalStepAssemblies.Add(stepAssembly);
            }
        }
Exemplo n.º 11
0
        internal RuntimeConfigurationForGenerator UpdateFromConfigFile(ConfigurationSectionHandler configSection)
        {
            if (configSection == null)
            {
                throw new ArgumentNullException("configSection");
            }

            var config = this;

            foreach (var element in configSection.StepAssemblies)
            {
                var stepAssembly = ((StepAssemblyConfigElement)element).Assembly;
                config.additionalStepAssemblies.Add(stepAssembly);
            }

            return(config);
        }
Exemplo n.º 12
0
        public SpecFlowConfiguration Load(SpecFlowConfiguration specFlowConfiguration, SpecFlowConfigurationHolder specFlowConfigurationHolder)
        {
            switch (specFlowConfigurationHolder.ConfigSource)
            {
            case ConfigSource.Default:
                return(GetDefault());

            case ConfigSource.AppConfig:
                return(LoadAppConfig(specFlowConfiguration,
                                     ConfigurationSectionHandler.CreateFromXml(specFlowConfigurationHolder.Content)));

            case ConfigSource.Json:
                return(LoadJson(specFlowConfiguration, specFlowConfigurationHolder.Content));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 13
0
        internal void UpdateFromConfigFile(ConfigurationSectionHandler configSection, bool loadPlugins)
        {
            if (configSection == null) throw new ArgumentNullException("configSection");

            if (configSection.Language != null)
            {
                FeatureLanguage = CultureInfo.GetCultureInfo(configSection.Language.Feature);
                ToolLanguage = string.IsNullOrEmpty(configSection.Language.Tool) ? FeatureLanguage :
                    CultureInfo.GetCultureInfo(configSection.Language.Tool);
            }

            if (configSection.UnitTestProvider != null)
            {
                SetUnitTestDefaultsByName(configSection.UnitTestProvider.Name);

                if (!string.IsNullOrEmpty(configSection.UnitTestProvider.GeneratorProvider))
                {
                    if (loadPlugins)
                        GeneratorUnitTestProviderType = GetTypeConfig(configSection.UnitTestProvider.GeneratorProvider);
                    UsesPlugins = true;
                }

                //TODO: config.CheckUnitTestConfig();
            }

            if (configSection.Generator != null)
            {
                AllowDebugGeneratedFiles = configSection.Generator.AllowDebugGeneratedFiles;
                AllowRowTests = configSection.Generator.AllowRowTests;
                GenerateAsyncTests = configSection.Generator.GenerateAsyncTests;
                GeneratorPath = configSection.Generator.GeneratorPath;
            }

            if (configSection.Generator != null && configSection.Generator.Dependencies != null)
            {
                CustomDependencies = configSection.Generator.Dependencies;
                UsesPlugins = true; //TODO: this calculation can be refined later
            }
        }
Exemplo n.º 14
0
        public void LoadConfiguration(ConfigurationSectionHandler configSection)
        {
            if (configSection == null)
            {
                throw new ArgumentNullException("configSection");
            }

            if (IsSpecified(configSection.Language))
            {
                FeatureLanguage   = CultureInfo.GetCultureInfo(configSection.Language.Feature);
                this.ToolLanguage = string.IsNullOrEmpty(configSection.Language.Tool) ?
                                    CultureInfo.GetCultureInfo(configSection.Language.Feature) :
                                    CultureInfo.GetCultureInfo(configSection.Language.Tool);
            }

            if (IsSpecified(configSection.BindingCulture))
            {
                this.BindingCulture = CultureInfo.GetCultureInfo(configSection.BindingCulture.Name);
            }

            if (IsSpecified(configSection.Runtime))
            {
                this.DetectAmbiguousMatches       = configSection.Runtime.DetectAmbiguousMatches;
                this.StopAtFirstError             = configSection.Runtime.StopAtFirstError;
                this.MissingOrPendingStepsOutcome = configSection.Runtime.MissingOrPendingStepsOutcome;

                if (IsSpecified(configSection.Runtime.Dependencies))
                {
                    this.CustomDependencies = configSection.Runtime.Dependencies;
                }
            }

            if (IsSpecified(configSection.UnitTestProvider))
            {
                if (!string.IsNullOrEmpty(configSection.UnitTestProvider.RuntimeProvider))
                {
                    //compatibility mode, we simulate a custom dependency
                    this.RuntimeUnitTestProvider = "custom";
                    AddCustomDependency(configSection.UnitTestProvider.RuntimeProvider, typeof(IUnitTestRuntimeProvider), this.RuntimeUnitTestProvider);
                }
                else
                {
                    this.RuntimeUnitTestProvider = configSection.UnitTestProvider.Name;
                }
            }

            if (IsSpecified(configSection.Trace))
            {
                if (!string.IsNullOrEmpty(configSection.Trace.Listener)) // backwards compatibility
                {
                    AddCustomDependency(configSection.Trace.Listener, typeof(ITraceListener));
                }

                this.TraceSuccessfulSteps        = configSection.Trace.TraceSuccessfulSteps;
                this.TraceTimings                = configSection.Trace.TraceTimings;
                this.MinTracedDuration           = configSection.Trace.MinTracedDuration;
                this.StepDefinitionSkeletonStyle = configSection.Trace.StepDefinitionSkeletonStyle;
            }

            foreach (var element in configSection.StepAssemblies)
            {
                var assemblyName = ((StepAssemblyConfigElement)element).Assembly;
                this.AdditionalStepAssemblies.Add(assemblyName);
            }
        }
Exemplo n.º 15
0
        public void LoadConfiguration(ConfigurationSectionHandler configSection)
        {
            if (configSection == null) throw new ArgumentNullException("configSection");

            if (IsSpecified(configSection.Language))
            {
                this.ToolLanguage = string.IsNullOrEmpty(configSection.Language.Tool) ?
                    CultureInfo.GetCultureInfo(configSection.Language.Feature) :
                    CultureInfo.GetCultureInfo(configSection.Language.Tool);
            }

            if (IsSpecified(configSection.BindingCulture))
            {
                this.BindingCulture = CultureInfo.GetCultureInfo(configSection.BindingCulture.Name);
            }

            if (IsSpecified(configSection.Runtime))
            {
                this.DetectAmbiguousMatches = configSection.Runtime.DetectAmbiguousMatches;
                this.StopAtFirstError = configSection.Runtime.StopAtFirstError;
                this.MissingOrPendingStepsOutcome = configSection.Runtime.MissingOrPendingStepsOutcome;

                if (IsSpecified(configSection.Runtime.Dependencies))
                {
                    this.CustomDependencies = configSection.Runtime.Dependencies;
                }
            }

            if (IsSpecified(configSection.UnitTestProvider))
            {
                if (!string.IsNullOrEmpty(configSection.UnitTestProvider.RuntimeProvider))
                {
                    //compatibility mode, we simulate a custom dependency

                    if (this.CustomDependencies == null)
                        this.CustomDependencies = new ContainerRegistrationCollection();

                    this.RuntimeUnitTestProvider = "custom";
                    this.CustomDependencies.Add(configSection.UnitTestProvider.RuntimeProvider, typeof(IUnitTestRuntimeProvider).AssemblyQualifiedName, this.RuntimeUnitTestProvider);
                }
                else
                {
                    this.RuntimeUnitTestProvider = configSection.UnitTestProvider.Name;
                }
            }

            if (IsSpecified(configSection.Trace))
            {
                if (!string.IsNullOrEmpty(configSection.Trace.Listener))
                    this.TraceListenerType = GetTypeConfig(configSection.Trace.Listener);

                this.TraceSuccessfulSteps = configSection.Trace.TraceSuccessfulSteps;
                this.TraceTimings = configSection.Trace.TraceTimings;
                this.MinTracedDuration = configSection.Trace.MinTracedDuration;
            }

            foreach (var element in configSection.StepAssemblies)
            {
                Assembly stepAssembly = Assembly.Load(((StepAssemblyConfigElement)element).Assembly);
                this.additionalStepAssemblies.Add(stepAssembly);
            }
        }
Exemplo n.º 16
0
        public void LoadConfiguration(ConfigurationSectionHandler configSection)
        {
            if (configSection == null)
            {
                throw new ArgumentNullException("configSection");
            }

            if (IsSpecified(configSection.Language))
            {
                this.ToolLanguage = string.IsNullOrEmpty(configSection.Language.Tool) ?
                                    CultureInfo.GetCultureInfo(configSection.Language.Feature) :
                                    CultureInfo.GetCultureInfo(configSection.Language.Tool);
            }

            if (IsSpecified(configSection.BindingCulture))
            {
                this.BindingCulture = CultureInfo.GetCultureInfo(configSection.BindingCulture.Name);
            }

            if (IsSpecified(configSection.Runtime))
            {
                this.DetectAmbiguousMatches       = configSection.Runtime.DetectAmbiguousMatches;
                this.StopAtFirstError             = configSection.Runtime.StopAtFirstError;
                this.MissingOrPendingStepsOutcome = configSection.Runtime.MissingOrPendingStepsOutcome;

                if (IsSpecified(configSection.Runtime.Dependencies))
                {
                    this.CustomDependencies = configSection.Runtime.Dependencies;
                }
            }

            if (IsSpecified(configSection.UnitTestProvider))
            {
                if (!string.IsNullOrEmpty(configSection.UnitTestProvider.RuntimeProvider))
                {
                    //compatibility mode, we simulate a custom dependency

                    if (this.CustomDependencies == null)
                    {
                        this.CustomDependencies = new ContainerRegistrationCollection();
                    }

                    this.RuntimeUnitTestProvider = "custom";
                    this.CustomDependencies.Add(configSection.UnitTestProvider.RuntimeProvider, typeof(IUnitTestRuntimeProvider).AssemblyQualifiedName, this.RuntimeUnitTestProvider);
                }
                else
                {
                    this.RuntimeUnitTestProvider = configSection.UnitTestProvider.Name;
                }
            }

            if (IsSpecified(configSection.Trace))
            {
                if (!string.IsNullOrEmpty(configSection.Trace.Listener))
                {
                    this.TraceListenerType = GetTypeConfig(configSection.Trace.Listener);
                }

                this.TraceSuccessfulSteps = configSection.Trace.TraceSuccessfulSteps;
                this.TraceTimings         = configSection.Trace.TraceTimings;
                this.MinTracedDuration    = configSection.Trace.MinTracedDuration;
            }

            foreach (var element in configSection.StepAssemblies)
            {
                Assembly stepAssembly = Assembly.Load(((StepAssemblyConfigElement)element).Assembly);
                this.additionalStepAssemblies.Add(stepAssembly);
            }
        }
Exemplo n.º 17
0
        public void LoadConfiguration(ConfigurationSectionHandler configSection)
        {
            if (configSection == null) throw new ArgumentNullException("configSection");

            if (IsSpecified(configSection.Language))
            {
                FeatureLanguage = CultureInfo.GetCultureInfo(configSection.Language.Feature);
                this.ToolLanguage = string.IsNullOrEmpty(configSection.Language.Tool) ?
                    CultureInfo.GetCultureInfo(configSection.Language.Feature) :
                    CultureInfo.GetCultureInfo(configSection.Language.Tool);
            }

            if (IsSpecified(configSection.BindingCulture))
            {
                this.BindingCulture = CultureInfo.GetCultureInfo(configSection.BindingCulture.Name);
            }

            if (IsSpecified(configSection.Runtime))
            {
                this.DetectAmbiguousMatches = configSection.Runtime.DetectAmbiguousMatches;
                this.StopAtFirstError = configSection.Runtime.StopAtFirstError;
                this.MissingOrPendingStepsOutcome = configSection.Runtime.MissingOrPendingStepsOutcome;

                if (IsSpecified(configSection.Runtime.Dependencies))
                {
                    this.CustomDependencies = configSection.Runtime.Dependencies;
                }
            }

            if (IsSpecified(configSection.UnitTestProvider))
            {
                if (!string.IsNullOrEmpty(configSection.UnitTestProvider.RuntimeProvider))
                {
                    //compatibility mode, we simulate a custom dependency
                    this.RuntimeUnitTestProvider = "custom";
                    AddCustomDependency(configSection.UnitTestProvider.RuntimeProvider, typeof(IUnitTestRuntimeProvider), this.RuntimeUnitTestProvider);
                }
                else
                {
                    this.RuntimeUnitTestProvider = configSection.UnitTestProvider.Name;
                }
            }

            if (IsSpecified(configSection.Trace))
            {
                if (!string.IsNullOrEmpty(configSection.Trace.Listener)) // backwards compatibility
                {
                    AddCustomDependency(configSection.Trace.Listener, typeof(ITraceListener));
                }

                this.TraceSuccessfulSteps = configSection.Trace.TraceSuccessfulSteps;
                this.TraceTimings = configSection.Trace.TraceTimings;
                this.MinTracedDuration = configSection.Trace.MinTracedDuration;
                this.StepDefinitionSkeletonStyle = configSection.Trace.StepDefinitionSkeletonStyle;
            }

            foreach (var element in configSection.StepAssemblies)
            {
                var assemblyName = ((StepAssemblyConfigElement)element).Assembly;
                this.AdditionalStepAssemblies.Add(assemblyName);
            }
        }
 internal virtual void UpdateRuntimeConfiguration(SpecFlowProjectConfiguration configuration, ConfigurationSectionHandler specFlowConfigSection)
 {
     configuration.RuntimeConfiguration.UpdateFromConfigFile(specFlowConfigSection);
 }
Exemplo n.º 19
0
 private SpecFlowConfiguration LoadAppConfig(SpecFlowConfiguration specFlowConfiguration,
                                             ConfigurationSectionHandler specFlowConfigSection)
 {
     return(_appConfigConfigurationLoader.LoadAppConfig(specFlowConfiguration, specFlowConfigSection));
 }
 internal override void UpdateGeneratorConfiguration(SpecFlowProjectConfiguration configuration, ConfigurationSectionHandler specFlowConfigSection)
 {
     configuration.GeneratorConfiguration.UpdateFromConfigFile(specFlowConfigSection, false);
 }
 internal virtual void UpdateGeneratorConfiguration(SpecFlowProjectConfiguration configuration, ConfigurationSectionHandler specFlowConfigSection)
 {
     configuration.GeneratorConfiguration.UpdateFromConfigFile(specFlowConfigSection, true);
 }
Exemplo n.º 22
0
 public SpecFlowConfiguration Update(SpecFlowConfiguration specFlowConfiguration, ConfigurationSectionHandler specFlowConfigSection)
 {
     return(LoadAppConfig(specFlowConfiguration, specFlowConfigSection));
 }