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


C# ApiConnection.Get方法代码示例

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


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

示例1: EnsuresArgumentNotNull

 public async Task EnsuresArgumentNotNull()
 {
     var getUri = new Uri("anything", UriKind.Relative);
     var client = new ApiConnection(Substitute.For<IConnection>());
     await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get<object>(null));
     await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get<object>(getUri, new Dictionary<string, string>(), null));
 }
开发者ID:alexgyori,项目名称:octokit.net,代码行数:7,代码来源:ApiConnectionTests.cs

示例2: MakesGetRequestForItem

            public async Task MakesGetRequestForItem()
            {
                var getUri = new Uri("anything", UriKind.Relative);
                IApiResponse<object> response = new ApiResponse<object>(new Response());
                var connection = Substitute.For<IConnection>();
                connection.Get<object>(Args.Uri, null, null).Returns(Task.FromResult(response));
                var apiConnection = new ApiConnection(connection);

                var data = await apiConnection.Get<object>(getUri);

                Assert.Same(response.Body, data);
                connection.Received().GetResponse<object>(getUri);
            }
开发者ID:alexgyori,项目名称:octokit.net,代码行数:13,代码来源:ApiConnectionTests.cs

示例3: MakesGetRequestForItemWithAcceptsOverride

            public async Task MakesGetRequestForItemWithAcceptsOverride()
            {
                var getUri = new Uri("anything", UriKind.Relative);
                var accepts = "custom/accepts";
                IResponse<object> response = new ApiResponse<object> { BodyAsObject = new object() };
                var connection = Substitute.For<IConnection>();
                connection.GetAsync<object>(Args.Uri, null, Args.String).Returns(Task.FromResult(response));
                var apiConnection = new ApiConnection(connection);

                var data = await apiConnection.Get<object>(getUri, null, accepts);

                Assert.Same(response.BodyAsObject, data);
                connection.Received().GetAsync<object>(getUri, null, accepts);
            }
开发者ID:rajwilkhu,项目名称:octokit.net,代码行数:14,代码来源:ApiConnectionTests.cs

示例4: EnsuresArgumentNotNull

 public async Task EnsuresArgumentNotNull()
 {
     var client = new ApiConnection(Substitute.For<IConnection>());
     await AssertEx.Throws<ArgumentNullException>(async () => await client.Get<object>(null));
 }
开发者ID:ninjanye,项目名称:octokit.net,代码行数:5,代码来源:ApiConnectionTests.cs


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