Esempio n. 1
0
        public virtual void TestGetTypedProperties2()
        {
            StringProperties         stringProperties = CreateStringProperties("test.properties");
            IProperty <String, int?> property         = stringProperties.GetIntProperty("int-value");

            Console.WriteLine("property: " + property + "\n");
            int?expected = 1;

            Assert.Equal(expected, property.Value);

            IProperty <String, List <String> > property2 = stringProperties.GetListProperty("list-value");

            Console.WriteLine("property: " + property2 + "\n");
            List <String> expected2 = new List <string>()
            {
                "s1", "s2", "s3"
            };

            Assert.Equal(expected2, property2.Value);

            IProperty <String, Dictionary <String, String> > property3 = stringProperties.GetDictionaryProperty("map-value");

            Console.WriteLine("property: " + property3 + "\n");
            Dictionary <String, String> expected3 = new Dictionary <String, String>()
            {
                { "k1", "v1" },
                { "k2", "v2" },
                { "k3", "v3" }
            };

            Assert.Equal(expected3, property3.Value);

            IProperty <String, List <int?> > property4 = stringProperties.GetListProperty("int-list-value",
                                                                                          StringToIntConverter.Default);

            Console.WriteLine("property: " + property4 + "\n");
            List <int?> expected4 = new List <int?>()
            {
                1, 2, 3
            };

            Assert.Equal(expected4, property4.Value);

            IProperty <String, Dictionary <int?, long?> > property5 = stringProperties.GetDictionaryProperty("int-long-map-value",
                                                                                                             StringToIntConverter.Default, StringToLongConverter.Default);

            Console.WriteLine("property: " + property5 + "\n");
            Dictionary <int?, long?> expected5 = new Dictionary <int?, long?>()
            {
                { 1, 2L },
                { 3, 4L },
                { 5, 6L }
            };

            Assert.Equal(expected5, property5.Value);
        }
Esempio n. 2
0
        public virtual void TestSameKeyDifferentConfig()
        {
            StringProperties stringProperties = CreateStringProperties("test.properties");
            IProperty <String, Dictionary <String, String> > property = stringProperties.GetDictionaryProperty("map-value");
            Dictionary <String, String> expected = new Dictionary <String, String>()
            {
                { "k1", "v1" },
                { "k2", "v2" },
                { "k3", "v3" }
            };

            Assert.Equal(expected, property.Value);

            Assert.Throws <ArgumentException>(
                () => stringProperties.GetDictionaryProperty("map-value", StringToIntConverter.Default, StringToLongConverter.Default));
        }
Esempio n. 3
0
        public virtual void TestSameConfigSameProperty()
        {
            StringProperties stringProperties = CreateStringProperties("test.properties");
            IProperty <String, Dictionary <String, String> > property = stringProperties.GetDictionaryProperty("map-value");
            Dictionary <String, String> expected = new Dictionary <String, String>()
            {
                { "k1", "v1" },
                { "k2", "v2" },
                { "k3", "v3" }
            };

            Assert.Equal(expected, property.Value);

            IProperty <String, Dictionary <String, String> > property2 = stringProperties.GetDictionaryProperty("map-value");

            Console.WriteLine("property2: " + property + "\n");
            Assert.True(property == property2);
        }