public void TestSmartQueryDoingCount() { JArray result = Store.Query(QuerySpec.BuildSmartQuerySpec("select count(*) from {employees}", 1), 0); JArray compare = JArray.Parse("[[7]]"); Assert.AreEqual(compare.ToString(), result.ToString()); }
public void TestUpsertManyEntries() { Debug.WriteLine("SmartStoreLoadTest", "In testUpsertManyEntries"); for (int k = 1; k < MAX_NUMBER_ENTRIES; k *= 2) { UpsertManyEntriesWithManyFields(k); } JArray result = Store.Query( QuerySpec.BuildSmartQuerySpec( "select {test_soup:key} from {" + TEST_SOUP + "} WHERE {test_soup:key} = 'k_100'", 1), 0); JArray compare = JArray.Parse("[[\"k_100\"]]"); Assert.AreEqual(compare.ToString(), result.ToString()); }
public async Task TestSyncUpWithLocallyUpdatedRecords() { // first sync down TrySyncDown(SyncState.MergeModeOptions.Overwrite); // make local changes Dictionary <string, string> idToNamesLocallyUpdated = MakeSomeLocalChanges(); // sync up TrySyncUp(3); // check that the db doesn't show entries as locally modified anymore Dictionary <string, string> .KeyCollection ids = idToNamesLocallyUpdated.Keys; string idsClause = "('" + String.Join("', '", ids) + "')"; QuerySpec smartStoreQuery = QuerySpec.BuildSmartQuerySpec( "SELECT {accounts:_soup} FROM {accounts} WHERE {accounts:Id} IN " + idsClause, ids.Count); JArray accountsFromDb = _smartStore.Query(smartStoreQuery, 0); foreach (JArray row in accountsFromDb.Select(row => row.ToObject <JArray>())) { var soupElt = row[0].ToObject <JObject>(); Assert.AreEqual(false, soupElt.ExtractValue <bool>(SyncManager.Local), "Wrong local flag"); Assert.AreEqual(false, soupElt.ExtractValue <bool>(SyncManager.LocallyUpdated), "Wrong local flag"); } string soql = "SELECT Id, Name FROM Account WHERE Id IN " + idsClause; var request = RestRequest.GetRequestForQuery(ApiVersionStrings.VersionNumber, soql); var response = await _restClient.SendAsync(request); var records = response.AsJObject.ExtractValue <JArray>(RecordsStr); var idToNamesFromServer = new JObject(); foreach (JToken rowToken in records) { var row = rowToken.ToObject <JObject>(); idToNamesFromServer[row.ExtractValue <string>(Constants.Id)] = row.ExtractValue <string>(Constants.Name); } Assert.IsTrue(JToken.DeepEquals(JObject.FromObject(idToNamesLocallyUpdated), idToNamesFromServer)); }