Beispiel #1
0
        public void KeepInstanceTest1()
        {
            // Create model and save it
            var ki = new ModelKeepInstance();

            ki.InstObj         = new InstanceObject();
            ki.InstObj.IntVal1 = 1;
            ki.InstObj.IntVal2 = 2;
            var json = Json.Format(ki);

            // Update the kept instance object
            ki.InstObj.IntVal1 = 11;
            ki.InstObj.IntVal2 = 12;

            // Reload
            var oldInst = ki.InstObj;

            Json.ParseInto(json, ki);

            // Check object instance kept
            Assert.AreSame(oldInst, ki.InstObj);

            // Check json properties updated, others not
            Assert.AreEqual(ki.InstObj.IntVal1, 1);
            Assert.AreEqual(ki.InstObj.IntVal2, 12);
        }
Beispiel #2
0
        public void KeepInstanceTest2()
        {
            // Create model and save it
            var ki = new ModelKeepInstance();

            ki.InstObj         = new InstanceObject();
            ki.InstObj.IntVal1 = 1;
            ki.InstObj.IntVal2 = 2;
            var json = Json.Format(ki);

            // Update the kept instance object
            ki.InstObj = null;

            // Reload
            Json.ParseInto(json, ki);

            // Check object instance kept
            Assert.IsNotNull(ki.InstObj);

            // Check json properties updated, others not
            Assert.AreEqual(ki.InstObj.IntVal1, 1);
            Assert.AreEqual(ki.InstObj.IntVal2, 0);
        }
Beispiel #3
0
        public void KeepInstanceTest1()
        {
            // Create model and save it
            var ki = new ModelKeepInstance();
            ki.InstObj = new InstanceObject();
            ki.InstObj.IntVal1 = 1;
            ki.InstObj.IntVal2 = 2;
            var json = Json.Format(ki);

            // Update the kept instance object
            ki.InstObj.IntVal1 = 11;
            ki.InstObj.IntVal2 = 12;

            // Reload
            var oldInst = ki.InstObj;
            Json.ParseInto(json, ki);

            // Check object instance kept
            Assert.AreSame(oldInst, ki.InstObj);

            // Check json properties updated, others not
            Assert.AreEqual(ki.InstObj.IntVal1, 1);
            Assert.AreEqual(ki.InstObj.IntVal2, 12);
        }
Beispiel #4
0
        public void KeepInstanceTest2()
        {
            // Create model and save it
            var ki = new ModelKeepInstance();
            ki.InstObj = new InstanceObject();
            ki.InstObj.IntVal1 = 1;
            ki.InstObj.IntVal2 = 2;
            var json = Json.Format(ki);

            // Update the kept instance object
            ki.InstObj = null;

            // Reload
            Json.ParseInto(json, ki);

            // Check object instance kept
            Assert.IsNotNull(ki.InstObj);

            // Check json properties updated, others not
            Assert.AreEqual(ki.InstObj.IntVal1, 1);
            Assert.AreEqual(ki.InstObj.IntVal2, 0);
        }