示例#1
0
        public void ConfigurationRoot_GetTest()
        {
            var root = new TestableConfigurationRoot <ComplexTestOptions>(new ComplexTestOptions());

            Assert.IsInstanceOfType(root.Get <string>("TestProperty"), typeof(string));
            Assert.IsInstanceOfType(root.Get <SimpleTestOptions>("TestOptions"), typeof(SimpleTestOptions));
        }
示例#2
0
        public void ConfigurationRoot_GetSectionTest()
        {
            var root = new TestableConfigurationRoot <SimpleTestOptions>(new SimpleTestOptions("default"));

            var section = root.GetSection <SimpleTestOptions>("");

            Assert.IsNotNull(section);
            Assert.IsInstanceOfType(section.Value, typeof(SimpleTestOptions));
            Assert.AreEqual("default", section.Value.TestProperty);
        }
示例#3
0
        public void ConfigurationRoot_Get_WithDefaultsTest()
        {
            var root          = new TestableConfigurationRoot <ComplexTestOptions>(new ComplexTestOptions());
            var resultString1 = root.Get <string>("TestProperty");
            var resultString2 = root.Get <string>("TestProperty2", "applied default value");

            Assert.IsInstanceOfType(resultString1, typeof(string));
            Assert.AreEqual("default value", resultString1);
            Assert.IsInstanceOfType(resultString2, typeof(string));
            Assert.AreEqual("applied default value", resultString2);
        }
示例#4
0
        public void ConfigurationRoot_Get_UnknownPropertyTest()
        {
            var root = new TestableConfigurationRoot <ComplexTestOptions>(new ComplexTestOptions());

            Assert.IsNull(root.Get <string>("TestProperty2"));
        }