本文整理汇总了C#中Microsoft.WindowsAzure.MobileServices.Test.StringIdType类的典型用法代码示例。如果您正苦于以下问题:C# StringIdType类的具体用法?C# StringIdType怎么用?C# StringIdType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringIdType类属于Microsoft.WindowsAzure.MobileServices.Test命名空间,在下文中一共展示了StringIdType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RefreshAsync_Succeeds_WhenIdIsNull
public async Task RefreshAsync_Succeeds_WhenIdIsNull()
{
IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...");
await service.SyncContext.InitializeAsync(new MobileServiceLocalStoreMock(), new MobileServiceSyncHandler());
IMobileServiceSyncTable<StringIdType> table = service.GetSyncTable<StringIdType>();
var item = new StringIdType() { String = "what?" };
await table.RefreshAsync(item);
}
示例2: RefreshAsync_Succeeds_WhenIdIsNull
public async Task RefreshAsync_Succeeds_WhenIdIsNull()
{
IMobileServiceClient service = new MobileServiceClient(MobileAppUriValidator.DummyMobileApp);
await service.SyncContext.InitializeAsync(new MobileServiceLocalStoreMock(), new MobileServiceSyncHandler());
IMobileServiceSyncTable<StringIdType> table = service.GetSyncTable<StringIdType>();
var item = new StringIdType() { String = "what?" };
await table.RefreshAsync(item);
}
开发者ID:brettsam,项目名称:azure-mobile-apps-net-client,代码行数:10,代码来源:MobileServiceSyncTable.Generic.Test.cs
示例3: RefreshAsync_ThrowsInvalidOperationException_WhenIdItemDoesNotExist
public async Task RefreshAsync_ThrowsInvalidOperationException_WhenIdItemDoesNotExist()
{
IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...");
await service.SyncContext.InitializeAsync(new MobileServiceLocalStoreMock(), new MobileServiceSyncHandler());
IMobileServiceSyncTable<StringIdType> table = service.GetSyncTable<StringIdType>();
var item = new StringIdType() { Id = "abc" };
InvalidOperationException ex = await ThrowsAsync<InvalidOperationException>(() => table.RefreshAsync(item));
Assert.AreEqual(ex.Message, "Item not found in local store.");
}
示例4: RefreshAsync_UpdatesItem_WhenItExistsInStore
public async Task RefreshAsync_UpdatesItem_WhenItExistsInStore()
{
IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...");
await service.SyncContext.InitializeAsync(new MobileServiceLocalStoreMock(), new MobileServiceSyncHandler());
IMobileServiceSyncTable<StringIdType> table = service.GetSyncTable<StringIdType>();
// add item to store
var item = new StringIdType() { String = "what?" };
await table.InsertAsync(item);
Assert.IsNotNull(item.Id, "Id must be generated");
// update it in store
item.String = "nothing!";
await table.UpdateAsync(item);
// read it back into new object
var refreshed = new StringIdType() { Id = item.Id };
await table.RefreshAsync(refreshed);
Assert.AreEqual(refreshed.String, "nothing!");
}
示例5: PushAsync_ExecutesThePendingOperations
public async Task PushAsync_ExecutesThePendingOperations()
{
var hijack = new TestHttpHandler();
var store = new MobileServiceLocalStoreMock();
hijack.SetResponseContent("{\"id\":\"abc\",\"String\":\"Hey\"}");
IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);
await service.SyncContext.InitializeAsync(store, new MobileServiceSyncHandler());
IMobileServiceSyncTable<StringIdType> table = service.GetSyncTable<StringIdType>();
var item = new StringIdType() { Id = "an id", String = "what?" };
await table.InsertAsync(item);
Assert.AreEqual(store.TableMap[table.TableName].Count, 1);
await service.SyncContext.PushAsync();
}
示例6: DeleteAsyncWithStringIdTypeAndInvalidStringIdParameter
public async Task DeleteAsyncWithStringIdTypeAndInvalidStringIdParameter()
{
string[] testIdData = IdTestData.InvalidStringIds;
foreach (string testId in testIdData)
{
TestHttpHandler hijack = new TestHttpHandler();
hijack.SetResponseContent("{\"id\":\"" + testId + "\",\"String\":\"Hey\"}");
IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);
IMobileServiceTable<StringIdType> table = service.GetTable<StringIdType>();
Exception exception = null;
try
{
StringIdType item = new StringIdType() { Id = testId, String = "what?" };
await table.DeleteAsync(item);
}
catch (Exception e)
{
exception = e;
}
Assert.IsNotNull(exception);
Assert.IsTrue(exception.Message.Contains("An id must not contain any control characters or the characters") ||
exception.Message.Contains("is longer than the max string id length of 255 characters"));
}
}
示例7: FeatureHeaderValidation_TypedTableViaQueryToCollection
public Task FeatureHeaderValidation_TypedTableViaQueryToCollection()
{
var obj = new StringIdType { Id = "the id", String = "hey" };
return this.ValidateFeaturesHeader("TT,TC", true, t => t.Where(a => a.String != null).ToCollectionAsync());
}
示例8: FeatureHeaderValidation_TypedTableDelete
public Task FeatureHeaderValidation_TypedTableDelete()
{
var obj = new StringIdType { Id = "the id", String = "hey" };
return this.ValidateFeaturesHeader("TT", false, t => t.DeleteAsync(obj));
}
示例9: TestCollapseThrow
/// <summary>
/// Tests that the second operation on the same item will throw if first operation is in the queue
/// </summary>
/// <param name="firstOperation">The operation that was already in queue.</param>
/// <param name="secondOperation">The operation that came in late but could not be collapsed.</param>
/// <returns></returns>
private async Task TestCollapseThrow(Func<IMobileServiceSyncTable<StringIdType>, StringIdType, Task> firstOperation, Func<IMobileServiceSyncTable<StringIdType>, StringIdType, Task> secondOperation)
{
IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...");
await service.SyncContext.InitializeAsync(new MobileServiceLocalStoreMock(), new MobileServiceSyncHandler());
IMobileServiceSyncTable<StringIdType> table = service.GetSyncTable<StringIdType>();
var item = new StringIdType() { Id = "an id", String = "what?" };
await firstOperation(table, item);
Assert.AreEqual(service.SyncContext.PendingOperations, 1L);
await ThrowsAsync<InvalidOperationException>(() => secondOperation(table, item));
Assert.AreEqual(service.SyncContext.PendingOperations, 1L);
}
示例10: Collapse_DeletesTheError_OnReplace
public async Task Collapse_DeletesTheError_OnReplace()
{
var store = new MobileServiceLocalStoreMock();
var hijack = new TestHttpHandler();
MobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);
var item = new StringIdType() { Id = "item1", String = "what?" };
await service.SyncContext.InitializeAsync(store, new MobileServiceSyncHandler());
IMobileServiceSyncTable<StringIdType> table = service.GetSyncTable<StringIdType>();
await table.InsertAsync(item);
Assert.AreEqual(service.SyncContext.PendingOperations, 1L);
string id = store.TableMap[MobileServiceLocalSystemTables.OperationQueue].Values.First().Value<string>("id");
// inject an error to test if it is deleted on collapse
store.TableMap[MobileServiceLocalSystemTables.SyncErrors] = new Dictionary<string, JObject>() { { id, new JObject() } };
await table.UpdateAsync(item);
Assert.AreEqual(service.SyncContext.PendingOperations, 1L);
// error should be deleted
Assert.AreEqual(store.TableMap[MobileServiceLocalSystemTables.SyncErrors].Count, 0);
}
示例11: DeleteAsync_CancelsAll_WhenInsertIsInQueue
public async Task DeleteAsync_CancelsAll_WhenInsertIsInQueue()
{
var hijack = new TestHttpHandler();
hijack.SetResponseContent("[{\"id\":\"abc\",\"String\":\"Hey\"}]");
hijack.OnSendingRequest = req =>
{
Assert.Fail("No request should be made.");
return Task.FromResult(req);
};
IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);
await service.SyncContext.InitializeAsync(new MobileServiceLocalStoreMock(), new MobileServiceSyncHandler());
IMobileServiceSyncTable<StringIdType> table = service.GetSyncTable<StringIdType>();
var item = new StringIdType() { Id = "an id", String = "what?" };
await table.InsertAsync(item);
Assert.AreEqual(service.SyncContext.PendingOperations, 1L);
await table.DeleteAsync(item);
await service.SyncContext.PushAsync();
Assert.AreEqual(service.SyncContext.PendingOperations, 0L);
}
示例12: UpdateAsyncWithStringIdTypeAndNonStringIdResponseContent
public async Task UpdateAsyncWithStringIdTypeAndNonStringIdResponseContent()
{
object[] testIdData = IdTestData.ValidIntIds.Concat(
IdTestData.InvalidIntIds).Cast<object>().Concat(
IdTestData.NonStringNonIntValidJsonIds).ToArray();
foreach (object testId in testIdData)
{
string stringTestId = testId.ToString().ToLower();
TestHttpHandler hijack = new TestHttpHandler();
hijack.SetResponseContent("{\"id\":" + stringTestId.ToLower() + ",\"String\":\"Hey\"}");
IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);
IMobileServiceTable<StringIdType> table = service.GetTable<StringIdType>();
StringIdType item = new StringIdType() { Id = "an id", String = "what?" };
await table.UpdateAsync(item);
Assert.AreEqual(testId.ToString(), item.Id);
Assert.AreEqual("Hey", item.String);
}
}
示例13: UpdateAsyncWithStringIdTypeAndStringIdResponseContent
public async Task UpdateAsyncWithStringIdTypeAndStringIdResponseContent()
{
string[] testIdData = IdTestData.ValidStringIds.Concat(
IdTestData.EmptyStringIds).Concat(
IdTestData.InvalidStringIds).ToArray();
foreach (string testId in testIdData)
{
TestHttpHandler hijack = new TestHttpHandler();
// Make the testId JSON safe
string jsonTestId = testId.Replace("\\", "\\\\").Replace("\"", "\\\"");
hijack.SetResponseContent("{\"id\":\"" + jsonTestId + "\",\"String\":\"Hey\"}");
IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);
IMobileServiceTable<StringIdType> table = service.GetTable<StringIdType>();
StringIdType item = new StringIdType() { Id = "an id", String = "what?" };
await table.UpdateAsync(item);
Assert.AreEqual(testId, item.Id);
Assert.AreEqual("Hey", item.String);
}
}
示例14: InsertAsyncWithStringIdTypeAndNullIdItem
public async Task InsertAsyncWithStringIdTypeAndNullIdItem()
{
TestHttpHandler hijack = new TestHttpHandler();
hijack.SetResponseContent("{\"id\":\"an id\",\"String\":\"Hey\"}");
IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);
IMobileServiceTable<StringIdType> table = service.GetTable<StringIdType>();
hijack.OnSendingRequest = async request =>
{
string requestContent = await request.Content.ReadAsStringAsync();
JObject itemAsJObject = JObject.Parse(requestContent);
Assert.AreEqual(null, (string)itemAsJObject["id"]);
Assert.AreEqual("what?", (string)itemAsJObject["String"]);
return request;
};
StringIdType item = new StringIdType() { Id = null, String = "what?" };
await table.InsertAsync(item);
Assert.AreEqual("an id", item.Id);
Assert.AreEqual("Hey", item.String);
}
示例15: RefreshAsyncWithStringIdTypeAndNullIdParameter
public async Task RefreshAsyncWithStringIdTypeAndNullIdParameter()
{
TestHttpHandler hijack = new TestHttpHandler();
IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);
IMobileServiceTable<StringIdType> table = service.GetTable<StringIdType>();
StringIdType item = new StringIdType() { String = "Hey" };
await table.RefreshAsync(item);
Assert.AreEqual(null, item.Id);
Assert.AreEqual("Hey", item.String);
}