public void LoadMethodCanHandleEmptyValue() { var properties = @"DefaultKey="; PropertiesConfigurationProvider propertiesConfigSrc = new PropertiesConfigurationProvider(new PropertiesConfigurationSource()); propertiesConfigSrc.Load(StringToStream(properties)); Assert.AreEqual(string.Empty, GetValue(propertiesConfigSrc, "DefaultKey")); }
public void DoubleQuoteIsPartOfValueIfAppearInTheMiddleOfValue() { var properties = "DefaultConnection=Test\"Connection\"String\n" + "Provider=Sql\"Client"; var propertiesConfigSrc = new PropertiesConfigurationProvider(new PropertiesConfigurationSource()); propertiesConfigSrc.Load(StringToStream(properties)); Assert.AreEqual("Test\"Connection\"String", GetValue(propertiesConfigSrc, "DefaultConnection")); Assert.AreEqual("Sql\"Client", GetValue(propertiesConfigSrc, "Provider")); }
public void DoubleQuoteIsPartOfValueIfNotPaired() { var properties = "DefaultConnection=\"TestConnectionString\n" + "Provider=SqlClient\""; var propertiesConfigSrc = new PropertiesConfigurationProvider(new PropertiesConfigurationSource()); propertiesConfigSrc.Load(StringToStream(properties)); Assert.AreEqual("\"TestConnectionString", GetValue(propertiesConfigSrc, "DefaultConnection")); Assert.AreEqual("SqlClient\"", GetValue(propertiesConfigSrc, "Provider")); }
public void SupportAndIgnoreComments() { var properties = @" # Comments ConnectionString=TestConnectionString Provider=SqlClient "; var propertiesConfigSrc = new PropertiesConfigurationProvider(new PropertiesConfigurationSource()); propertiesConfigSrc.Load(StringToStream(properties)); Assert.AreEqual("TestConnectionString", GetValue(propertiesConfigSrc, "ConnectionString")); Assert.AreEqual("SqlClient", GetValue(propertiesConfigSrc, "Provider")); }
public void LoadKeyValuePairsFromValidPropertiesFileWithQuotedValues() { var properties = "DefaultConnection.ConnectionString=\"TestConnectionString\"\n" + "DefaultConnection.Provider=\"SqlClient\"\n" + "Data.Inventory.ConnectionString=\"AnotherTestConnectionString\"\n" + "Provider=\"MySql\""; var propertiesConfigSrc = new PropertiesConfigurationProvider(new PropertiesConfigurationSource()); propertiesConfigSrc.Load(StringToStream(properties)); Assert.AreEqual("TestConnectionString", GetValue(propertiesConfigSrc, "DefaultConnection:ConnectionString")); Assert.AreEqual("SqlClient", GetValue(propertiesConfigSrc, "DefaultConnection:Provider")); Assert.AreEqual("AnotherTestConnectionString", GetValue(propertiesConfigSrc, "Data:Inventory:ConnectionString")); Assert.AreEqual("MySql", GetValue(propertiesConfigSrc, "Provider")); }
public void LoadKeyValuePairsFromValidPropertiesFile() { var properties = @" DefaultConnection.ConnectionString=TestConnectionString DefaultConnection.Provider=SqlClient Data.Inventory.ConnectionString=AnotherTestConnectionString Data.Inventory.Provider=MySql "; var propertiesConfigSrc = new PropertiesConfigurationProvider(new PropertiesConfigurationSource()); propertiesConfigSrc.Load(StringToStream(properties)); Assert.AreEqual("TestConnectionString", GetValue(propertiesConfigSrc, "DefaultConnection:ConnectionString")); Assert.AreEqual("SqlClient", GetValue(propertiesConfigSrc, "DEFAULTCONNECTION:PROVIDER")); Assert.AreEqual("AnotherTestConnectionString", GetValue(propertiesConfigSrc, "Data:Inventory:CONNECTIONSTRING")); Assert.AreEqual("MySql", GetValue(propertiesConfigSrc, "Data:Inventory:Provider")); }
private string GetValue(PropertiesConfigurationProvider provider, string key) { Assert.IsTrue(provider.TryGet(key, out var value)); return(value); }