本文整理汇总了C#中ApiConnection.Patch方法的典型用法代码示例。如果您正苦于以下问题:C# ApiConnection.Patch方法的具体用法?C# ApiConnection.Patch怎么用?C# ApiConnection.Patch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiConnection
的用法示例。
在下文中一共展示了ApiConnection.Patch方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakesPatchRequestWithAcceptsOverride
public async Task MakesPatchRequestWithAcceptsOverride()
{
var patchUri = new Uri("anything", UriKind.Relative);
var sentData = new object();
var accepts = "custom/accepts";
IApiResponse<object> response = new ApiResponse<object>(new Response());
var connection = Substitute.For<IConnection>();
connection.Patch<object>(Args.Uri, Args.Object, Args.String).Returns(Task.FromResult(response));
var apiConnection = new ApiConnection(connection);
var data = await apiConnection.Patch<object>(patchUri, sentData, accepts);
Assert.Same(data, response.Body);
connection.Received().Patch<object>(patchUri, sentData, accepts);
}
示例2: EnsuresArgumentNotNull
public async Task EnsuresArgumentNotNull()
{
var connection = new ApiConnection(Substitute.For<IConnection>());
var patchUri = new Uri("", UriKind.Relative);
await Assert.ThrowsAsync<ArgumentNullException>(() => connection.Patch<object>(null, new object()));
await Assert.ThrowsAsync<ArgumentNullException>(() => connection.Patch<object>(patchUri, null));
await Assert.ThrowsAsync<ArgumentNullException>(() => connection.Patch<object>(patchUri, new object(), null));
}
示例3: MakesPatchRequestWithSuppliedData
public async Task MakesPatchRequestWithSuppliedData()
{
var patchUri = new Uri("anything", UriKind.Relative);
var sentData = new object();
IResponse<object> response = new ApiResponse<object> {BodyAsObject = new object()};
var connection = Substitute.For<IConnection>();
connection.PatchAsync<object>(Args.Uri, Args.Object).Returns(Task.FromResult(response));
var apiConnection = new ApiConnection(connection);
var data = await apiConnection.Patch<object>(patchUri, sentData);
Assert.Same(data, response.BodyAsObject);
connection.Received().PatchAsync<object>(patchUri, sentData);
}