Beispiel #1
0
        public DeveroomConfiguration Load(string configFilePath)
        {
            var config = new DeveroomConfiguration();

            Update(config, configFilePath);
            return(config);
        }
Beispiel #2
0
        public void Update(DeveroomConfiguration config, string configFileContent, string configFolder)
        {
            _configDeserializer.Populate(configFileContent, config);

            config.ConfigurationBaseFolder = configFolder;

            config.SpecFlow.ConfigFilePath  = EnsureFullPath(config, c => c.SpecFlow.ConfigFilePath);
            config.SpecFlow.GeneratorFolder = EnsureFullPath(config, c => c.SpecFlow.GeneratorFolder, isFolder: true);
        }
Beispiel #3
0
        public void Update(DeveroomConfiguration config, string configFilePath)
        {
            if (!File.Exists(configFilePath))
            {
                throw new DeveroomConfigurationException($"The specified config file '{configFilePath}' does not exist.");
            }
            var configFolder = Path.GetDirectoryName(configFilePath) ??
                               throw new DeveroomConfigurationException($"The specified config file '{configFilePath}' does not contain a folder.");

            var jsonString = File.ReadAllText(configFilePath);

            Update(config, jsonString, configFolder);
        }
Beispiel #4
0
        private string EnsureFullPath(DeveroomConfiguration config, string filePath, string label, bool isFolder = false)
        {
            if (filePath == null)
            {
                return(null);
            }
            filePath = ExpandEnvironmentVariables(filePath);
            var fullPath = Path.GetFullPath(Path.Combine(config.ConfigurationBaseFolder, filePath));

            if (!isFolder && !File.Exists(fullPath))
            {
                throw new DeveroomConfigurationException($"Unable to access file '{fullPath}'. Please make sure you specify a path for an existing file for the {label} option.");
            }
            if (isFolder && !Directory.Exists(fullPath))
            {
                throw new DeveroomConfigurationException($"Unable to access directory '{fullPath}'. Please make sure you specify a path for an existing directory for the {label} option.");
            }
            return(fullPath);
        }
Beispiel #5
0
 protected bool Equals(DeveroomConfiguration other)
 {
     return(string.Equals(ConfigurationBaseFolder, other.ConfigurationBaseFolder) && Equals(SpecFlow, other.SpecFlow) && Equals(Traceability, other.Traceability) && ProcessorArchitecture == other.ProcessorArchitecture && DebugConnector == other.DebugConnector && string.Equals(DefaultFeatureLanguage, other.DefaultFeatureLanguage) && string.Equals(ConfiguredBindingCulture, other.ConfiguredBindingCulture));
 }
Beispiel #6
0
 public void Populate(string jsonString, DeveroomConfiguration config)
 {
     JsonConvert.PopulateObject(jsonString, config, GetJsonSerializerSettings(true));
 }
Beispiel #7
0
        private string EnsureFullPath(DeveroomConfiguration config, Expression <Func <DeveroomConfiguration, string> > configAccessor, bool isFolder = false)
        {
            var filePath = configAccessor.Compile().Invoke(config);

            return(EnsureFullPath(config, filePath, configAccessor.ToString(), isFolder));
        }