public void GetTypedValues(NameValueCollection collection, string key, TestEnum[] expected)
        {
            var cs     = new NameValueConfigurationSource(collection);
            var result = ConfigurationSourceExtensions.GetTypedValues <TestEnum>(cs, key);

            Assert.Equal(expected, result);
        }
        public void GetString_NoMatches()
        {
            var collection = new NameValueCollection
            {
                { "example1", "value1" },
                { "example2", "value2" }
            };
            var cs     = new NameValueConfigurationSource(collection);
            var result = ConfigurationSourceExtensions.GetStrings(cs, "test");

            Assert.Empty(result);
        }
        public void GetString_MultipleValues()
        {
            var collection = new NameValueCollection
            {
                { "example1", "value1,value2,," }
            };
            var cs     = new NameValueConfigurationSource(collection);
            var result = ConfigurationSourceExtensions.GetStrings(cs, "example1");

            Assert.Contains(result, (v) => v == "value1");
            Assert.Contains(result, (v) => v == "value2");
            Assert.True(result.Count() == 2);
        }
Ejemplo n.º 4
0
 private static SingletonSettings GetSettings()
 {
     return(ConfigurationSourceExtensions.GetSection <SingletonSettings>(ConfigurationSourceName, SingletonSettings.SectionName));
 }
        public void GetTypedValue_CanHandleNullSource()
        {
            var result = ConfigurationSourceExtensions.GetTypedValue <TestEnum>(null, "example2");

            Assert.Equal(default(TestEnum), result);
        }
        public void GetStrings_CanHandleNullSource()
        {
            var result = ConfigurationSourceExtensions.GetStrings(null, "test");

            Assert.Same(Enumerable.Empty <string>(), result);
        }
        public void GetTypedValues_CanHandleNullSource()
        {
            var result = ConfigurationSourceExtensions.GetTypedValues <TestEnum>(null, "example2");

            Assert.True(result.Count() == 0);
        }