本文整理汇总了C#中System.Net.Connection.GetLastApiInfo方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.GetLastApiInfo方法的具体用法?C# Connection.GetLastApiInfo怎么用?C# Connection.GetLastApiInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Connection
的用法示例。
在下文中一共展示了Connection.GetLastApiInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReturnsObjectIfNotNew
public async Task ReturnsObjectIfNotNew()
{
var apiInfo = new ApiInfo(
new Dictionary<string, Uri>
{
{
"next",
new Uri("https://api.github.com/repos/rails/rails/issues?page=4&per_page=5")
},
{
"last",
new Uri("https://api.github.com/repos/rails/rails/issues?page=131&per_page=5")
},
{
"first",
new Uri("https://api.github.com/repos/rails/rails/issues?page=1&per_page=5")
},
{
"prev",
new Uri("https://api.github.com/repos/rails/rails/issues?page=2&per_page=5")
}
},
new List<string>
{
"user",
},
new List<string>
{
"user",
"public_repo",
"repo",
"gist"
},
"5634b0b187fd2e91e3126a75006cc4fa",
new RateLimit(100, 75, 1372700873)
);
var httpClient = Substitute.For<IHttpClient>();
// We really only care about the ApiInfo property...
var expectedResponse = new Response(HttpStatusCode.OK, null, new Dictionary<string, string>(), "application/json")
{
ApiInfo = apiInfo
};
httpClient.Send(Arg.Any<IRequest>(), Arg.Any<CancellationToken>())
.Returns(Task.FromResult<IResponse>(expectedResponse));
var connection = new Connection(new ProductHeaderValue("OctokitTests"),
_exampleUri,
Substitute.For<ICredentialStore>(),
httpClient,
Substitute.For<IJsonSerializer>());
connection.Get<PullRequest>(new Uri("https://example.com"), TimeSpan.MaxValue);
var result = connection.GetLastApiInfo();
// No point checking all of the values as they are tested elsewhere
// Just provde that the ApiInfo is populated
Assert.Equal(4, result.Links.Count);
Assert.Equal(1, result.OauthScopes.Count);
Assert.Equal(4, result.AcceptedOauthScopes.Count);
Assert.Equal("5634b0b187fd2e91e3126a75006cc4fa", result.Etag);
Assert.Equal(100, result.RateLimit.Limit);
}
示例2: ReturnsNullIfNew
public async Task ReturnsNullIfNew()
{
var httpClient = Substitute.For<IHttpClient>();
var connection = new Connection(new ProductHeaderValue("OctokitTests"),
_exampleUri,
Substitute.For<ICredentialStore>(),
httpClient,
Substitute.For<IJsonSerializer>());
var result = connection.GetLastApiInfo();
Assert.Null(result);
}