public void StringDictionaryCaseSensitive()
        {
            var dictionary = new Energy.Base.Collection.StringDictionary <object>();

            dictionary.SelectionOfDuplicates = Energy.Enumeration.MultipleBehaviour.First;

            dictionary["One"] = 1;
            dictionary["TWO"] = 2;
            dictionary["ONE"] = 1 + (int)(dictionary["two"] ?? 1);

            Assert.AreEqual("ONE=2 one=", string.Concat("", "ONE=", dictionary["ONE"], " one=", dictionary["one"]));

            dictionary.CaseSensitive = false;

            Assert.AreEqual("ONE=1 one=1", string.Concat("", "ONE=", dictionary["ONE"], " one=", dictionary["one"]));

            string result;
            string expect;

            Energy.Base.Collection.StringDictionary sd;

            sd = new Energy.Base.Collection.StringDictionary();
            sd.CaseSensitive = false;
            sd.Set("Product", "123");
            sd.Set("product", "123456789");
            result = sd.Get("Product");
            expect = "123456789";
            Assert.AreEqual(expect, result);
            sd.CaseSensitive = true;
            result           = sd.Get("Product");
            expect           = "123456789";
            Assert.AreEqual(expect, result);

            sd = new Energy.Base.Collection.StringDictionary();
            sd.Set("Product", "123");
            sd.Set("product", "123456789");
            sd.Set("zzz1", "abc");

            result = sd.Get("Product");
            expect = "123";
            Assert.AreEqual(expect, result);

            result = sd.Get("zzz1");
            expect = "abc";
            Assert.AreEqual(expect, result);

            sd.CaseSensitive = false;
            result           = sd.Get("Product");
            expect           = "123456789";
            Assert.AreEqual(expect, result);
        }
Beispiel #2
0
        private static void TestA1()
        {
            Random random = new Random();

            Energy.Base.Collection.StringDictionary d = new Energy.Base.Collection.StringDictionary();
            d.CaseSensitive = false;
            for (int i = 0; i < 100000; i++)
            {
                string key   = random.Next(10000).ToString();
                string value = random.Next(10000).ToString();
                d.Set(key, value);
            }
        }
Beispiel #3
0
        private static void TestB1()
        {
            Energy.Base.Collection.StringDictionary d = new Energy.Base.Collection.StringDictionary();
            d.CaseSensitive = true;
            Console.WriteLine("Setting \"Option\" to \"Value\"");
            d.Set("Option", "Value");
            string value;

            value = d.Get("option");
            Console.WriteLine("Value of \"option\" when CaseSensitive is true: {0}", value);
            d.CaseSensitive = false;
            value           = d.Get("option");
            Console.WriteLine("Value of \"option\" when CaseSensitive is false: {0}", value);
        }