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] config key prefixes should be static
Browse files Browse the repository at this point in the history
  • Loading branch information
hasankhan committed Nov 20, 2014
1 parent d11963a commit 4761bcf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ private async Task InitializeConfig()
if (!MobileServiceLocalSystemTables.All.Contains(table.Key))
{
// preserve system properties setting for non-system tables
string name = String.Format("{0}_systemProperties", table.Key);
string name = String.Format("systemProperties_{0}", table.Key);
string value = ((int)table.Value.SystemProperties).ToString();
await this.SaveSetting(name, value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ private async Task<string> GetSettingAsync(string key, string defaultValue)

private string GetDeltaTokenKey(string tableName, string queryId)
{
return tableName + "_deltaToken_" + queryId;
return "deltaToken_" + tableName + "_" + queryId;
}

private static string GetSystemPropertiesKey(string tableName)
{
return tableName + "_systemProperties";
return "systemProperties_" + tableName;
}

public void Dispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public async Task PullAsync_UpdatesDeltaToken_AfterEachResult_IfOrderByIsSupport
AssertEx.MatchUris(hijack.Requests, "http://www.test.com/tables/stringId_test_table?$filter=(__updatedAt ge datetimeoffset'1970-01-01T00:00:00.0000000%2B00:00')&$orderby=__updatedAt&$skip=0&$top=50&__includeDeleted=true&__systemproperties=__updatedAt%2C__version%2C__deleted",
"http://www.test.com/tables/stringId_test_table?$filter=(__updatedAt ge datetimeoffset'2001-02-04T00:00:00.0000000%2B00:00')&$orderby=__updatedAt&$skip=0&$top=50&__includeDeleted=true&__systemproperties=__updatedAt%2C__version%2C__deleted");

Assert.Equals(store.TableMap[MobileServiceLocalSystemTables.Config]["stringId_test_table_deltaToken_items"]["value"], "2001-02-04T00:00:00.0000000+00:00");
Assert.Equals(store.TableMap[MobileServiceLocalSystemTables.Config]["deltaToken_stringId_test_table_items"]["value"], "2001-02-04T00:00:00.0000000+00:00");
}

[AsyncTestMethod]
Expand Down Expand Up @@ -288,7 +288,7 @@ public async Task PullAsync_DoesNotUpdateDeltaToken_AfterEachResult_IfOrderByIsN
AssertEx.MatchUris(hijack.Requests, "http://www.test.com/tables/stringId_test_table?$filter=(__updatedAt ge datetimeoffset'1970-01-01T00:00:00.0000000%2B00:00')&$skip=0&$top=50&__includeDeleted=true&__systemproperties=__updatedAt%2C__version%2C__deleted",
"http://www.test.com/tables/stringId_test_table?$filter=(__updatedAt ge datetimeoffset'1970-01-01T00:00:00.0000000%2B00:00')&$skip=2&$top=50&__includeDeleted=true&__systemproperties=__updatedAt%2C__version%2C__deleted");

Assert.IsFalse(store.TableMap[MobileServiceLocalSystemTables.Config].ContainsKey("stringId_test_table_deltaToken_items"));
Assert.IsFalse(store.TableMap[MobileServiceLocalSystemTables.Config].ContainsKey("deltaToken_stringId_test_table_items"));
}

[AsyncTestMethod]
Expand Down Expand Up @@ -771,9 +771,9 @@ private static async Task TestIncrementalPull(MobileServiceLocalStoreMock store,
hijack.AddResponseContent(@"[]");


store.TableMap[MobileServiceLocalSystemTables.Config]["stringId_test_table_systemProperties"] = new JObject
store.TableMap[MobileServiceLocalSystemTables.Config]["systemProperties_stringId_test_table"] = new JObject
{
{ MobileServiceSystemColumns.Id, "stringId_test_table_systemProperties" },
{ MobileServiceSystemColumns.Id, "systemProperties_stringId_test_table" },
{ "value", "1" }
};

Expand Down Expand Up @@ -899,15 +899,15 @@ public async Task PurgeAsync_ResetsDeltaToken_WhenQueryIdIsSpecified()
Assert.AreEqual(store.TableMap["stringId_test_table"]["def"].Value<string>("String"), "How");

// ensure delta token was updated
Assert.Equals(store.TableMap[MobileServiceLocalSystemTables.Config]["stringId_test_table_deltaToken_items"]["value"], "2001-02-04T00:00:00.0000000+00:00");
Assert.Equals(store.TableMap[MobileServiceLocalSystemTables.Config]["deltaToken_stringId_test_table_items"]["value"], "2001-02-04T00:00:00.0000000+00:00");

// now purge and forget the delta token
await table.PurgeAsync("items", null, false, CancellationToken.None);

// make sure data is purged
Assert.AreEqual(store.TableMap["stringId_test_table"].Count, 0);
// make sure delta token is removed
Assert.IsFalse(store.TableMap[MobileServiceLocalSystemTables.Config].ContainsKey("stringId_test_table_deltaToken_items"));
Assert.IsFalse(store.TableMap[MobileServiceLocalSystemTables.Config].ContainsKey("deltaToken_stringId_test_table_items"));

// pull again
await table.PullAsync("items", table.CreateQuery());
Expand Down Expand Up @@ -983,7 +983,7 @@ public async Task PurgeAsync_DeletesOperations_WhenThereIsOperationInTable_AndFo
await service.SyncContext.InitializeAsync(store, new MobileServiceSyncHandler());

// put a dummy delta token
string deltaKey = "someTable_deltaToken_abc";
string deltaKey = "deltaToken_someTable_abc";
store.TableMap[MobileServiceLocalSystemTables.Config] = new Dictionary<string, JObject>() { { deltaKey, new JObject() } };

// insert an item but don't push
Expand Down

0 comments on commit 4761bcf

Please sign in to comment.