public void TestDefaultGetSetConfigValues() { // Load a configuration in StfConfiguration var stfConfiguration = new StfConfiguration(@"TestData\Defaulting\DefaultSectionWithEnvironments.xml"); stfConfiguration.Environment = stfConfiguration.DefaultEnvironment; var dUsername = stfConfiguration.GetConfigValue("Users.Username"); var dPassword = stfConfiguration.GetConfigValue("Users.Password"); StfAssert.AreEqual("Default Username is User_Kasper", "User_Kasper", dUsername); StfAssert.AreEqual("Default Password is K999", "K999", dPassword); var newUserName = "******"; var newUserPassword = "******"; stfConfiguration.SetConfigValue("Users.Username", newUserName); stfConfiguration.SetConfigValue("Users.Password", newUserPassword); dUsername = stfConfiguration.GetConfigValue("Users.Username"); dPassword = stfConfiguration.GetConfigValue("Users.Password"); StfAssert.AreEqual("Default Username is updated", newUserName, dUsername); StfAssert.AreEqual("Default Password is updated", newUserPassword, dPassword); }
public void TestSetValueOnExistingKey() { var stfConfiguration = new StfConfiguration(@"TestData\Defaulting\NoDefaultSection.xml"); StfAssert.IsFalse("Trying to set non existing value", stfConfiguration.SetConfigValue("Users.Ulrich.FortyTwo", "New_Ulrich")); string configValue; StfAssert.IsFalse("Can't get value", stfConfiguration.TryGetKeyValue("Users.Ulrich.FortyTwo", out configValue)); }
public void TestSetValue() { // Load a configuration in StfConfiguration var stfConfiguration = new StfConfiguration(@"TestData\Defaulting\NoDefaultSection.xml"); var uUsername = stfConfiguration.GetKeyValue("Users.Ulrich.Username"); var uPassword = stfConfiguration.GetKeyValue("Users.Ulrich.Password"); var kUsername = stfConfiguration.GetKeyValue("Users.Kasper.Username"); var kPassword = stfConfiguration.GetKeyValue("Users.Kasper.Password"); StfAssert.AreEqual("Username is Ulrich", "User_Ulrich", uUsername); StfAssert.AreEqual("Password for Ulrich is U777", "U777", uPassword); StfAssert.AreEqual("Username is Kasper", "User_Kasper", kUsername); StfAssert.AreEqual("Password for Kasper is K999", "K999", kPassword); StfAssert.IsTrue("Setting config value", stfConfiguration.SetConfigValue("Users.Ulrich.Username", "New_Ulrich")); StfAssert.AreEqual("Username for Ulrich updated", "New_Ulrich", stfConfiguration.GetKeyValue("Users.Ulrich.Username")); StfAssert.IsTrue("Setting config value", stfConfiguration.SetConfigValue("Users.Ulrich.Password", "Super1234")); StfAssert.AreEqual("Password for Ulrich updated", "Super1234", stfConfiguration.GetKeyValue("Users.Ulrich.Password")); }