From 4761bcf699a059fcc746bfa326f5c184c6161abf Mon Sep 17 00:00:00 2001 From: Hasan Khan Date: Wed, 19 Nov 2014 10:46:33 -0800 Subject: [PATCH] [client][managed][offline] config key prefixes should be static --- .../MobileServiceSQLiteStore.cs | 2 +- .../Table/Sync/MobileServiceSyncSettingsManager.cs | 4 ++-- .../Sync/MobileServiceSyncTable.Generic.Test.cs | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sdk/Managed/src/Microsoft.WindowsAzure.MobileServices.SQLiteStore/MobileServiceSQLiteStore.cs b/sdk/Managed/src/Microsoft.WindowsAzure.MobileServices.SQLiteStore/MobileServiceSQLiteStore.cs index 4ca7deea6..7c9b5b3eb 100644 --- a/sdk/Managed/src/Microsoft.WindowsAzure.MobileServices.SQLiteStore/MobileServiceSQLiteStore.cs +++ b/sdk/Managed/src/Microsoft.WindowsAzure.MobileServices.SQLiteStore/MobileServiceSQLiteStore.cs @@ -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); } diff --git a/sdk/Managed/src/Microsoft.WindowsAzure.MobileServices/Table/Sync/MobileServiceSyncSettingsManager.cs b/sdk/Managed/src/Microsoft.WindowsAzure.MobileServices/Table/Sync/MobileServiceSyncSettingsManager.cs index 46ba45a64..525076d14 100644 --- a/sdk/Managed/src/Microsoft.WindowsAzure.MobileServices/Table/Sync/MobileServiceSyncSettingsManager.cs +++ b/sdk/Managed/src/Microsoft.WindowsAzure.MobileServices/Table/Sync/MobileServiceSyncSettingsManager.cs @@ -113,12 +113,12 @@ private async Task 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() diff --git a/sdk/Managed/test/Microsoft.WindowsAzure.MobileServices.Test/UnitTests/Table/Sync/MobileServiceSyncTable.Generic.Test.cs b/sdk/Managed/test/Microsoft.WindowsAzure.MobileServices.Test/UnitTests/Table/Sync/MobileServiceSyncTable.Generic.Test.cs index 03373159f..1eba3fc6f 100644 --- a/sdk/Managed/test/Microsoft.WindowsAzure.MobileServices.Test/UnitTests/Table/Sync/MobileServiceSyncTable.Generic.Test.cs +++ b/sdk/Managed/test/Microsoft.WindowsAzure.MobileServices.Test/UnitTests/Table/Sync/MobileServiceSyncTable.Generic.Test.cs @@ -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] @@ -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] @@ -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" } }; @@ -899,7 +899,7 @@ public async Task PurgeAsync_ResetsDeltaToken_WhenQueryIdIsSpecified() Assert.AreEqual(store.TableMap["stringId_test_table"]["def"].Value("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); @@ -907,7 +907,7 @@ public async Task PurgeAsync_ResetsDeltaToken_WhenQueryIdIsSpecified() // 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()); @@ -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() { { deltaKey, new JObject() } }; // insert an item but don't push