public void DoubleQuoteIsPartOfValueIfNotPaired() { var ini = "[ConnectionString]\n" + "DefaultConnection=\"TestConnectionString\n" + "Provider=SqlClient\""; var iniConfigSrc = new IniFileConfigurationSource(TestStreamHelpers.ArbitraryFilePath); iniConfigSrc.Load(TestStreamHelpers.StringToStream(ini)); Assert.Equal("\"TestConnectionString", iniConfigSrc.Get("ConnectionString:DefaultConnection")); Assert.Equal("SqlClient\"", iniConfigSrc.Get("ConnectionString:Provider")); }
public void DoubleQuoteIsPartOfValueIfAppearInTheMiddleOfValue() { var ini = "[ConnectionString]\n" + "DefaultConnection=Test\"Connection\"String\n" + "Provider=Sql\"Client"; var iniConfigSrc = new IniFileConfigurationSource(TestStreamHelpers.ArbitraryFilePath); iniConfigSrc.Load(TestStreamHelpers.StringToStream(ini)); Assert.Equal("Test\"Connection\"String", iniConfigSrc.Get("ConnectionString:DefaultConnection")); Assert.Equal("Sql\"Client", iniConfigSrc.Get("ConnectionString:Provider")); }
public void DoubleQuoteIsPartOfValueIfNotPaired() { var ini = "[ConnectionString]\n" + "DefaultConnection=\"TestConnectionString\n" + "Provider=SqlClient\""; var iniConfigSrc = new IniFileConfigurationSource(TestStreamHelpers.ArbitraryFilePath); iniConfigSrc.Load(TestStreamHelpers.StringToStream(ini)); Assert.Equal("\"TestConnectionString", iniConfigSrc.Get("ConnectionString:DefaultConnection")); Assert.Equal("SqlClient\"", iniConfigSrc.Get("ConnectionString:Provider")); }
public void DoubleQuoteIsPartOfValueIfAppearInTheMiddleOfValue() { var ini = "[ConnectionString]\n" + "DefaultConnection=Test\"Connection\"String\n" + "Provider=Sql\"Client"; var iniConfigSrc = new IniFileConfigurationSource(TestStreamHelpers.ArbitraryFilePath); iniConfigSrc.Load(TestStreamHelpers.StringToStream(ini)); Assert.Equal("Test\"Connection\"String", iniConfigSrc.Get("ConnectionString:DefaultConnection")); Assert.Equal("Sql\"Client", iniConfigSrc.Get("ConnectionString:Provider")); }
public void IniConfiguration_Does_Not_Throw_On_Optional_Configuration() { var configSource = new IniFileConfigurationSource("NotExistingConfig.ini", optional: true); configSource.Load(); Assert.Throws <InvalidOperationException>(() => configSource.Get("key")); }
public void LoadKeyValuePairsFromValidIniFileWithoutSectionHeader() { var ini = @" DefaultConnection:ConnectionString=TestConnectionString DefaultConnection:Provider=SqlClient Data:Inventory:ConnectionString=AnotherTestConnectionString Data:Inventory:Provider=MySql "; var iniConfigSrc = new IniFileConfigurationSource(TestStreamHelpers.ArbitraryFilePath); iniConfigSrc.Load(TestStreamHelpers.StringToStream(ini)); Assert.Equal("TestConnectionString", iniConfigSrc.Get("DefaultConnection:ConnectionString")); Assert.Equal("SqlClient", iniConfigSrc.Get("DefaultConnection:Provider")); Assert.Equal("AnotherTestConnectionString", iniConfigSrc.Get("Data:Inventory:ConnectionString")); Assert.Equal("MySql", iniConfigSrc.Get("Data:Inventory:Provider")); }
public void LoadKeyValuePairsFromValidIniFileWithQuotedValues() { var ini = "[DefaultConnection]\n" + "ConnectionString=\"TestConnectionString\"\n" + "Provider=\"SqlClient\"\n" + "[Data:Inventory]\n" + "ConnectionString=\"AnotherTestConnectionString\"\n" + "Provider=\"MySql\""; var iniConfigSrc = new IniFileConfigurationSource(TestStreamHelpers.ArbitraryFilePath); iniConfigSrc.Load(TestStreamHelpers.StringToStream(ini)); Assert.Equal("TestConnectionString", iniConfigSrc.Get("DefaultConnection:ConnectionString")); Assert.Equal("SqlClient", iniConfigSrc.Get("DefaultConnection:Provider")); Assert.Equal("AnotherTestConnectionString", iniConfigSrc.Get("Data:Inventory:ConnectionString")); Assert.Equal("MySql", iniConfigSrc.Get("Data:Inventory:Provider")); }
public void LoadKeyValuePairsFromValidIniFile() { var ini = @"[DefaultConnection] ConnectionString=TestConnectionString Provider=SqlClient [Data:Inventory] ConnectionString=AnotherTestConnectionString SubHeader:Provider=MySql"; var iniConfigSrc = new IniFileConfigurationSource(TestStreamHelpers.ArbitraryFilePath); iniConfigSrc.Load(TestStreamHelpers.StringToStream(ini)); Assert.Equal("TestConnectionString", iniConfigSrc.Get("defaultconnection:ConnectionString")); Assert.Equal("SqlClient", iniConfigSrc.Get("DEFAULTCONNECTION:PROVIDER")); Assert.Equal("AnotherTestConnectionString", iniConfigSrc.Get("Data:Inventory:CONNECTIONSTRING")); Assert.Equal("MySql", iniConfigSrc.Get("Data:Inventory:SubHeader:Provider")); }
public void LoadMethodCanHandleEmptyValue() { var ini = @"DefaultKey="; var iniConfigSrc = new IniFileConfigurationSource(TestStreamHelpers.ArbitraryFilePath); iniConfigSrc.Load(TestStreamHelpers.StringToStream(ini)); Assert.Equal(string.Empty, iniConfigSrc.Get("DefaultKey")); }
public void SupportAndIgnoreComments() { var ini = @" ; Comments [DefaultConnection] # Comments ConnectionString=TestConnectionString / Comments Provider=SqlClient [Data:Inventory] ConnectionString=AnotherTestConnectionString Provider=MySql "; var iniConfigSrc = new IniFileConfigurationSource(TestStreamHelpers.ArbitraryFilePath); iniConfigSrc.Load(TestStreamHelpers.StringToStream(ini)); Assert.Equal("TestConnectionString", iniConfigSrc.Get("DefaultConnection:ConnectionString")); Assert.Equal("SqlClient", iniConfigSrc.Get("DefaultConnection:Provider")); Assert.Equal("AnotherTestConnectionString", iniConfigSrc.Get("Data:Inventory:ConnectionString")); Assert.Equal("MySql", iniConfigSrc.Get("Data:Inventory:Provider")); }
public void LoadKeyValuePairsFromValidIniFileWithoutSectionHeader() { var ini = @" DefaultConnection:ConnectionString=TestConnectionString DefaultConnection:Provider=SqlClient Data:Inventory:ConnectionString=AnotherTestConnectionString Data:Inventory:Provider=MySql "; var iniConfigSrc = new IniFileConfigurationSource(TestStreamHelpers.ArbitraryFilePath); iniConfigSrc.Load(TestStreamHelpers.StringToStream(ini)); Assert.Equal("TestConnectionString", iniConfigSrc.Get("DefaultConnection:ConnectionString")); Assert.Equal("SqlClient", iniConfigSrc.Get("DefaultConnection:Provider")); Assert.Equal("AnotherTestConnectionString", iniConfigSrc.Get("Data:Inventory:ConnectionString")); Assert.Equal("MySql", iniConfigSrc.Get("Data:Inventory:Provider")); }
public void LoadKeyValuePairsFromValidIniFile() { var ini = @"[DefaultConnection] ConnectionString=TestConnectionString Provider=SqlClient [Data:Inventory] ConnectionString=AnotherTestConnectionString SubHeader:Provider=MySql"; var iniConfigSrc = new IniFileConfigurationSource(TestStreamHelpers.ArbitraryFilePath); iniConfigSrc.Load(TestStreamHelpers.StringToStream(ini)); Assert.Equal("TestConnectionString", iniConfigSrc.Get("defaultconnection:ConnectionString")); Assert.Equal("SqlClient", iniConfigSrc.Get("DEFAULTCONNECTION:PROVIDER")); Assert.Equal("AnotherTestConnectionString", iniConfigSrc.Get("Data:Inventory:CONNECTIONSTRING")); Assert.Equal("MySql", iniConfigSrc.Get("Data:Inventory:SubHeader:Provider")); }
public void IniConfiguration_Does_Not_Throw_On_Optional_Configuration() { var configSource = new IniFileConfigurationSource("NotExistingConfig.ini", optional: true); configSource.Load(); Assert.Throws<InvalidOperationException>(() => configSource.Get("key")); }
public void SupportAndIgnoreComments() { var ini = @" ; Comments [DefaultConnection] # Comments ConnectionString=TestConnectionString / Comments Provider=SqlClient [Data:Inventory] ConnectionString=AnotherTestConnectionString Provider=MySql "; var iniConfigSrc = new IniFileConfigurationSource(TestStreamHelpers.ArbitraryFilePath); iniConfigSrc.Load(TestStreamHelpers.StringToStream(ini)); Assert.Equal("TestConnectionString", iniConfigSrc.Get("DefaultConnection:ConnectionString")); Assert.Equal("SqlClient", iniConfigSrc.Get("DefaultConnection:Provider")); Assert.Equal("AnotherTestConnectionString", iniConfigSrc.Get("Data:Inventory:ConnectionString")); Assert.Equal("MySql", iniConfigSrc.Get("Data:Inventory:Provider")); }
public void LoadMethodCanHandleEmptyValue() { var ini = @"DefaultKey="; var iniConfigSrc = new IniFileConfigurationSource(TestStreamHelpers.ArbitraryFilePath); iniConfigSrc.Load(TestStreamHelpers.StringToStream(ini)); Assert.Equal(string.Empty, iniConfigSrc.Get("DefaultKey")); }
public void LoadKeyValuePairsFromValidIniFileWithQuotedValues() { var ini = "[DefaultConnection]\n" + "ConnectionString=\"TestConnectionString\"\n" + "Provider=\"SqlClient\"\n" + "[Data:Inventory]\n" + "ConnectionString=\"AnotherTestConnectionString\"\n" + "Provider=\"MySql\""; var iniConfigSrc = new IniFileConfigurationSource(TestStreamHelpers.ArbitraryFilePath); iniConfigSrc.Load(TestStreamHelpers.StringToStream(ini)); Assert.Equal("TestConnectionString", iniConfigSrc.Get("DefaultConnection:ConnectionString")); Assert.Equal("SqlClient", iniConfigSrc.Get("DefaultConnection:Provider")); Assert.Equal("AnotherTestConnectionString", iniConfigSrc.Get("Data:Inventory:ConnectionString")); Assert.Equal("MySql", iniConfigSrc.Get("Data:Inventory:Provider")); }