Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.

Commit

Permalink
[client][managed][offline] save tableKind in the errors table
Browse files Browse the repository at this point in the history
  • Loading branch information
hasankhan committed Nov 12, 2014
1 parent 9c7f72f commit 23f2ef0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ private async Task<bool> ExecuteOperationAsync(MobileServiceTableOperation opera
rawResult,
result)
{
TableKind = this.tableKind,
Context = this.context
};
await batch.AddSyncErrorAsync(syncError);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public class MobileServiceTableOperationError
/// </summary>
public MobileServiceTableOperationKind OperationKind { get; private set; }

/// <summary>
/// The kind of table
/// </summary>
internal MobileServiceTableKind TableKind { get; set; }

/// <summary>
/// The name of the remote table.
/// </summary>
Expand Down Expand Up @@ -138,6 +143,7 @@ internal static void DefineTable(MobileServiceLocalStore store)
{ "operationVersion", 0 },
{ "operationKind", 0 },
{ "tableName", String.Empty },
{ "tableKind", 0 },
{ "item", String.Empty },
{ "rawResult", String.Empty }
});
Expand All @@ -153,6 +159,7 @@ internal JObject Serialize()
{ "operationVersion", this.OperationVersion },
{ "operationKind", (int)this.OperationKind },
{ "tableName", this.TableName },
{ "tableKind", (int)this.TableKind },
{ "item", this.Item.ToString(Formatting.None) },
{ "rawResult", this.RawResult }
};
Expand All @@ -170,6 +177,8 @@ internal static MobileServiceTableOperationError Deserialize(JObject obj, Mobile
long operationVersion = obj.Value<long?>("operationVersion").GetValueOrDefault();
MobileServiceTableOperationKind operationKind = (MobileServiceTableOperationKind)obj.Value<int>("operationKind");
var tableName = obj.Value<string>("tableName");
var tableKind = (MobileServiceTableKind)obj.Value<int?>("tableKind").GetValueOrDefault();

string itemStr = obj.Value<string>("item");
JObject item = itemStr == null ? null : JObject.Parse(itemStr);
string rawResult = obj.Value<string>("rawResult");
Expand All @@ -184,7 +193,8 @@ internal static MobileServiceTableOperationError Deserialize(JObject obj, Mobile
rawResult,
result)
{
Id = id
Id = id,
TableKind = tableKind
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public void Deserialize_Succeeds()
""operationVersion"":123,
""operationKind"":0,
""tableName"":""test"",
""tableKind"":1,
""item"":""{\""id\"":\""abc\"",\""text\"":\""example\""}"",
""rawResult"":""{\""id\"":\""abc\"",\""text\"":\""example\""}""
}");
Expand All @@ -37,6 +38,7 @@ public void Deserialize_Succeeds()
Assert.AreEqual(serializedError["operationVersion"], operation.OperationVersion);
Assert.AreEqual(serializedError["operationKind"], (int)operation.OperationKind);
Assert.AreEqual(serializedError["tableName"], operation.TableName);
Assert.AreEqual(serializedError["tableKind"], (int)operation.TableKind);
Assert.AreEqual(serializedError["item"], operation.Item.ToString(Formatting.None));
Assert.AreEqual(serializedError["rawResult"], operation.RawResult);
}
Expand All @@ -51,6 +53,7 @@ public void Deserialize_Succeeds_WhenOperationVersionIsNull()
""operationVersion"":null,
""operationKind"":0,
""tableName"":""test"",
""tableKind"":1,
""item"":""{\""id\"":\""abc\"",\""text\"":\""example\""}"",
""rawResult"":""{\""id\"":\""abc\"",\""text\"":\""example\""}""
}");
Expand All @@ -62,6 +65,7 @@ public void Deserialize_Succeeds_WhenOperationVersionIsNull()
Assert.AreEqual(0, operation.OperationVersion);
Assert.AreEqual(serializedError["operationKind"], (int)operation.OperationKind);
Assert.AreEqual(serializedError["tableName"], operation.TableName);
Assert.AreEqual(serializedError["tableKind"], (int)operation.TableKind);
Assert.AreEqual(serializedError["item"], operation.Item.ToString(Formatting.None));
Assert.AreEqual(serializedError["rawResult"], operation.RawResult);
}
Expand Down

0 comments on commit 23f2ef0

Please sign in to comment.