private bool CheckValidSettings() { string keyName; string err; string serviceName = "postgresql-x64-9.4"; // These keys are always required keyName = "DBTest"; if (!ConnectionExist(keyName)) { err = "Missing connection string " + keyName + " in configuration file"; throw new DataTestLoaderException(err); } dbTest = new ConnectionParser(ConnectionStringDBTest); if (dbTest == null) { err = "Database test is invalid. "; throw new DataTestLoaderException(err); } if (!dbTest.Database.EndsWith("_test")) { err = "The name of database test must be contain the word '_test' at end of name."; throw new DataTestLoaderException(err); } keyName = "DBPostgres"; if (!ConnectionExist(keyName)) { err = "Missing connection string " + keyName + " in configuration file."; throw new DataTestLoaderException(err); } servicePath = GetServicePath(serviceName); if (string.IsNullOrEmpty(servicePath)) { err = string.Format("Postgres DB service {0} is not installed on server {1}. ", serviceName, dbSource.Server); throw new DataTestLoaderException(err); } psqlExe = Path.Combine(this.servicePath, "psql.exe"); pgdumpExe = Path.Combine(this.servicePath, "pg_dump.exe"); keyName = "DBSource"; if (!ConnectionExist(keyName)) { err = "Missing connection string " + keyName + " in configuration file"; throw new DataTestLoaderException(err); } dbSource = new ConnectionParser(ConnectionStringDBSource); if (dbSource == null) { err = "Database source is invalid."; throw new DataTestLoaderException(err); } hostName = GetMachineNameFromIPAddress(dbSource.Server); if (string.IsNullOrEmpty(hostName)) { err = string.Format("Host {0} is not reachable. ", dbSource.Server); throw new DataTestLoaderException(err); } System.Environment.SetEnvironmentVariable("PGPASSWORD", dbSource.Password); keyName = "FileSchemaPreData"; if (!ConfigKeyExist(keyName)) { err = string.Format("Missing key " + keyName + " in configuration file"); throw new DataTestLoaderException(err); } this.FileSchemaPreData = ConfigurationManager.AppSettings[keyName].ToString(); keyName = "FileSchemaPostData"; if (!ConfigKeyExist(keyName)) { err = string.Format("Missing key " + keyName + " in configuration file"); throw new DataTestLoaderException(err); } this.FileSchemaPostData = ConfigurationManager.AppSettings[keyName].ToString(); // the assembly model is required only when it is required to load data from json if (this.loadJsonData == true) { keyName = "AssemblyModel"; if (!ConfigKeyExist(keyName)) { err = string.Format("Missing key " + keyName + " in configuration file"); throw new DataTestLoaderException(err); } keyName = "AssemblyModelNamespace"; if (!ConfigKeyExist(keyName)) { err = string.Format("Missing key " + keyName + " in configuration file"); throw new DataTestLoaderException(err); } if (!File.Exists(Path.Combine(AssemblyDirectory, AssemblyModel + ".dll"))) { err = string.Format("Assembly Model {0} was not found on {1}", AssemblyModel, AssemblyDirectory); throw new DataTestLoaderException(err); } } if (this.testSuite != string.Empty) { if (! Directory.Exists(Path.Combine(AssemblyDirectory, "DataTestFiles", testSuite))) { err = string.Format("'testSuite' argument was specified, ensure that the folder {0} exist or remove this argument.", testSuite); throw new DataTestLoaderException(err); } } logger.Info("All settings are valid. DataTestLoader will run."); return true; }
private bool CheckValidSettings() { string keyName; string err; string serviceName = "postgresql-x64-9.4"; // These keys are always required keyName = "DBTest"; if (!ConnectionExist(keyName)) { err = "Missing connection string " + keyName + " in configuration file"; throw new DataTestLoaderException(err); } dbTest = new ConnectionParser(ConnectionStringDBTest); if (dbTest == null) { err = "Database test is invalid. "; throw new DataTestLoaderException(err); } if (!dbTest.Database.EndsWith("_test")) { err = "The name of database test must be contain the word '_test' at end of name."; throw new DataTestLoaderException(err); } keyName = "DBPostgres"; if (!ConnectionExist(keyName)) { err = "Missing connection string " + keyName + " in configuration file."; throw new DataTestLoaderException(err); } servicePath = GetServicePath(serviceName); if (string.IsNullOrEmpty(servicePath)) { err = string.Format("Postgres DB service {0} is not installed on server {1}. ", serviceName, dbSource.Server); throw new DataTestLoaderException(err); } psqlExe = Path.Combine(this.servicePath, "psql.exe"); pgdumpExe = Path.Combine(this.servicePath, "pg_dump.exe"); keyName = "DBSource"; if (!ConnectionExist(keyName)) { err = "Missing connection string " + keyName + " in configuration file"; throw new DataTestLoaderException(err); } dbSource = new ConnectionParser(ConnectionStringDBSource); if (dbSource == null) { err = "Database source is invalid."; throw new DataTestLoaderException(err); } hostName = GetMachineNameFromIPAddress(dbSource.Server); if (string.IsNullOrEmpty(hostName)) { err = string.Format("Host {0} is not reachable. ", dbSource.Server); throw new DataTestLoaderException(err); } System.Environment.SetEnvironmentVariable("PGPASSWORD", dbSource.Password); keyName = "FileSchemaPreData"; if (!ConfigKeyExist(keyName)) { err = string.Format("Missing key " + keyName + " in configuration file"); throw new DataTestLoaderException(err); } this.FileSchemaPreData = ConfigurationManager.AppSettings[keyName].ToString(); keyName = "FileSchemaPostData"; if (!ConfigKeyExist(keyName)) { err = string.Format("Missing key " + keyName + " in configuration file"); throw new DataTestLoaderException(err); } this.FileSchemaPostData = ConfigurationManager.AppSettings[keyName].ToString(); // the assembly model is required only when it is required to load data from json if (this.loadJsonData == true) { keyName = "AssemblyModel"; if (!ConfigKeyExist(keyName)) { err = string.Format("Missing key " + keyName + " in configuration file"); throw new DataTestLoaderException(err); } keyName = "AssemblyModelNamespace"; if (!ConfigKeyExist(keyName)) { err = string.Format("Missing key " + keyName + " in configuration file"); throw new DataTestLoaderException(err); } if (!File.Exists(Path.Combine(AssemblyDirectory, AssemblyModel + ".dll"))) { err = string.Format("Assembly Model {0} was not found on {1}", AssemblyModel, AssemblyDirectory); throw new DataTestLoaderException(err); } } if (this.testSuite != string.Empty) { if (!Directory.Exists(Path.Combine(AssemblyDirectory, "DataTestFiles", testSuite))) { err = string.Format("'testSuite' argument was specified, ensure that the folder {0} exist or remove this argument.", testSuite); throw new DataTestLoaderException(err); } } logger.Info("All settings are valid. DataTestLoader will run."); return(true); }