예제 #1
0
        public void can_set_property_one_deep()
        {
            var prop = FindMembers.Member <DictTarget>(x => x.Property);

            var element = new DictionaryElement <DictTarget, string>(EnumStorage.AsString, new[] { "foo" }, prop);

            var target = new DictTarget
            {
                Property = "baz"
            };

            var dict = new Dictionary <string, object>();

            element.Write(target, dict);

            dict["foo"].ShouldBe("baz");
        }
예제 #2
0
        public void can_set_field_one_deep()
        {
            var field = FindMembers.Member <DictTarget>(x => x.Field);

            var element = new DictionaryElement <DictTarget, string>(EnumStorage.AsString, new[] { "foo" }, field);

            var target = new DictTarget
            {
                Field = "bar"
            };

            var dict = new Dictionary <string, object>();

            element.Write(target, dict);

            dict["foo"].ShouldBe("bar");
        }
        public void can_set_property_one_deep()
        {
            var prop = FindMembers.Member<DictTarget>(x => x.Property);

            var element = new DictionaryElement<DictTarget, string>(EnumStorage.AsString, new[] { "foo" }, prop);

            var target = new DictTarget
            {
                Property = "baz"
            };

            var dict = new Dictionary<string, object>();

            element.Write(target, dict);

            dict["foo"].ShouldBe("baz");
        }
        public void can_set_field_one_deep()
        {
            var field = FindMembers.Member<DictTarget>(x => x.Field);

            var element = new DictionaryElement<DictTarget, string>(EnumStorage.AsString, new []{ "foo" }, field);

            var target = new DictTarget
            {
                Field = "bar"
            };

            var dict = new Dictionary<string, object>();

            element.Write(target, dict);

            dict["foo"].ShouldBe("bar");
        }
예제 #5
0
        public void can_set_property_three_deep_to_existing_dictionary_structure()
        {
            var prop = FindMembers.Member <DictTarget>(x => x.Property);

            var element = new DictionaryElement <DictTarget, string>(EnumStorage.AsString, new[] { "one", "two", "three" }, prop);

            var target = new DictTarget
            {
                Property = "baz"
            };

            var dict = new Dictionary <string, object>();

            dict.Add("one", new Dictionary <string, object>());

            element.Write(target, dict);

            dict["one"].ShouldBeOfType <Dictionary <string, object> >()
            ["two"].ShouldBeOfType <Dictionary <string, object> >()
            ["three"].ShouldBe("baz");
        }
        public void can_set_property_three_deep_to_existing_dictionary_structure()
        {
            var prop = FindMembers.Member<DictTarget>(x => x.Property);

            var element = new DictionaryElement<DictTarget, string>(EnumStorage.AsString, new[] { "one", "two", "three" }, prop);

            var target = new DictTarget
            {
                Property = "baz"
            };

            var dict = new Dictionary<string, object>();
            dict.Add("one", new Dictionary<string, object>());

            element.Write(target, dict);

            dict["one"].ShouldBeOfType<Dictionary<string, object>>()
                ["two"].ShouldBeOfType<Dictionary<string, object>>()
                ["three"].ShouldBe("baz");

        }