예제 #1
0
        public void StructTest()
        {
            var o = new ModelStruct();

            o.IntField = 23;
            o.IntProp  = 24;

            var json = Json.Format(o);

            Assert.Contains(json, "23");
            Assert.Contains(json, "24");

            var o2 = Json.Parse <ModelStruct>(json);

            Assert.AreEqual(o2.IntField, 23);
            Assert.AreEqual(o2.IntProp, 24);

            // Test parseInto on a value type not supported
            var o3 = new ModelStruct();

            Assert.Throws <InvalidOperationException>(() => Json.ParseInto(json, o3));
        }
예제 #2
0
        public void StructTest()
        {
            var o = new ModelStruct();
            o.IntField = 23;
            o.IntProp = 24;

            var json = Json.Format(o);
            Assert.Contains(json, "23");
            Assert.Contains(json, "24");

            var o2 = Json.Parse<ModelStruct>(json);
            Assert.AreEqual(o2.IntField, 23);
            Assert.AreEqual(o2.IntProp, 24);

            // Test parseInto on a value type not supported
            var o3 = new ModelStruct();
            Assert.Throws<InvalidOperationException>(() => Json.ParseInto(json, o3));
        }