public Settings(string name, string configFile, Func<string, bool> fileExists, string baseDirectory, ITestLogger logger) { Name = name; Logger = logger; try { Directory = Path.GetDirectoryName(configFile); SettingsFile = configFile; Json.PopulateFromFile(SettingsFile, this); Name = Name ?? name; BatchInterval = BatchInterval ?? 250; if (AreValid) { LogDirectory = GetFullPath(LogDirectory ?? ""); if (LogToFile) { logger.AddLogger(LogFilePath); } } else { LogDirectory = ""; LogToFile = false; } } catch (Exception ex) { _validator.Validate(false, "Could not read settings: {0}", ex.Message); logger.Error(ex, "Could not read settings"); } }
public KarmaSettings(string name, string configFile, Func <string, bool> fileExists, string baseDirectory, ITestLogger logger) { HasSettingsFile = false; Name = name; Logger = logger; try { Directory = Path.GetDirectoryName(configFile); SettingsFile = GetFullPath(Globals.SettingsFilename); KarmaConfigFile = GetFullPath(Globals.KarmaConfigFilename); if (PathUtils.PathHasFileName(configFile, Globals.SettingsFilename)) { Json.PopulateFromFile(configFile, this); KarmaConfigFile = string.IsNullOrWhiteSpace(KarmaConfigFile) ? GetFullPath(Globals.KarmaConfigFilename) : GetFullPath(KarmaConfigFile); _validator.Validate(fileExists(SettingsFile), "Settings file not found: {0}", PathUtils.GetRelativePath(baseDirectory, SettingsFile)); _validator.Validate(fileExists(KarmaConfigFile), "Karma configuration file not found: {0}", PathUtils.GetRelativePath(baseDirectory, KarmaConfigFile)); HasSettingsFile = true; } else { KarmaConfigFile = GetFullPath(configFile); _validator.Validate(fileExists(KarmaConfigFile), "Karma configuration file not found: {0}", PathUtils.GetRelativePath(baseDirectory, KarmaConfigFile)); } Name = Name ?? name; if (AreValid) { LogDirectory = GetFullPath(LogDirectory ?? ""); if (LogToFile) { logger.AddLogger(LogFilePath); } } else { LogDirectory = ""; LogToFile = false; } } catch (Exception ex) { _validator.Validate(false, "Could not read settings: {0}", ex.Message); logger.Error(ex, "Could not read settings"); } }
public KarmaSettings(string name, string configFile, Func<string, bool> fileExists, string baseDirectory, ITestLogger logger) { HasSettingsFile = false; Name = name; Logger = logger; try { Directory = Path.GetDirectoryName(configFile); SettingsFile = GetFullPath(Globals.SettingsFilename); KarmaConfigFile = GetFullPath(Globals.KarmaConfigFilename); if (PathUtils.PathHasFileName(configFile, Globals.SettingsFilename)) { Json.PopulateFromFile(configFile, this); KarmaConfigFile = string.IsNullOrWhiteSpace(KarmaConfigFile) ? GetFullPath(Globals.KarmaConfigFilename) : GetFullPath(KarmaConfigFile); _validator.Validate(fileExists(SettingsFile), "Settings file not found: {0}", PathUtils.GetRelativePath(baseDirectory, SettingsFile)); _validator.Validate(fileExists(KarmaConfigFile), "Karma configuration file not found: {0}", PathUtils.GetRelativePath(baseDirectory, KarmaConfigFile)); HasSettingsFile = true; } else { KarmaConfigFile = GetFullPath(configFile); _validator.Validate(fileExists(KarmaConfigFile), "Karma configuration file not found: {0}", PathUtils.GetRelativePath(baseDirectory, KarmaConfigFile)); } Name = Name ?? name; if (AreValid) { LogDirectory = GetFullPath(LogDirectory ?? ""); if (LogToFile) { logger.AddLogger(LogFilePath); } } else { LogDirectory = ""; LogToFile = false; } } catch (Exception ex) { _validator.Validate(false, "Could not read settings: {0}", ex.Message); logger.Error(ex, "Could not read settings"); } }