public async Task DeleteAsyncById_CanDeleteEntities() { var store = new OfflineSQLiteStore(ConnectionString); store.DefineTable(TestTable, IdEntityDefinition); await store.InitializeAsync(); await store.UpsertAsync(TestTable, IdEntityValues, false); // Page before the deletion. var page = await store.GetPageAsync(new QueryDescription(TestTable) { IncludeTotalCount = true }); Assert.Equal(IdEntityValues.Length, page.Count); Assert.Contains(page.Items, o => o.Value <string>("stringValue") == "item#1"); var ids = IdEntityValues.Skip(2).Take(2).Select(o => o.Value <string>("id")).ToArray(); await store.DeleteAsync(TestTable, ids); // Page after the deletion. var page2 = await store.GetPageAsync(new QueryDescription(TestTable) { IncludeTotalCount = true }); Assert.Equal(IdEntityValues.Length - 2, page2.Count); Assert.DoesNotContain(page2.Items, o => o.Value <string>("id") == ids[0]); Assert.DoesNotContain(page2.Items, o => o.Value <string>("id") == ids[1]); }
public async Task GetItemAsync_ReturnsItem_WhenPresent() { var store = new OfflineSQLiteStore(ConnectionString); store.DefineTable(TestTable, IdEntityDefinition); await store.InitializeAsync(); await store.UpsertAsync(TestTable, IdEntityValues, false); var expected = IdEntityValues.Skip(2).First(); var result = await store.GetItemAsync(TestTable, expected.Value <string>("id")); Assert.Equal(expected.ToString(Formatting.None), result.ToString(Formatting.None)); }