Exemple #1
0
        public void Deserialize_Succeeds_WhenVersionSequenceOrStateIsNull()
        {
            var serializedOperation = JObject.Parse(@"
            {""id"":""70cf6cc2-5981-4a32-ae6c-249572917a46"",
            ""kind"": 2,
            ""tableName"":""test"",
            ""itemId"":""abc"",
            ""version"":null,
            ""sequence"":null,
            ""state"":null,
            ""item"":""{\""id\"":\""abc\"",\""text\"":\""example\""}"",
            ""__createdAt"":""2014-03-11T20:37:10.3366689Z"",
            ""sequence"":0
            }");
            var operation           = MobileServiceTableOperation.Deserialize(serializedOperation);

            Assert.AreEqual(serializedOperation["id"], operation.Id);
            Assert.AreEqual(serializedOperation["itemId"], operation.ItemId);
            Assert.AreEqual(serializedOperation["tableName"], operation.TableName);
            Assert.AreEqual(MobileServiceTableOperationKind.Delete, operation.Kind);
            Assert.AreEqual(serializedOperation["sequence"], operation.Sequence);
            Assert.AreEqual(0, operation.Version);
            Assert.AreEqual("abc", operation.Item["id"]);
            Assert.AreEqual("example", operation.Item["text"]);
        }
Exemple #2
0
        public void Deserialize_Succeeds()
        {
            var serializedOperation = JObject.Parse("{\"id\":\"70cf6cc2-5981-4a32-ae6c-249572917a46\",\"kind\": 0,\"tableName\":\"test\",\"itemId\":\"abc\",\"item\":null,\"__createdAt\":\"2014-03-11T20:37:10.3366689Z\",\"sequence\":0}");

            var operation = MobileServiceTableOperation.Deserialize(serializedOperation);

            Assert.AreEqual(serializedOperation["id"], operation.Id);
            Assert.AreEqual(serializedOperation["itemId"], operation.ItemId);
            Assert.AreEqual(serializedOperation["tableName"], operation.TableName);
            Assert.AreEqual(MobileServiceTableOperationKind.Insert, operation.Kind);
            Assert.IsNull(operation.Item);
            Assert.AreEqual(serializedOperation["sequence"], operation.Sequence);
        }