public void SettingAValueForAnExistingKeyOverrides() { var section = new ConfigurationSection(SectionName); section.Set(Key, Value); Assert.Equal(Value, section.Get <string>(Key)); section.Set(Key, Key); Assert.Equal(Key, section.Get <string>(Key)); }
public void CanReadAddedValue() { var section = new ConfigurationSection( SectionName ); section.Set( Key, Value ); var value = section.Get<string>( "key" ); Assert.Equal( Value, value ); }
public void CanGetAndSetEnumStringValues() { const OSEnum value = OSEnum.Win2k; var section = new ConfigurationSection( SectionName ); section.Set( Key, value.ToString() ); var fromSection = section.Get<OSEnum>( Key ); Assert.AreEqual( value, fromSection ); }
public void CanGetAndSetEnumFlagValues() { const OptionsEnum all = ( OptionsEnum.A | OptionsEnum.B | OptionsEnum.C ); var section = new ConfigurationSection( SectionName ); section.Set( Key, all ); var fromSection = section.Get<OptionsEnum>( Key ); Assert.AreEqual( all, fromSection ); }
public void CanReadAddedValue() { var section = new ConfigurationSection(SectionName); section.Set(Key, Value); var value = section.Get <string>("key"); Assert.Equal(Value, value); }
public void CanGetAndSetEnumFlagInt32Values() { const OptionsEnum all = (OptionsEnum.A | OptionsEnum.B | OptionsEnum.C); var section = new ConfigurationSection(SectionName); section.Set(Key, (int)all); var fromSection = section.Get <OptionsEnum>(Key); Assert.Equal(all, fromSection); }
public void CanGetAndSetEnumInt32Values() { const OSEnum value = OSEnum.Win2k; var section = new ConfigurationSection(SectionName); section.Set(Key, (int)value); var fromSection = section.Get <OSEnum>(Key); Assert.Equal(value, fromSection); }
public void DefaultParameterValueIsReturnedForNonExistingKey() { var section = new ConfigurationSection(SectionName); const OptionsEnum optionsEnumDefault = OptionsEnum.None; OptionsEnum optionsEnum = section.Get(Key, optionsEnumDefault); Assert.Equal(optionsEnumDefault, optionsEnum); const OSEnum osEnumDefault = OSEnum.WinXp; OSEnum osEnum = section.Get(Key, osEnumDefault); Assert.Equal(osEnumDefault, osEnum); const string stringDefault = Value; string stringValue = section.Get(Key, stringDefault); Assert.Equal(stringDefault, stringValue); bool boolValue = section.Get(Key, true); Assert.Equal(true, boolValue); boolValue = section.Get(Key, false); Assert.Equal(false, boolValue); var defaultSection = new ConfigurationSection("MyDefault"); ConfigurationSection dummySection = section.Get(Key, defaultSection); Assert.Equal(defaultSection, dummySection); }
public void GettingNonExistingItemReturnsDefaultForType() { var section = new ConfigurationSection(SectionName); var optionsEnum = section.Get <OptionsEnum>(Key); Assert.Equal(default(OptionsEnum), optionsEnum); var osEnum = section.Get <OSEnum>(Key); Assert.Equal(default(OSEnum), osEnum); var stringValue = section.Get <string>(Key); Assert.Equal(default(string), stringValue); var boolValue = section.Get <bool>(Key); Assert.Equal(default(bool), boolValue); var dummySection = section.Get <ConfigurationSection>(Key); Assert.Equal(default(ConfigurationSection), dummySection); }
public void SettingAValueForAnExistingKeyOverrides() { var section = new ConfigurationSection( SectionName ); section.Set( Key, Value ); Assert.AreEqual( Value, section.Get<string>( Key ) ); section.Set( Key, Key ); Assert.AreEqual( Key, section.Get<string>( Key ) ); }
public void GettingNonExistingItemReturnsDefaultForType() { var section = new ConfigurationSection( SectionName ); var optionsEnum = section.Get<OptionsEnum>( Key ); Assert.AreEqual( default( OptionsEnum ), optionsEnum ); var osEnum = section.Get<OSEnum>( Key ); Assert.AreEqual( default( OSEnum ), osEnum ); var stringValue = section.Get<string>( Key ); Assert.AreEqual( default( string ), stringValue ); var boolValue = section.Get<bool>( Key ); Assert.AreEqual( default( bool ), boolValue ); var dummySection = section.Get<ConfigurationSection>( Key ); Assert.AreEqual( default( ConfigurationSection ), dummySection ); }
public void DefaultParameterValueIsReturnedForNonExistingKey() { var section = new ConfigurationSection( SectionName ); const OptionsEnum optionsEnumDefault = OptionsEnum.None; OptionsEnum optionsEnum = section.Get( Key, optionsEnumDefault ); Assert.AreEqual( optionsEnumDefault, optionsEnum ); const OSEnum osEnumDefault = OSEnum.WinXp; OSEnum osEnum = section.Get( Key, osEnumDefault ); Assert.AreEqual( osEnumDefault, osEnum ); const string stringDefault = Value; string stringValue = section.Get( Key, stringDefault ); Assert.AreEqual( stringDefault, stringValue ); bool boolValue = section.Get( Key, true ); Assert.AreEqual( true, boolValue ); boolValue = section.Get( Key, false ); Assert.AreEqual( false, boolValue ); var defaultSection = new ConfigurationSection( "MyDefault" ); ConfigurationSection dummySection = section.Get( Key, defaultSection ); Assert.AreEqual( defaultSection, dummySection ); }
public void CanGetAndSetEnumInt32Values() { const OSEnum value = OSEnum.Win2k; var section = new ConfigurationSection( SectionName ); section.Set( Key, (int) value ); var fromSection = section.Get<OSEnum>( Key ); Assert.Equal( value, fromSection ); }