コード例 #1
0
        public void SimplePropertyDeserializationTest()
        {
            var jsonString =
                "{\"NestedNode\":{\"Data\":\"test\"}}";

            var expectedResult = new PropertyTestModel <string> {
                Data = "test"
            };

            var result = JsonConvert.DeserializeObject <PropertyTestModel <string> >(jsonString);

            expectedResult.ShouldDeepEqual(result);
        }
コード例 #2
0
        public void SerializationWithObjectPropertyTest()
        {
            var jsonString =
                "{\"NestedNode\":{\"Data\":{\"name\":\"test\"}}}";

            var obj =
                new PropertyTestModel <ModelWithJsonProperty> {
                Data = new ModelWithJsonProperty {
                    Name = "test"
                }
            };

            var result = JsonConvert.SerializeObject(obj);

            result.ShouldDeepEqual(jsonString);
        }
コード例 #3
0
        public void NestedObjectPropertyDeserializationTest()
        {
            var jsonString =
                "{\"NestedNode\":{\"Data\":{\"name\":\"test\"}}}";

            var expectedResult =
                new PropertyTestModel <ModelWithJsonProperty> {
                Data = new ModelWithJsonProperty {
                    Name = "test"
                }
            };

            var result = JsonConvert.DeserializeObject <PropertyTestModel <ModelWithJsonProperty> >(jsonString);

            expectedResult.ShouldDeepEqual(result);
        }