public void Whitespace_around_separator_matters_not() { var input = "key1=value1"; var props = new Properties(input); props.Count().ShouldBe(1); props.GetProperty("key1").ShouldBe("value1"); }
public void Valid_lines_are_parsed() { var input = "key1 = value1"; var props = new Properties(input); props.Count().ShouldBe(1); props.GetProperty("key1").ShouldBe("value1"); }
public void Windows_newlines_can_separate_items() { var input = "foo=bar\r\nbar=baz"; var props = new Properties(input); props.Count().ShouldBe(2); props.GetProperty("foo").ShouldBe("bar"); props.GetProperty("bar").ShouldBe("baz"); }
public void Commented_lines_are_ignored() { var input = "# This line is commented\r\n" + "! so = is this one"; var props = new Properties(input); props.Count().ShouldBe(0); }
private Properties GetPropertiesFromFile() { try { var source = this.file.ReadAllText(this.apiKeyFilePath); var properties = new Properties(source); return properties; } catch (Exception ex) { var msg = $"Unable to load API Key properties file [{this.apiKeyFilePath}].\n" + $"Exception: '{ex.Message}' at '{ex.Source}'"; this.logger.Trace(msg); return null; } }
private Properties GetPropertiesFromAppConfigFileLocation(string path) { try { var source = this.file.ReadAllText(path); var properties = new Properties(source); return properties; } catch (Exception ex) { var msg = $"Unable to load API Key properties file [{path}] specified by config key " + "STORMPATH_API_KEY_FILE. This can safely be ignored as this is a fallback location - " + "other more specific locations will be checked.\n" + $"Exception: '{ex.Message}' at '{ex.Source}'"; this.logger.Trace(msg); return null; } }
public void Empty_string_returns_empty_dictionary() { var props = new Properties(string.Empty); props.Count().ShouldBe(0); }
public void Null_string_returns_empty_dictionary() { var props = new Properties(null); props.Count().ShouldBe(0); }
public void Returns_value() { var props = new Properties("foo=baz"); props.GetProperty("foo").ShouldBe("baz"); }
public void Returns_default_value_for_missing_property() { var props = new Properties(string.Empty); props.GetProperty("foo", defaultValue: "bar").ShouldBe("bar"); }
public void Returns_null_for_missing_property() { var props = new Properties(string.Empty); props.GetProperty("foo").ShouldBeNull(); }