public void Iniitialize_WithStringArray_FillsKeyValuesInPairs()
        {
            DictionaryVariableSource dvs = new DictionaryVariableSource(new string[] { "key1", "value1", "key2", "value2" });

            Assert.AreEqual("value1", dvs.ResolveVariable("key1"));
            Assert.AreEqual("value2", dvs.ResolveVariable("key2"));
        }
        public void Iniitialize_WithStringArray_FillsKeyValuesInPairs()
        {
            DictionaryVariableSource dvs = new DictionaryVariableSource(new string[] { "key1", "value1", "key2", "value2" });

            Assert.AreEqual("value1", dvs.ResolveVariable("key1"));
            Assert.AreEqual("value2", dvs.ResolveVariable("key2"));
        }
        public void Initialize_WithCaseSensitiveFlag_AddsCaseSensitiveKeys()
        {
            DictionaryVariableSource dvs = new DictionaryVariableSource(false);
            dvs.Add("key1", "lowercasevalue");
            dvs.Add("KEY1", "uppercasevalue");

            Assert.AreEqual("lowercasevalue", dvs.ResolveVariable("key1"));
            Assert.AreEqual("uppercasevalue", dvs.ResolveVariable("KEY1"));
        }
        public void Initialize_WithCaseSensitiveFlag_AddsCaseSensitiveKeys()
        {
            DictionaryVariableSource dvs = new DictionaryVariableSource(false);

            dvs.Add("key1", "lowercasevalue");
            dvs.Add("KEY1", "uppercasevalue");

            Assert.AreEqual("lowercasevalue", dvs.ResolveVariable("key1"));
            Assert.AreEqual("uppercasevalue", dvs.ResolveVariable("KEY1"));
        }
        public void Initialize_WithEmptyConstructor_AddsCaseInsensitiveKeys()
        {
            DictionaryVariableSource dvs = new DictionaryVariableSource();

            dvs.Add("key1", "value1");
            dvs.Add("KEY2", "value2");

            Assert.AreEqual("value1", dvs.ResolveVariable("KEY1"));
            Assert.AreEqual("value2", dvs.ResolveVariable("key2"));
        }
Beispiel #6
0
        public void Initialize_WithInlineDictionarySyntax()
        {
            DictionaryVariableSource dvs = new DictionaryVariableSource()
            {
                { "key1", "value1" }, { "key2", "value2" }
            };

            Assert.AreEqual("value1", dvs.ResolveVariable("key1"));
            Assert.AreEqual("value2", dvs.ResolveVariable("key2"));
        }
        public void Initialize_WithDictionaryConstructor_AddsCaseInsensitiveKeys()
        {
            IDictionary dict = new Hashtable();
            dict.Add("key1", "value1");
            dict.Add("KEY2", "value2");

            DictionaryVariableSource dvs = new DictionaryVariableSource(dict);

            Assert.AreEqual("value1", dvs.ResolveVariable("KEY1"));
            Assert.AreEqual("value2", dvs.ResolveVariable("key2"));
        }
        public void Initialize_WithDictionaryConstructor_AddsKeys()
        {
            IDictionary dict = new Hashtable();

            dict.Add("key1", "value1");
            dict.Add("key2", "value2");

            DictionaryVariableSource dvs = new DictionaryVariableSource(dict);

            Assert.AreEqual("value1", dvs.ResolveVariable("key1"));
            Assert.AreEqual("value2", dvs.ResolveVariable("key2"));
        }
        public void Initialize_WithDictionaryConstructorAndCaseSensitiveFlag_AddsCaseSensitiveKeys()
        {
            IDictionary dict = new Hashtable();

            dict.Add("key1", "lowecasevalue");
            dict.Add("KEY1", "uppercasevalue");

            DictionaryVariableSource dvs = new DictionaryVariableSource(dict, false);

            Assert.AreEqual("lowecasevalue", dvs.ResolveVariable("key1"));
            Assert.AreEqual("uppercasevalue", dvs.ResolveVariable("KEY1"));
        }
        public void Requesting_KeyNotFound_ThrowsException()
        {
            const string THE_KEY = "key-found";

            DictionaryVariableSource dvs = new DictionaryVariableSource();

            dvs.Add(THE_KEY, "value-found");

            try
            {
                dvs.ResolveVariable("not" + THE_KEY);
                Assert.Fail("Expected ArgumentException not thrown.");
            }
            catch (ArgumentException)
            {
            }
        }
        public void Initialize_WithDictionaryConstructorAndCaseSensitiveFlag_AddsCaseSensitiveKeys()
        {
            IDictionary dict = new Hashtable();
            dict.Add("key1", "lowecasevalue");
            dict.Add("KEY1", "uppercasevalue");

            DictionaryVariableSource dvs = new DictionaryVariableSource(dict, false);

            Assert.AreEqual("lowecasevalue", dvs.ResolveVariable("key1"));
            Assert.AreEqual("uppercasevalue", dvs.ResolveVariable("KEY1"));
        }
        public void Requesting_KeyNotFound_ThrowsException()
        {
            const string THE_KEY = "key-found";

            DictionaryVariableSource dvs = new DictionaryVariableSource();
            dvs.Add(THE_KEY, "value-found");

            try
            {
                dvs.ResolveVariable("not" + THE_KEY);
                Assert.Fail("Expected ArgumentException not thrown.");
            }
            catch (ArgumentException)
            {
            }
        }
        public void Initialize_WithInlineDictionarySyntax()
        {
            DictionaryVariableSource dvs = new DictionaryVariableSource() { { "key1", "value1" }, { "key2", "value2" } };

            Assert.AreEqual("value1", dvs.ResolveVariable("key1"));
            Assert.AreEqual("value2", dvs.ResolveVariable("key2"));

        }