本文整理汇总了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));
}
示例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);
}
示例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);
}
示例4: EnsuresArgumentNotNull
public async Task EnsuresArgumentNotNull()
{
var client = new ApiConnection(Substitute.For<IConnection>());
await AssertEx.Throws<ArgumentNullException>(async () => await client.Get<object>(null));
}