public void CanLoadSimpleCustomConfigObject() { SimpleConfigs configSection = GetConfigSection("SimpleConfigsEg1"); Assert.That(configSection.SomeStringConfig, Is.EqualTo("StringValue")); Assert.That(configSection.SomeIntConfig, Is.EqualTo(1)); }
public void CanUpdateConfigsInConfigFile_UseWithCaution() { Configuration configs = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); SimpleConfigs simpleConfigs = (SimpleConfigs)configs.GetSection("SimpleConfigs_Scratch"); simpleConfigs.SomeIntConfig = 22; configs.Save(); }
public void CustomConfigSectionsCanBeMadeToValidateProperties() { Configuration configs = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); SimpleConfigs simpleConfigs = (SimpleConfigs)configs.GetSection("SimpleConfigs_Scratch"); ConfigurationErrorsException ex = Assert.Throws <ConfigurationErrorsException>(delegate { simpleConfigs.SomeStringConfig = "This value is to long for the property"; }); Assert.That(ex.Message, Text.Contains("The value for the property 'SomeStringConfig' is not valid.")); }
public void CanLoadMultipleInstancesOfSimpleCustomConfigObject() { SimpleConfigs simpleConfigs1 = GetConfigSection("SimpleConfigsEg1"); Assert.That(simpleConfigs1.SomeStringConfig, Is.EqualTo("StringValue")); Assert.That(simpleConfigs1.SomeIntConfig, Is.EqualTo(1)); SimpleConfigs simpleConfigs2 = GetConfigSection("SimpleConfigsEg2"); Assert.That(simpleConfigs2.SomeStringConfig, Is.EqualTo("AnotherStringValue")); Assert.That(simpleConfigs2.SomeIntConfig, Is.EqualTo(2)); }