Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve token case for unmatched tokens. #65

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public void if_given_a_value_that_is_not_set_should_return_empty_string()
}

[Observation]
public void if_given_a_value_that_does_not_exist_should_return_the_value()
public void if_given_a_value_that_does_not_exist_should_return_the_value_with_original_casing()
{
TokenReplacer.replace_tokens(configuration, "ALTER DATABASE {{database}}").should_be_equal_to("ALTER DATABASE {{database}}");
TokenReplacer.replace_tokens(configuration, "ALTER DATABASE {{DataBase}}").should_be_equal_to("ALTER DATABASE {{DataBase}}");
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions product/roundhouse/infrastructure.app/tokens/TokenReplacer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static string replace_tokens(ConfigurationPropertyHolder configuration, s
{
string key = "";

key = m.Groups["key"].Value.to_lower();
key = m.Groups["key"].Value;
if (!dictionary.ContainsKey(key))
{
return "{{" + key + "}}";
Expand All @@ -33,10 +33,10 @@ public static string replace_tokens(ConfigurationPropertyHolder configuration, s

private static IDictionary<string, string> create_dictionary_from_configuration(ConfigurationPropertyHolder configuration)
{
Dictionary<string, string> property_dictionary = new Dictionary<string, string>();
Dictionary<string, string> property_dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
foreach (var property in configuration.GetType().GetProperties())
{
property_dictionary.Add(property.Name.to_lower(), property.GetValue(configuration, null).to_string());
property_dictionary.Add(property.Name, property.GetValue(configuration, null).to_string());
}

return property_dictionary;
Expand Down