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"); }
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"); }
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"); }