From 5736abf0531daf762c79229aee17b4dd0ce03a58 Mon Sep 17 00:00:00 2001 From: Mario Pareja Date: Wed, 20 Jun 2012 10:57:13 -0400 Subject: [PATCH] Preserve token case for unmatched tokens. Using case insensitive dictionary for comparisons. --- .../infrastructure.app/tokens/TokenReplacerSpecs.cs | 4 ++-- .../roundhouse/infrastructure.app/tokens/TokenReplacer.cs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/product/roundhouse.tests/infrastructure.app/tokens/TokenReplacerSpecs.cs b/product/roundhouse.tests/infrastructure.app/tokens/TokenReplacerSpecs.cs index 6e57689d..172608ac 100644 --- a/product/roundhouse.tests/infrastructure.app/tokens/TokenReplacerSpecs.cs +++ b/product/roundhouse.tests/infrastructure.app/tokens/TokenReplacerSpecs.cs @@ -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}}"); } } } diff --git a/product/roundhouse/infrastructure.app/tokens/TokenReplacer.cs b/product/roundhouse/infrastructure.app/tokens/TokenReplacer.cs index 607e52c8..d4ffe708 100644 --- a/product/roundhouse/infrastructure.app/tokens/TokenReplacer.cs +++ b/product/roundhouse/infrastructure.app/tokens/TokenReplacer.cs @@ -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 + "}}"; @@ -33,10 +33,10 @@ public static string replace_tokens(ConfigurationPropertyHolder configuration, s private static IDictionary create_dictionary_from_configuration(ConfigurationPropertyHolder configuration) { - Dictionary property_dictionary = new Dictionary(); + Dictionary property_dictionary = new Dictionary(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;