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


C# ApiConnection.Put方法代码示例

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


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

示例1: MakesPutRequestWithSuppliedDataAndTwoFactorCode

            public async Task MakesPutRequestWithSuppliedDataAndTwoFactorCode()
            {
                var putUri = new Uri("anything", UriKind.Relative);
                var sentData = new object();
                IApiResponse<object> response = new ApiResponse<object>(new Response());
                var connection = Substitute.For<IConnection>();
                connection.Put<object>(Args.Uri, Args.Object, "two-factor").Returns(Task.FromResult(response));
                var apiConnection = new ApiConnection(connection);

                var data = await apiConnection.Put<object>(putUri, sentData, "two-factor");

                Assert.Same(data, response.Body);
                connection.Received().Put<object>(putUri, sentData, "two-factor");
            }
开发者ID:alexgyori,项目名称:octokit.net,代码行数:14,代码来源:ApiConnectionTests.cs

示例2: EnsuresArgumentsNotNull

            public async Task EnsuresArgumentsNotNull()
            {
                var putUri = new Uri("", UriKind.Relative);
                var connection = new ApiConnection(Substitute.For<IConnection>());

                // 2 parameter overload
                await Assert.ThrowsAsync<ArgumentNullException>(async () =>
                    await connection.Put<object>(null, new object()));
                await Assert.ThrowsAsync<ArgumentNullException>(async () =>
                    await connection.Put<object>(putUri, null));

                // 3 parameters
                await Assert.ThrowsAsync<ArgumentNullException>(async () =>
                    await connection.Put<object>(null, new MemoryStream(), "two-factor"));
                await Assert.ThrowsAsync<ArgumentNullException>(async () =>
                    await connection.Put<object>(putUri, null, "two-factor"));
                await Assert.ThrowsAsync<ArgumentNullException>(async () =>
                    await connection.Put<object>(putUri, new MemoryStream(), null));
                await Assert.ThrowsAsync<ArgumentException>(async () =>
                    await connection.Put<object>(putUri, new MemoryStream(), ""));
            }
开发者ID:alexgyori,项目名称:octokit.net,代码行数:21,代码来源:ApiConnectionTests.cs

示例3: MakesPutRequestWithSuppliedData

            public async Task MakesPutRequestWithSuppliedData()
            {
                var putUri = new Uri("anything", UriKind.Relative);
                var sentData = new object();
                IResponse<object> response = new ApiResponse<object> { BodyAsObject = new object() };
                var connection = Substitute.For<IConnection>();
                connection.PutAsync<object>(Args.Uri, Args.Object).Returns(Task.FromResult(response));
                var apiConnection = new ApiConnection(connection);

                var data = await apiConnection.Put<object>(putUri, sentData);

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


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