コード例 #1
0
        public void LoadIntoTest()
        {
            var configuration = new ReflectionAdapter(new DotNetConfigurationStore()
            {
                FileName = "ConfigKramLoadTest.config"
            });
            var test = new TestConfigurationObject {
                TestString = "", TestInt = 0, TestNullableInt = 1
            };

            configuration.LoadInto(test);
            Assert.Equal("default", test.TestString);
            Assert.Equal(10, test.TestInt);
            Assert.Null(test.TestNullableInt);
        }
コード例 #2
0
        public void SaveTest()
        {
            var configuration = new ReflectionAdapter(new DotNetConfigurationStore()
            {
                FileName = "ConfigKramSaveTest.config"
            });
            var test = new TestConfigurationObject {
                TestString = nameof(SaveTest), TestInt = -1, TestNullableInt = null
            };

            configuration.Save(test);

            test = new TestConfigurationObject();
            configuration.LoadInto(test);

            Assert.Equal(nameof(SaveTest), test.TestString);
            Assert.Equal(-1, test.TestInt);
            Assert.Null(test.TestNullableInt);
        }