private static void LoadPropertiesFromText(string text, Dictionary <string, string> targetDictionary) { targetDictionary.Clear(); foreach (KeyValuePair <string, string> entry in PropertiesFileParser.ParseText(text)) { targetDictionary.Add(entry.Key, entry.Value); } }
public void DoPropertiesFileParserTest() { string filePath = "Packages/com.achimmihca.ProTrans/Tests/Editor/TestProperties.properties"; Dictionary <string, string> properties = PropertiesFileParser.ParseFile(filePath); bool containsComment = AnyKeyToLowerContains(properties, "comment") || AnyValueToLowerContains(properties, "comment"); Assert.That(!containsComment, "Contains comment in key or value"); AssertPropertyIgnoreCase(properties, "test_helloWorld", "Hello world!"); AssertPropertyIgnoreCase(properties, "test_equals", "before=after"); AssertPropertyIgnoreCase(properties, "test_parameters", "First name: {firstName}, second name: {secondName}"); AssertPropertyIgnoreCase(properties, "test_nonAscii", "üäößêéèáà"); AssertPropertyIgnoreCase(properties, "test_quotes", "\"All these outer and 'single quotes' and \"double quotes\" are kept\""); AssertPropertyIgnoreCase(properties, "test_spaceAtTheEndNotAroundEquals", "Space around the equals sign is trimmed, but the ending space is kept: "); AssertPropertyIgnoreCase(properties, "test_tab", "Before tab\tafter tab"); AssertPropertyIgnoreCase(properties, "test_newline", "First line\nAfter newline\rAfter carriage return"); AssertPropertyIgnoreCase(properties, "test_backslash", "\\Just two backslashes\\"); AssertPropertyIgnoreCase(properties, "test_targetCities", "Detroit,Chicago,Los Angeles"); AssertPropertyIgnoreCase(properties, "test_KeepSpace", " <- white-space -> "); }