Esempio n. 1
0
        public void TestBasics()
        {
            var all = new AllTypes();
            all.Init();
            var json = Json.Format(all);
            var all2 = Json.Parse<AllTypes>(json);

            Compare(all, all2);
        }
Esempio n. 2
0
        public void TestNegatives()
        {
            var all = new AllTypes();
            all.Init();
            all.SByte = -1;
            all.Short = -2;
            all.Int = -3;
            all.Long = -4;
            all.Decimal = -5.1M;
            all.Float = -6.2f;
            all.Double = -7.3;

            var json = Json.Format(all);
            var all2 = Json.Parse<AllTypes>(json);
            Compare(all, all2);
        }
Esempio n. 3
0
        public void TestMaxValue()
        {
            var all = new AllTypes();
            all.Init();
            all.Bool = true;
            all.Byte = Byte.MaxValue;
            all.SByte = SByte.MaxValue;
            all.Short = short.MaxValue;
            all.UShort = ushort.MaxValue;
            all.Int = int.MaxValue;
            all.UInt = uint.MaxValue;
            all.Long = long.MaxValue;
            all.ULong = ulong.MaxValue;
            all.Decimal = decimal.MaxValue;
            all.Float = float.MaxValue;
            all.Double = double.MaxValue;

            var json = Json.Format(all);
            Console.WriteLine(json);
            var all2 = Json.Parse<AllTypes>(json);
            Compare(all, all2);
        }
Esempio n. 4
0
 void Compare(AllTypes all, AllTypes all2)
 {
     Assert.AreEqual(all.String, all2.String);
     Assert.AreEqual(all.Char, all2.Char);
     Assert.AreEqual(all.Bool, all2.Bool);
     Assert.AreEqual(all.Byte, all2.Byte);
     Assert.AreEqual(all.SByte, all2.SByte);
     Assert.AreEqual(all.Short, all2.Short);
     Assert.AreEqual(all.UShort, all2.UShort);
     Assert.AreEqual(all.Int, all2.Int);
     Assert.AreEqual(all.UInt, all2.UInt);
     Assert.AreEqual(all.Long, all2.Long);
     Assert.AreEqual(all.ULong, all2.ULong);
     Assert.AreEqual(all.Decimal, all2.Decimal);
     Assert.AreEqual(all.Float, all2.Float);
     Assert.AreEqual(all.Double, all2.Double);
     Assert.AreEqual(all.DateTime, all2.DateTime);
     Assert.IsTrue((all.Blob==null && all2.Blob==null) || Convert.ToBase64String(all.Blob)==Convert.ToBase64String(all2.Blob));
 }