Exemple #1
0
        public SpecFlowConfiguration LoadConfiguration(SpecFlowConfiguration specFlowConfiguration)
        {
            if (IsJsonConfig)
            {
                var jsonConfigurationLoader = new JsonConfigurationLoader();

                return(jsonConfigurationLoader.LoadJson(specFlowConfiguration, configFileContent));
            }

            ConfigurationSectionHandler section = GetSection();

            var runtimeConfigurationLoader = new AppConfigConfigurationLoader();

            return(runtimeConfigurationLoader.LoadAppConfig(specFlowConfiguration, section));
        }
Exemple #2
0
        public SpecFlowConfiguration Load(SpecFlowConfiguration specFlowConfiguration)
        {
            if (_configFilePath == null)
            {
                return(LoadDefaultConfiguration(specFlowConfiguration));
            }

            var extension         = Path.GetExtension(_configFilePath);
            var configFileContent = File.ReadAllText(_configFilePath);

            switch (extension.ToLowerInvariant())
            {
            case ".config":
            {
                var configDocument = new XmlDocument();
                configDocument.LoadXml(configFileContent);
                var specFlowNode = configDocument.SelectSingleNode("/configuration/specFlow");
                if (specFlowNode == null)
                {
                    return(LoadDefaultConfiguration(specFlowConfiguration));
                }

                var configSection = ConfigurationSectionHandler.CreateFromXml(specFlowNode);
                var loader        = new AppConfigConfigurationLoader();
                return(loader.LoadAppConfig(specFlowConfiguration, configSection));
            }

            case ".json":
            {
                if (_jsonSpecFlow2Mode)
                {
                    configFileContent = ConvertToJsonSpecFlow2Style(configFileContent);
                }

                var loader = new JsonConfigurationLoader();
                return(loader.LoadJson(specFlowConfiguration, configFileContent));
            }
            }
            throw new ConfigurationErrorsException($"Invalid config type: {_configFilePath}");
        }
Exemple #3
0
        public void CanLoadConfigFromString(string configString)
        {
            var configurationLoader = new JsonConfigurationLoader();

            configurationLoader.LoadJson(ConfigurationLoader.GetDefault(), configString);
        }
 private SpecFlowConfiguration LoadJson(SpecFlowConfiguration specFlowConfiguration, string jsonContent)
 {
     return(_jsonConfigurationLoader.LoadJson(specFlowConfiguration, jsonContent));
 }