• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Test.StringIdType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.WindowsAzure.MobileServices.Test.StringIdType的典型用法代码示例。如果您正苦于以下问题:C# StringIdType类的具体用法?C# StringIdType怎么用?C# StringIdType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StringIdType类属于Microsoft.WindowsAzure.MobileServices.Test命名空间,在下文中一共展示了StringIdType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
        }
开发者ID:angusbreno,项目名称:azure-mobile-services,代码行数:10,代码来源:MobileServiceSyncTable.Generic.Test.cs


示例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.");
        }
开发者ID:angusbreno,项目名称:azure-mobile-services,代码行数:11,代码来源:MobileServiceSyncTable.Generic.Test.cs


示例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!");
        }
开发者ID:angusbreno,项目名称:azure-mobile-services,代码行数:23,代码来源:MobileServiceSyncTable.Generic.Test.cs


示例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();
        }
开发者ID:angusbreno,项目名称:azure-mobile-services,代码行数:17,代码来源:MobileServiceSyncTable.Generic.Test.cs


示例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"));
            }
        }
开发者ID:rfaisal,项目名称:azure-mobile-services,代码行数:27,代码来源:MobileServiceTable.Generic.Test.cs


示例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());
 }
开发者ID:brettsam,项目名称:azure-mobile-apps-net-client,代码行数:5,代码来源:MobileServiceTable.Generic.Test.cs


示例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));
 }
开发者ID:brettsam,项目名称:azure-mobile-apps-net-client,代码行数:5,代码来源:MobileServiceTable.Generic.Test.cs


示例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);
        }
开发者ID:angusbreno,项目名称:azure-mobile-services,代码行数:20,代码来源:MobileServiceSyncTable.Generic.Test.cs


示例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);
        }
开发者ID:angusbreno,项目名称:azure-mobile-services,代码行数:25,代码来源:MobileServiceSyncTable.Generic.Test.cs


示例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);
        }
开发者ID:angusbreno,项目名称:azure-mobile-services,代码行数:23,代码来源:MobileServiceSyncTable.Generic.Test.cs


示例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);
            }
        }
开发者ID:rfaisal,项目名称:azure-mobile-services,代码行数:24,代码来源:MobileServiceTable.Generic.Test.cs


示例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);
            }
        }
开发者ID:rfaisal,项目名称:azure-mobile-services,代码行数:25,代码来源:MobileServiceTable.Generic.Test.cs


示例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);
        }
开发者ID:rfaisal,项目名称:azure-mobile-services,代码行数:23,代码来源:MobileServiceTable.Generic.Test.cs


示例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);
        }
开发者ID:rfaisal,项目名称:azure-mobile-services,代码行数:13,代码来源:MobileServiceTable.Generic.Test.cs


示例16: RefreshAsyncWithStringIdTypeAndEmptyStringIdItem

        public async Task RefreshAsyncWithStringIdTypeAndEmptyStringIdItem()
        {
            string[] testIdData = IdTestData.EmptyStringIds;

            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>();

                StringIdType item = new StringIdType() { Id = testId, String = "what?" };
                await table.RefreshAsync(item);

                Assert.AreEqual(testId, item.Id);
                Assert.AreEqual("what?", item.String);
            }
        }
开发者ID:rfaisal,项目名称:azure-mobile-services,代码行数:19,代码来源:MobileServiceTable.Generic.Test.cs


示例17: RefreshAsyncWithStringIdTypeAndStringIdItem

        public async Task RefreshAsyncWithStringIdTypeAndStringIdItem()
        {
            string[] testIdData = IdTestData.ValidStringIds.ToArray();

            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>();

                StringIdType item = new StringIdType() { Id = testId, String = "what?" };
                await table.RefreshAsync(item);
                
                string idForOdataQuery = Uri.EscapeDataString(testId.Replace("'", "''"));
                Uri expectedUri = new Uri(string.Format("http://www.test.com/tables/StringIdType?$filter=(id eq '{0}')", idForOdataQuery));

                Assert.AreEqual(testId, item.Id);
                Assert.AreEqual("Hey", item.String);
                Assert.AreEqual(hijack.Request.RequestUri.AbsoluteUri, expectedUri.AbsoluteUri);
            }
        }
开发者ID:rfaisal,项目名称:azure-mobile-services,代码行数:23,代码来源:MobileServiceTable.Generic.Test.cs


示例18: DeleteAsync_DoesNotUpsertResultOnStore_WhenOperationIsPushed

        public async Task DeleteAsync_DoesNotUpsertResultOnStore_WhenOperationIsPushed()
        {
            var storeMock = new MobileServiceLocalStoreMock();

            var hijack = new TestHttpHandler();
            hijack.AddResponseContent("{\"id\":\"abc\",\"String\":\"Hey\"}"); // for insert
            hijack.AddResponseContent("{\"id\":\"abc\",\"String\":\"Hey\"}"); // for delete
            IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);

            await service.SyncContext.InitializeAsync(storeMock, new MobileServiceSyncHandler());

            IMobileServiceSyncTable<StringIdType> table = service.GetSyncTable<StringIdType>();

            // first add an item
            var item = new StringIdType() { Id = "abc", String = "what?" };
            await table.InsertAsync(item);

            Assert.AreEqual(storeMock.TableMap[table.TableName].Count, 1);

            // for good measure also push it
            await service.SyncContext.PushAsync();

            await table.DeleteAsync(item);

            Assert.AreEqual(storeMock.TableMap[table.TableName].Count, 0);

            // now play it on server
            await service.SyncContext.PushAsync();

            // wait we don't want to upsert the result back because its delete operation
            Assert.AreEqual(storeMock.TableMap[table.TableName].Count, 0);
            // looks good
        }
开发者ID:angusbreno,项目名称:azure-mobile-services,代码行数:33,代码来源:MobileServiceSyncTable.Generic.Test.cs


示例19: DeleteAsync_Throws_WhenInsertWasAttempted

        public async Task DeleteAsync_Throws_WhenInsertWasAttempted()
        {
            var hijack = new TestHttpHandler();
            hijack.Response = new HttpResponseMessage(HttpStatusCode.RequestTimeout); // insert response
            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);
            // insert is in queue
            Assert.AreEqual(service.SyncContext.PendingOperations, 1L);

            var pushException = await ThrowsAsync<MobileServicePushFailedException>(service.SyncContext.PushAsync);
            Assert.AreEqual(pushException.PushResult.Errors.Count(), 1);

            var delException = await ThrowsAsync<InvalidOperationException>(() => table.DeleteAsync(item));
            Assert.AreEqual(delException.Message, "The item is in inconsistent state in the local store. Please complete the pending sync by calling PushAsync() before deleting the item.");

            // insert still in queue
            Assert.AreEqual(service.SyncContext.PendingOperations, 1L);
        }
开发者ID:angusbreno,项目名称:azure-mobile-services,代码行数:22,代码来源:MobileServiceSyncTable.Generic.Test.cs


示例20: UpdateAsyncWithStringIdTypeAndNoIdResponseContent

        public async Task UpdateAsyncWithStringIdTypeAndNoIdResponseContent()
        {
            TestHttpHandler hijack = new TestHttpHandler();
            hijack.SetResponseContent("{\"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("an id", item.Id);
            Assert.AreEqual("Hey", item.String);
        }
开发者ID:rfaisal,项目名称:azure-mobile-services,代码行数:14,代码来源:MobileServiceTable.Generic.Test.cs



注:本文中的Microsoft.WindowsAzure.MobileServices.Test.StringIdType类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Test.TestHttpHandler类代码示例发布时间:2022-05-26
下一篇:
C# Test.MobileServiceLocalStoreMock类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap