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