예제 #1
0
        public void Test10()
        {
            var data = new DataWithObject();

            data.Value = (double)2;
            string json  = Framework.Server.Json.Util.Serialize(data);
            var    data2 = Framework.Server.Json.Util.Deserialize <DataWithObject>(json);

            Util.Assert((double)data2.Value == 2);
        }
예제 #2
0
        public void Test08()
        {
            var data = new DataWithObject();

            data.Value = "H";
            string json  = Framework.Server.Json.Util.Serialize(data);
            var    data2 = Framework.Server.Json.Util.Deserialize <DataWithObject>(json);

            Util.Assert((string)data2.Value == "H");
        }
예제 #3
0
        public void Test13()
        {
            var data = new DataWithObject();

            data.Value = new DataWithListItem2()
            {
                Name = "M"
            };
            string json  = Framework.Server.Json.Util.Serialize(data);
            var    data2 = Framework.Server.Json.Util.Deserialize <DataWithObject>(json);

            Util.Assert(data2.Value.GetType() == typeof(DataWithListItem2));
            Util.Assert(((DataWithListItem2)data2.Value).Name == "M");
        }
예제 #4
0
        public void Test12()
        {
            var data = new DataWithObject();

            data.Value = new DataWithListItem();
            try
            {
                string json = Framework.Server.Json.Util.Serialize(data);
            }
            catch (Framework.Server.Json.JsonException exception)
            {
                Util.Assert(exception.Message == "Object has no Type field!");
            }
        }
예제 #5
0
        public void Test11()
        {
            var data = new DataWithObject();

            data.Value = (int)2;
            try
            {
                string json = Framework.Server.Json.Util.Serialize(data);
            }
            catch (Framework.Server.Json.JsonException exception)
            {
                Util.Assert(exception.Message == "Allowed types: string, double or bool!");
            }
        }