コード例 #1
0
        public void ConfigurationSection_Get_ValueTypeTest()
        {
            var testOptions = new TestableConfigurationSection <ComplexTestOptions>(new ComplexTestOptions());

            Assert.IsInstanceOfType(testOptions.Get <int>("TestValueType"), typeof(int));
            Assert.AreEqual(42, testOptions.Get <int>("TestValueType"));
        }
コード例 #2
0
        public void ConfigurationSection_FieldTest()
        {
            var testOptions = new TestableConfigurationSection <SimpleTestOptions>(new SimpleTestOptions(testString));

            Assert.IsNotNull(testOptions.Value.TestField);
            Assert.IsNull(testOptions["TestField"]);
        }
コード例 #3
0
        public void ConfigurationSection_GetTest()
        {
            var testOptions = new TestableConfigurationSection <ComplexTestOptions>(new ComplexTestOptions());

            Assert.IsInstanceOfType(testOptions.Get <string>("TestProperty"), typeof(string));
            Assert.IsInstanceOfType(testOptions.Get <SimpleTestOptions>("TestOptions"), typeof(SimpleTestOptions));
        }
コード例 #4
0
        public void ConfigurationSection_SimpleTest()
        {
            var testOptions = new TestableConfigurationSection <SimpleTestOptions>(new SimpleTestOptions(testString));

            Assert.IsNotNull(testOptions.Value.TestProperty);
            Assert.AreEqual(testString, testOptions.Value.TestProperty);
        }
コード例 #5
0
        public void ConfigurationSection_NullValueTest()
        {
            var testOptions = new TestableConfigurationSection <NullValueTestOptions>(new NullValueTestOptions());

            Assert.IsNull(testOptions.Value.Test);
            Assert.IsNull(testOptions["test"]);
        }
コード例 #6
0
        public void ConfigurationSection_GetPropertyWithCasingTest()
        {
            var testOptions = new TestableConfigurationSection <SimpleTestOptions>(new SimpleTestOptions(testString));

            Assert.AreEqual(testString, testOptions["TestProperty"]);
            Assert.AreEqual(testString, testOptions["testproperty"]);
            Assert.AreEqual(testString, testOptions["TeStPrOpErTy"]);
        }
コード例 #7
0
        public void ConfigurationSection_TypeTest()
        {
            var testOptions = new TestableConfigurationSection <TypeTestOptions>(new TypeTestOptions());

            Assert.IsNotNull(testOptions);
            Assert.IsInstanceOfType(testOptions, typeof(IOptions <TypeTestOptions>));
            Assert.IsNotNull(testOptions.Value);
            Assert.IsInstanceOfType(testOptions.Value, typeof(TypeTestOptions));
        }
コード例 #8
0
        public void ConfigurationSection_Get_WithDefaultsTest()
        {
            var testOptions   = new TestableConfigurationSection <ComplexTestOptions>(new ComplexTestOptions());
            var resultString1 = testOptions.Get <string>("TestProperty");
            var resultString2 = testOptions.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);
        }
コード例 #9
0
        public void ConfigurationSection_Get_UnknownPropertyTest()
        {
            var testOptions = new TestableConfigurationSection <ComplexTestOptions>(new ComplexTestOptions());

            Assert.IsNull(testOptions.Get <string>("TestProperty2"));
        }
コード例 #10
0
        public void ConfigurationSection_UnknownPropertyTest()
        {
            var testOptions = new TestableConfigurationSection <SimpleTestOptions>(new SimpleTestOptions(testString));

            Assert.IsNull(testOptions["UnknownProperty"]);
        }