Beispiel #1
0
        public void GetDouble()
        {
            var dictionary = new Dictionary <string, string>
            {
                { "Item1", "1.1" },
                { "Item2", "2.2" },
                { "Item3", "3.3" },
                { "Item4", "4.4" },
                { "Item5", "5.5" },
                { "Item6", "6.6" },
                { "Item7", "7.7" },
                { "Item8", "8.8" }
            };

            var value1 = ConfigurationUtilities.GetFromDictionary(dictionary, "Item3", 100.123);
            var value2 = ConfigurationUtilities.GetFromDictionary(dictionary, "Item4", 100.123);
            var value3 = ConfigurationUtilities.GetFromDictionary(dictionary, "Item9", 100.123);

            Assert.IsTrue(value1 == 3.3, "Item3 is not the expected value");
            Assert.IsTrue(value2 == 4.4, "Item4 is not the expected value");
            Assert.IsTrue(value3 == 100.123, "Item9 is not the expected value");
        }
Beispiel #2
0
        public void GetBool()
        {
            var dictionary = new Dictionary <string, string>
            {
                { "Item1", "true" },
                { "Item2", "false" },
                { "Item3", "true" },
                { "Item4", "false" },
                { "Item5", "true" },
                { "Item6", "false" },
                { "Item7", "true" },
                { "Item8", "false" }
            };

            var value1 = ConfigurationUtilities.GetFromDictionary(dictionary, "Item3", false);
            var value2 = ConfigurationUtilities.GetFromDictionary(dictionary, "Item4", false);
            var value3 = ConfigurationUtilities.GetFromDictionary(dictionary, "Item9", false);

            Assert.IsTrue(value1, "Item3 is not the expected value");
            Assert.IsFalse(value2, "Item4 is not the expected value");
            Assert.IsFalse(value3, "Item9 is not the expected value");
        }
Beispiel #3
0
        public void GetInt()
        {
            var dictionary = new Dictionary <string, string>
            {
                { "Item1", "1" },
                { "Item2", "2" },
                { "Item3", "3" },
                { "Item4", "4" },
                { "Item5", "5" },
                { "Item6", "6" },
                { "Item7", "7" },
                { "Item8", "8" }
            };

            var value1 = ConfigurationUtilities.GetFromDictionary(dictionary, "Item3", 100);
            var value2 = ConfigurationUtilities.GetFromDictionary(dictionary, "Item4", 100);
            var value3 = ConfigurationUtilities.GetFromDictionary(dictionary, "Item9", 100);

            Assert.IsTrue(value1 == 3, "Item3 is not the expected value");
            Assert.IsTrue(value2 == 4, "Item4 is not the expected value");
            Assert.IsTrue(value3 == 100, "Item0 is not the expected value");
        }
Beispiel #4
0
        public void GetTimeSpan()
        {
            var dictionary = new Dictionary <string, string>
            {
                { "Item1", TimeSpan.FromMinutes(1).ToString() },
                { "Item2", TimeSpan.FromMinutes(2).ToString() },
                { "Item3", TimeSpan.FromMinutes(3).ToString() },
                { "Item4", TimeSpan.FromMinutes(4).ToString() },
                { "Item5", TimeSpan.FromMinutes(5).ToString() },
                { "Item6", TimeSpan.FromMinutes(6).ToString() },
                { "Item7", TimeSpan.FromMinutes(7).ToString() },
                { "Item8", TimeSpan.FromMinutes(8).ToString() }
            };

            var value1 = ConfigurationUtilities.GetFromDictionary(dictionary, "Item3", TimeSpan.FromHours(1));
            var value2 = ConfigurationUtilities.GetFromDictionary(dictionary, "Item4", TimeSpan.FromHours(1));
            var value3 = ConfigurationUtilities.GetFromDictionary(dictionary, "Item9", TimeSpan.FromHours(1));

            Assert.IsTrue(value1 == TimeSpan.FromMinutes(3), "Item3 is not the expected value");
            Assert.IsTrue(value2 == TimeSpan.FromMinutes(4), "Item4 is not the expected value");
            Assert.IsTrue(value3 == TimeSpan.FromHours(1), "Item9 is not the expected value");
        }