public async Task FilterReadAsyncWithIntegerAsStringIdAgainstIntegerIdTable() { await EnsureEmptyTableAsync <ToDoWithIntId>(); IMobileServiceTable <ToDoWithIntId> table = GetClient().GetTable <ToDoWithIntId>(); List <ToDoWithIntId> integerIdItems = new List <ToDoWithIntId>(); for (var i = 0; i < 10; i++) { ToDoWithIntId item = new ToDoWithIntId() { Name = i.ToString() }; await table.InsertAsync(item); integerIdItems.Add(item); } IMobileServiceTable <ToDoWithStringIdAgainstIntIdTable> stringIdTable = GetClient().GetTable <ToDoWithStringIdAgainstIntIdTable>(); IEnumerable <ToDoWithStringIdAgainstIntIdTable> results = await stringIdTable.Where(p => p.Id == integerIdItems[0].Id.ToString()).ToEnumerableAsync(); ToDoWithStringIdAgainstIntIdTable[] items = results.ToArray(); Assert.Single(items); Assert.Equal(integerIdItems[0].Id.ToString(), items[0].Id); Assert.Equal("0", items[0].Name); foreach (ToDoWithIntId integerIdItem in integerIdItems) { await table.DeleteAsync(integerIdItem); } }
public async Task OrderingReadAsyncWithStringIdAgainstIntegerIdTable() { await EnsureEmptyTableAsync <ToDoWithIntId>(); IMobileServiceTable <ToDoWithIntId> table = GetClient().GetTable <ToDoWithIntId>(); List <ToDoWithIntId> integerIdItems = new List <ToDoWithIntId>(); for (var i = 0; i < 10; i++) { ToDoWithIntId item = new ToDoWithIntId() { Name = i.ToString() }; await table.InsertAsync(item); integerIdItems.Add(item); } IMobileServiceTable <ToDoWithStringIdAgainstIntIdTable> stringIdTable = GetClient().GetTable <ToDoWithStringIdAgainstIntIdTable>(); IEnumerable <ToDoWithStringIdAgainstIntIdTable> results = await stringIdTable.OrderBy(p => p.Id).ToEnumerableAsync(); ToDoWithStringIdAgainstIntIdTable[] items = results.ToArray(); Assert.Equal(10, items.Count()); for (var i = 0; i < 8; i++) { Assert.Equal((int.Parse(items[i].Id) + 1).ToString(), items[i + 1].Id); } results = await stringIdTable.OrderByDescending(p => p.Id).ToEnumerableAsync(); items = results.ToArray(); Assert.Equal(10, items.Count()); for (var i = 8; i >= 0; i--) { Assert.Equal((int.Parse(items[i].Id) - 1).ToString(), items[i + 1].Id); } foreach (ToDoWithIntId integerIdItem in integerIdItems) { await table.DeleteAsync(integerIdItem); } }
public async Task ReadAsyncWithValidIntIdAgainstIntIdTable() { await EnsureEmptyTableAsync <ToDoWithIntId>(); IMobileServiceTable <ToDoWithIntId> table = GetClient().GetTable <ToDoWithIntId>(); ToDoWithIntId item = new ToDoWithIntId() { Name = "Hey" }; await table.InsertAsync(item); IEnumerable <ToDoWithIntId> results = await table.ReadAsync(); ToDoWithIntId[] items = results.ToArray(); Assert.Single(items); Assert.True(items[0].Id > 0); Assert.Equal("Hey", items[0].Name); await table.DeleteAsync(item); }
public async Task FilterReadAsyncWithEmptyStringIdAgainstIntegerIdTable() { await EnsureEmptyTableAsync <ToDoWithIntId>(); IMobileServiceTable <ToDoWithIntId> table = GetClient().GetTable <ToDoWithIntId>(); List <ToDoWithIntId> integerIdItems = new List <ToDoWithIntId>(); for (var i = 0; i < 10; i++) { ToDoWithIntId item = new ToDoWithIntId() { Name = i.ToString() }; await table.InsertAsync(item); integerIdItems.Add(item); } string[] testIdData = new string[] { "", " ", null }; IMobileServiceTable <ToDoWithStringIdAgainstIntIdTable> stringIdTable = GetClient().GetTable <ToDoWithStringIdAgainstIntIdTable>(); foreach (string testId in testIdData) { IEnumerable <ToDoWithStringIdAgainstIntIdTable> results = await stringIdTable.Where(p => p.Id == testId).ToEnumerableAsync(); ToDoWithStringIdAgainstIntIdTable[] items = results.ToArray(); Assert.Empty(items); } foreach (ToDoWithIntId integerIdItem in integerIdItems) { await table.DeleteAsync(integerIdItem); } }