示例#1
0
        public void read_text()
        {
            var data = new SettingsData(SettingCategory.core);
            data.Read("Key=Value1");
            data.Read("A.Key=Value2");

            data.AllKeys.ShouldHaveTheSameElementsAs("Key", "A.Key");

            data.Get("Key").ShouldEqual("Value1");
            data.Get("A.Key").ShouldEqual("Value2");
        }
示例#2
0
        public void read_complex_escaped_value()
        {
            var data = new SettingsData(SettingCategory.core);
            data.Read("DatabaseSettings.ConnectionString=\"Data Source=localhost;Initial Catalog=DovetailDAI;User Id=sa;Password=sa;\"");

            data.AllKeys.ShouldHaveTheSameElementsAs("DatabaseSettings.ConnectionString");

            data.Get("DatabaseSettings.ConnectionString").ShouldEqual("Data Source=localhost;Initial Catalog=DovetailDAI;User Id=sa;Password=sa;");
        }
        public void load_several_levels_of_nested_properties()
        {
            var source = new SettingsData(new Dictionary<string, object>(), "some name");

            source["A"] = 1;
            source["B"] =  2;
            source["Child.A"] =  2;
            source["Child.B"] =  3;
            source["Child.Nested.A"] =  4;
            source["Child.Nested.B"] =  5;

            source.Get("A").ShouldEqual(1);
            source.Get("B").ShouldEqual(2);
            source.As<IValueSource>().GetChild("Child").Get("A").ShouldEqual(2);
            source.As<IValueSource>().GetChild("Child").Get("B").ShouldEqual(3);
            source.As<IValueSource>().GetChild("Child").GetChild("Nested").Get("A").ShouldEqual(4);
            source.As<IValueSource>().GetChild("Child").GetChild("Nested").Get("B").ShouldEqual(5);
        }