Esempio n. 1
0
        public static void TestUseCase()
        {
            var list = new List <int> {
                7
            };
            var z = JSON.Stringify(list); // this is ok

            Assert.AreEqual("{\"items\":[7]}", z, "List<int>");

            var b = new Bridge501B()
            {
                1, 2
            };
            var y = JSON.Stringify(b); // wrong, missing items

            Assert.AreEqual("{\"items\":[1,2]}", y, "Bridge501B");

            var a = new Bridge501A()
            {
                7
            };                              // sine items is defined as member, push fails
            var x = JSON.Stringify(a);

            Assert.AreEqual("{\"items\":[7]}", x, "Bridge501A");

            var c = JSON.Parse <Bridge501A>(x);

            Assert.AreEqual("12", c.Items, "Bridge501A Parse c.Items");
            Assert.AreEqual(7, c[0], "Bridge501A Parse c[0]");
        }
Esempio n. 2
0
        public static void TestUseCase()
        {
            var list = new List <int> {
                7
            };
            var z = Bridge.Json.Serialize(list); // this is ok

            Assert.AreEqual("[7]", z, "List<int>");

            var b = new Bridge501B()
            {
                1, 2
            };
            var y = Bridge.Json.Serialize(b); // wrong, missing items

            Assert.AreEqual("[1,2]", y, "Bridge501B");

            var a = new Bridge501A()
            {
                7
            };                              // sine items is defined as member, push fails
            var x = Bridge.Json.Serialize(a);

            Assert.AreEqual("[7]", x, "Bridge501A");

            var c = Json.Deserialize <Bridge501A>(x);

            Assert.AreEqual("12", c.Items, "Bridge501A Parse c.Items");
            Assert.AreEqual(7, c[0], "Bridge501A Parse c[0]");
        }