Ejemplo n.º 1
0
        public void TestJSonSerializtion()
        {
            string nullObj = null;
            string json    = nullObj.ToJsonString();

            Assert.AreEqual("null", json);

            nullObj = json.FromJsonString <string>();
            Assert.AreEqual(null, nullObj);

            IList <Address> addresses = LinqTests.GetQueryCustomerAddressesByCustomerId();

            json = AOP.Invoke(AspectacularTest.TestAspects, () => addresses.ToJsonString());

            Address[] deserializedAddresses = json.FromJsonString <Address[]>();

            Assert.AreEqual(addresses.Count, deserializedAddresses.Length);
            deserializedAddresses.For((addr, i) => Assert.AreEqual(addr[i].ToJsonString(), deserializedAddresses[i].ToJsonString()));

            deserializedAddresses[0].AddressID++;
            Assert.AreNotEqual(addresses[0].ToJsonString(), deserializedAddresses[0].ToJsonString());
        }