public static string GetConfigFeature(string configSettingName, TestDataReserve testData, string hostNameKey = "CarBSUri", ConfigSettingType configType = ConfigSettingType.POS) { //create a configuration request data instance ConfigSettingRequestData configSettingRequestData = new ConfigSettingRequestData(hostNameKey, configType); configSettingRequestData.TUID = testData.tuid; string enableValue = null; // get the feature turned value from DB string envKey = ServiceConfigUtil.EnvNameGet(); ///1. mach as EnviromentName and POS's 3 values enableValue = CarBSDB.GetServiceConfig(configSettingName, envKey, testData.JurisdictionCountryCode, testData.CompanyCode, testData.ManagementUnitCode); if (enableValue == null) { ///2. if 1 is null, mach only with EnviromentName enableValue = CarBSDB.GetServiceConfig(configSettingName, envKey); if (enableValue == null) { ///3. if 2 is null, mach as EnviromentName is null enableValue = CarBSDB.GetServiceConfig(configSettingName); if (enableValue == null) { Assert.Fail("No enable feature value for " + configSettingName + "in DB,please check the DB."); } } } return(enableValue); }
// Common way to check the POS config setting value public static void CheckPosConfigFeatureEnable(string configSettingName, string expectedvalue, TestDataReserve testData, bool isUpdateIfNotMatch = false) { //create a configuration request data instance ConfigSettingRequestData configSettingRequestData = new ConfigSettingRequestData("CarBSUri", ConfigSettingType.POS); if (testData != null) { configSettingRequestData.TUID = testData.tuid; } string enableValue = null; // get the feature turned value from DB string envKey = ConfigurationManager.AppSettings["EnvironmentName"]; ///1. mach as EnviromentName and POS's 3 values if (testData != null) { enableValue = CarBSDB.GetServiceConfig(configSettingName, envKey, testData.JurisdictionCountryCode, testData.CompanyCode, testData.ManagementUnitCode); } if (enableValue != null) { // set configuration data by expectedValue where configName/envKey/JurisdictionCountryCode/CompanyCode/ManagementUnitCode have values configSettingRequestData.ConfigSettingDataAdd(new ConfigurationSettingData(env: envKey, sName: configSettingName, sValue: expectedvalue , jCode: testData.JurisdictionCountryCode, cCode: testData.CompanyCode, mUnitCode: testData.ManagementUnitCode, cID: null, sID: null)); //mach value MachExpectedValueinDB(expectedvalue, enableValue, configSettingName, testData.tuid, isUpdateIfNotMatch, configSettingRequestData); } else { ///2. if 1 is null, mach only with EnviromentName enableValue = CarBSDB.GetServiceConfig(configSettingName, envKey); if (enableValue != null) { // set configuration data by expectedValue where configName/envKey have values configSettingRequestData.ConfigSettingDataAdd(new ConfigurationSettingData(env: envKey, sName: configSettingName, sValue: expectedvalue , jCode: null, cCode: null, mUnitCode: null, cID: null, sID: null)); //mach value MachExpectedValueinDB(expectedvalue, enableValue, configSettingName, testData.tuid, isUpdateIfNotMatch, configSettingRequestData); } else { ///3. if 2 is null, mach as EnviromentName is null enableValue = CarBSDB.GetServiceConfig(configSettingName); if (enableValue != null) { // set configuration data by expectedValue where configNam have value configSettingRequestData.ConfigSettingDataAdd(new ConfigurationSettingData(env: null, sName: configSettingName, sValue: expectedvalue , jCode: null, cCode: null, mUnitCode: null, cID: null, sID: null)); //mach value MachExpectedValueinDB(expectedvalue, enableValue, configSettingName, testData.tuid, isUpdateIfNotMatch, configSettingRequestData); } else { Assert.Fail("No enable feature value for " + configSettingName + "in DB,please check the DB."); } } } }