当前位置: 首页>>代码示例>>C#>>正文


C# ApiConnection.GetQueuedOperation方法代码示例

本文整理汇总了C#中ApiConnection.GetQueuedOperation方法的典型用法代码示例。如果您正苦于以下问题:C# ApiConnection.GetQueuedOperation方法的具体用法?C# ApiConnection.GetQueuedOperation怎么用?C# ApiConnection.GetQueuedOperation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ApiConnection的用法示例。


在下文中一共展示了ApiConnection.GetQueuedOperation方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EnsuresArgumentNotNull

 public async Task EnsuresArgumentNotNull()
 {
     var connection = new ApiConnection(Substitute.For<IConnection>());
     await Assert.ThrowsAsync<ArgumentNullException>(() => connection.GetQueuedOperation<object>(null, CancellationToken.None));
 }
开发者ID:alexgyori,项目名称:octokit.net,代码行数:5,代码来源:ApiConnectionTests.cs

示例2: GetIsRepeatedUntilHttpStatusCodeOkIsReturned

            public async Task GetIsRepeatedUntilHttpStatusCodeOkIsReturned()
            {
                var queuedOperationUrl = new Uri("anything", UriKind.Relative);

                var result = new object();
                IApiResponse<object> firstResponse = new ApiResponse<object>(new Response(HttpStatusCode.Accepted, null, new Dictionary<string, string>(), "application/json"), result);
                IApiResponse<object> completedResponse = new ApiResponse<object>(new Response(HttpStatusCode.OK, null, new Dictionary<string, string>(), "application/json"), result);
                var connection = Substitute.For<IConnection>();
                connection.GetResponse<object>(queuedOperationUrl, Args.CancellationToken)
                          .Returns(x => Task.FromResult(firstResponse),
                          x => Task.FromResult(firstResponse), 
                          x => Task.FromResult(completedResponse));

                var apiConnection = new ApiConnection(connection);

                await apiConnection.GetQueuedOperation<object>(queuedOperationUrl, CancellationToken.None);

                connection.Received(3).GetResponse<object>(queuedOperationUrl, Args.CancellationToken);
            }
开发者ID:alexgyori,项目名称:octokit.net,代码行数:19,代码来源:ApiConnectionTests.cs

示例3: CanCancelQueuedOperation

            public async Task CanCancelQueuedOperation()
            {
                var queuedOperationUrl = new Uri("anything", UriKind.Relative);

                var result = new object();
                IApiResponse<object> accepted = new ApiResponse<object>(new Response(HttpStatusCode.Accepted, null, new Dictionary<string, string>(), "application/json"), result);
                var connection = Substitute.For<IConnection>();
                connection.GetResponse<object>(queuedOperationUrl, Args.CancellationToken).Returns(x => Task.FromResult(accepted));

                var apiConnection = new ApiConnection(connection);

                var cancellationTokenSource = new CancellationTokenSource();
                cancellationTokenSource.CancelAfter(100);
                var canceled = false;

                var operationResult = await apiConnection.GetQueuedOperation<object>(queuedOperationUrl, cancellationTokenSource.Token)
                    .ContinueWith(task =>
                    {
                        canceled = task.IsCanceled;
                        return task;
                    }, TaskContinuationOptions.OnlyOnCanceled)
                    .ContinueWith(task => task, TaskContinuationOptions.OnlyOnFaulted);

                Assert.True(canceled);
                Assert.Null(operationResult);
            }
开发者ID:alexgyori,项目名称:octokit.net,代码行数:26,代码来源:ApiConnectionTests.cs

示例4: WhenGetReturnsNotOkOrAcceptedApiExceptionIsThrown

            public async Task WhenGetReturnsNotOkOrAcceptedApiExceptionIsThrown()
            {
                var queuedOperationUrl = new Uri("anything", UriKind.Relative);

                const HttpStatusCode statusCode = HttpStatusCode.PartialContent;
                IApiResponse<object> response = new ApiResponse<object>(new Response(statusCode, null, new Dictionary<string, string>(), "application/json"), new object());
                var connection = Substitute.For<IConnection>();
                connection.GetResponse<object>(queuedOperationUrl, Args.CancellationToken).Returns(Task.FromResult(response));
                var apiConnection = new ApiConnection(connection);

                await Assert.ThrowsAsync<ApiException>(() => apiConnection.GetQueuedOperation<object>(queuedOperationUrl, Args.CancellationToken));
            }
开发者ID:alexgyori,项目名称:octokit.net,代码行数:12,代码来源:ApiConnectionTests.cs

示例5: WhenGetReturnsOkThenBodyAsObjectIsReturned

            public async Task WhenGetReturnsOkThenBodyAsObjectIsReturned()
            {
                var queuedOperationUrl = new Uri("anything", UriKind.Relative);

                var result = new object();
                const HttpStatusCode statusCode = HttpStatusCode.OK;
                IApiResponse<object> response = new ApiResponse<object>(new Response(statusCode, null, new Dictionary<string, string>(), "application/json"), result);
                var connection = Substitute.For<IConnection>();
                connection.GetResponse<object>(queuedOperationUrl, Args.CancellationToken).Returns(Task.FromResult(response));
                var apiConnection = new ApiConnection(connection);

                var actualResult = await apiConnection.GetQueuedOperation<object>(queuedOperationUrl, Args.CancellationToken);
                Assert.Same(actualResult,result);
            }
开发者ID:alexgyori,项目名称:octokit.net,代码行数:14,代码来源:ApiConnectionTests.cs

示例6: MakesGetRequest

            public async Task MakesGetRequest()
            {
                var queuedOperationUrl = new Uri("anything", UriKind.Relative);

                const HttpStatusCode statusCode = HttpStatusCode.OK;
                IApiResponse<object> response = new ApiResponse<object>(new Response(statusCode, null, new Dictionary<string, string>(), "application/json"), new object());
                var connection = Substitute.For<IConnection>();
                connection.GetResponse<object>(queuedOperationUrl,Args.CancellationToken).Returns(Task.FromResult(response));
                var apiConnection = new ApiConnection(connection);

                await apiConnection.GetQueuedOperation<object>(queuedOperationUrl,CancellationToken.None);

                connection.Received().GetResponse<object>(queuedOperationUrl, Args.CancellationToken);
            }
开发者ID:alexgyori,项目名称:octokit.net,代码行数:14,代码来源:ApiConnectionTests.cs

示例7: GetIsRepeatedUntilHttpStatusCodeOkIsReturned

            public async Task GetIsRepeatedUntilHttpStatusCodeOkIsReturned()
            {
                var queuedOperationUrl = new Uri("anything", UriKind.Relative);

                var result = new object();
                IResponse<object> firstResponse = new ApiResponse<object> { BodyAsObject = result, StatusCode = HttpStatusCode.Accepted };
                IResponse<object> completedResponse = new ApiResponse<object> { BodyAsObject = result, StatusCode = HttpStatusCode.OK };
                var connection = Substitute.For<IConnection>();
                connection.GetAsync<object>(queuedOperationUrl, Args.CancellationToken)
                          .Returns(x => Task.FromResult(firstResponse),
                          x => Task.FromResult(firstResponse), 
                          x => Task.FromResult(completedResponse));

                var apiConnection = new ApiConnection(connection);

                await apiConnection.GetQueuedOperation<object>(queuedOperationUrl, CancellationToken.None);

                connection.Received(3).GetAsync<object>(queuedOperationUrl, Args.CancellationToken);
            }
开发者ID:rajwilkhu,项目名称:octokit.net,代码行数:19,代码来源:ApiConnectionTests.cs

示例8: WhenGetReturnsNotOkOrAcceptedApiExceptionIsThrown

            public async Task WhenGetReturnsNotOkOrAcceptedApiExceptionIsThrown()
            {
                var queuedOperationUrl = new Uri("anything", UriKind.Relative);

                const HttpStatusCode statusCode = HttpStatusCode.PartialContent;
                IResponse<object> response = new ApiResponse<object> { BodyAsObject = new object(), StatusCode = statusCode };
                var connection = Substitute.For<IConnection>();
                connection.GetAsync<object>(queuedOperationUrl, Args.CancellationToken).Returns(Task.FromResult(response));
                var apiConnection = new ApiConnection(connection);

                await AssertEx.Throws<ApiException>(async () => await apiConnection.GetQueuedOperation<object>(queuedOperationUrl, Args.CancellationToken));
            }
开发者ID:rajwilkhu,项目名称:octokit.net,代码行数:12,代码来源:ApiConnectionTests.cs

示例9: MakesGetRequest

            public async Task MakesGetRequest()
            {
                var queuedOperationUrl = new Uri("anything", UriKind.Relative);

                const HttpStatusCode statusCode = HttpStatusCode.OK;
                IResponse<object> response = new ApiResponse<object> { BodyAsObject = new object(), StatusCode = statusCode };
                var connection = Substitute.For<IConnection>();
                connection.GetAsync<object>(queuedOperationUrl,Args.CancellationToken).Returns(Task.FromResult(response));
                var apiConnection = new ApiConnection(connection);

                await apiConnection.GetQueuedOperation<object>(queuedOperationUrl,CancellationToken.None);

                connection.Received().GetAsync<object>(queuedOperationUrl, Args.CancellationToken);
            }
开发者ID:rajwilkhu,项目名称:octokit.net,代码行数:14,代码来源:ApiConnectionTests.cs

示例10: WhenGetReturnsNoContentThenReturnsEmptyCollection

            public async Task WhenGetReturnsNoContentThenReturnsEmptyCollection()
            {
                var queuedOperationUrl = new Uri("anything", UriKind.Relative);

                var result = new[] { new object() };
                const HttpStatusCode statusCode = HttpStatusCode.NoContent;
                var httpResponse = new Response(statusCode, null, new Dictionary<string, string>(), "application/json");
                IApiResponse<IReadOnlyList<object>> response = new ApiResponse<IReadOnlyList<object>>(
                    httpResponse, result);
                var connection = Substitute.For<IConnection>();
                connection.GetResponse<IReadOnlyList<object>>(queuedOperationUrl, Args.CancellationToken)
                    .Returns(Task.FromResult(response));
                var apiConnection = new ApiConnection(connection);

                var actualResult = await apiConnection.GetQueuedOperation<object>(queuedOperationUrl, Args.CancellationToken);
                Assert.Empty(actualResult);
            }
开发者ID:RadicalLove,项目名称:octokit.net,代码行数:17,代码来源:ApiConnectionTests.cs


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