Example #1
0
        public static JsonTestObj PrepareData()
        {
            JsonTestObj result = new JsonTestObj();

            result.ID       = UuidHelper.NewUuidString();
            result.Age      = 41;
            result.Birthday = new DateTime(1972, 4, 26, 12, 40, 0, DateTimeKind.Local);

            return(result);
        }
Example #2
0
        public static JsonTestObj PrepareData()
        {
            JsonTestObj result = new JsonTestObj();

            result.ID = UuidHelper.NewUuidString();
            result.Age = 41;
            result.Birthday = new DateTime(1972, 4, 26, 12, 40, 0, DateTimeKind.Local);

            return result;
        }
Example #3
0
        public void SimpleObjectJsonTest()
        {
            JsonTestObj data = JsonTestObj.PrepareData();

            string json = JSONSerializerExecute.Serialize(data);

            Console.WriteLine(json);

            JsonTestObj deserializedData = JSONSerializerExecute.Deserialize <JsonTestObj>(json);

            AssertObjects(data, deserializedData);
        }
Example #4
0
        public void DictObjectJsonTest()
        {
            Dictionary <string, object> source = new Dictionary <string, object>();

            JsonTestObj data = JsonTestObj.PrepareData();

            source.Add("Data", data);

            string json = JSONSerializerExecute.SerializeWithType(source);

            Console.WriteLine(json);

            Dictionary <string, object> deserializedData = JSONSerializerExecute.Deserialize <Dictionary <string, object> >(json);

            AssertObjects((JsonTestObj)source["Data"], (JsonTestObj)deserializedData["Data"]);
        }
Example #5
0
        public void ListObjectJsonTest()
        {
            JsonTestObj data = JsonTestObj.PrepareData();

            List <JsonTestObj> source = new List <JsonTestObj>();

            source.Add(data);

            string json = JSONSerializerExecute.Serialize(source);

            Console.WriteLine(json);

            List <JsonTestObj> deserializedData = JSONSerializerExecute.Deserialize <List <JsonTestObj> >(json);

            AssertObjects(data, deserializedData[0]);
        }
Example #6
0
 private static void AssertObjects(JsonTestObj source, JsonTestObj dest)
 {
     Assert.AreEqual(source.ID, dest.ID);
     Assert.AreEqual(source.Age, dest.Age);
     Assert.AreEqual(source.Birthday, dest.Birthday);
 }
 private static void AssertObjects(JsonTestObj source, JsonTestObj dest)
 {
     Assert.AreEqual(source.ID, dest.ID);
     Assert.AreEqual(source.Age, dest.Age);
     Assert.AreEqual(source.Birthday, dest.Birthday);
 }