本文整理汇总了C#中Octokit.Reactive.ObservableRepositoriesClient类的典型用法代码示例。如果您正苦于以下问题:C# ObservableRepositoriesClient类的具体用法?C# ObservableRepositoriesClient怎么用?C# ObservableRepositoriesClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObservableRepositoriesClient类属于Octokit.Reactive命名空间,在下文中一共展示了ObservableRepositoriesClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RequestsCorrectUrlWithRepositoryId
public async Task RequestsCorrectUrlWithRepositoryId()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableRepositoriesClient(gitHubClient);
await client.Get(1);
gitHubClient.Repository.Get(1);
}
示例2: RequestsCorrectUrl
public async Task RequestsCorrectUrl()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableRepositoriesClient(gitHubClient);
await client.Get("owner", "name");
gitHubClient.Received().Repository.Get("owner", "name");
}
示例3: EnsuresNonNullArguments
public async Task EnsuresNonNullArguments()
{
var client = new ObservableRepositoriesClient(Substitute.For<IGitHubClient>());
Assert.Throws<ArgumentNullException>(() => client.Delete(null, "name"));
Assert.Throws<ArgumentNullException>(() => client.Delete("owner", null));
Assert.Throws<ArgumentException>(() => client.Delete("", "name"));
Assert.Throws<ArgumentException>(() => client.Delete("owner", ""));
}
示例4: ReturnsAllPublicReposSinceLastSeen
public async Task ReturnsAllPublicReposSinceLastSeen()
{
var github = Helper.GetAuthenticatedClient();
var client = new ObservableRepositoriesClient(github);
var request = new PublicRepositoryRequest(32732250L);
var repositories = await client.GetAllPublic(request).ToArray();
Assert.NotEmpty(repositories);
Assert.Equal(32732252, repositories[0].Id);
Assert.False(repositories[0].Private);
Assert.Equal("zad19", repositories[0].Name);
}
示例5: ObservableGitHubClient
public ObservableGitHubClient(IGitHubClient gitHubClient)
{
Ensure.ArgumentNotNull(gitHubClient, "githubClient");
_gitHubClient = gitHubClient;
Authorization = new ObservableAuthorizationsClient(gitHubClient);
Miscellaneous = new ObservableMiscellaneousClient(gitHubClient.Miscellaneous);
Notification = new ObservableNotificationsClient(gitHubClient);
Organization = new ObservableOrganizationsClient(gitHubClient);
Repository = new ObservableRepositoriesClient(gitHubClient);
SshKey = new ObservableSshKeysClient(gitHubClient);
User = new ObservableUsersClient(gitHubClient);
Release = new ObservableReleasesClient(gitHubClient);
}
示例6: ReturnsSpecifiedRepository
public async Task ReturnsSpecifiedRepository()
{
var github = Helper.GetAuthenticatedClient();
var client = new ObservableRepositoriesClient(github);
var observable = client.Get("haacked", "seegit");
var repository = await observable;
var repository2 = await observable;
Assert.Equal("https://github.com/Haacked/SeeGit.git", repository.CloneUrl);
Assert.False(repository.Private);
Assert.False(repository.Fork);
Assert.Equal("https://github.com/Haacked/SeeGit.git", repository2.CloneUrl);
Assert.False(repository2.Private);
Assert.False(repository2.Fork);
}
示例7: ReturnsEveryPageOfRepositories
public async Task ReturnsEveryPageOfRepositories()
{
var firstPageUrl = new Uri("user/repos", UriKind.Relative);
var secondPageUrl = new Uri("https://example.com/page/2");
var firstPageLinks = new Dictionary<string, Uri> { { "next", secondPageUrl } };
var firstPageResponse = new ApiResponse<List<Repository>>(
CreateResponseWithApiInfo(firstPageLinks),
new List<Repository>
{
new Repository(1),
new Repository(2),
new Repository(3)
});
var thirdPageUrl = new Uri("https://example.com/page/3");
var secondPageLinks = new Dictionary<string, Uri> { { "next", thirdPageUrl } };
var secondPageResponse = new ApiResponse<List<Repository>>
(
CreateResponseWithApiInfo(secondPageLinks),
new List<Repository>
{
new Repository(4),
new Repository(5),
new Repository(6)
});
var lastPageResponse = new ApiResponse<List<Repository>>(
new Response(),
new List<Repository>
{
new Repository(7)
});
var gitHubClient = Substitute.For<IGitHubClient>();
gitHubClient.Connection.GetResponse<List<Repository>>(firstPageUrl)
.Returns(Task.Factory.StartNew<IApiResponse<List<Repository>>>(() => firstPageResponse));
gitHubClient.Connection.GetResponse<List<Repository>>(secondPageUrl)
.Returns(Task.Factory.StartNew<IApiResponse<List<Repository>>>(() => secondPageResponse));
gitHubClient.Connection.GetResponse<List<Repository>>(thirdPageUrl)
.Returns(Task.Factory.StartNew<IApiResponse<List<Repository>>>(() => lastPageResponse));
var repositoriesClient = new ObservableRepositoriesClient(gitHubClient);
var results = await repositoriesClient.GetAllForCurrent().ToArray();
Assert.Equal(7, results.Length);
gitHubClient.Connection.Received(1).Get<List<Repository>>(firstPageUrl, null, null);
gitHubClient.Connection.Received(1).Get<List<Repository>>(secondPageUrl, null, null);
gitHubClient.Connection.Received(1).Get<List<Repository>>(thirdPageUrl, null, null);
}
示例8: ReturnsSpecifiedRepository
public async Task ReturnsSpecifiedRepository()
{
var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
{
Credentials = Helper.Credentials
};
var client = new ObservableRepositoriesClient(github);
var observable = client.Get("haacked", "seegit");
var repository = await observable;
var repository2 = await observable;
Assert.Equal("https://github.com/Haacked/SeeGit.git", repository.CloneUrl);
Assert.False(repository.Private);
Assert.False(repository.Fork);
Assert.Equal("https://github.com/Haacked/SeeGit.git", repository2.CloneUrl);
Assert.False(repository2.Private);
Assert.False(repository2.Fork);
}
示例9: ObservableGitHubClient
public ObservableGitHubClient(IGitHubClient gitHubClient)
{
Ensure.ArgumentNotNull(gitHubClient, "githubClient");
_gitHubClient = gitHubClient;
Authorization = new ObservableAuthorizationsClient(gitHubClient);
Activity = new ObservableActivitiesClient(gitHubClient);
Issue = new ObservableIssuesClient(gitHubClient);
Miscellaneous = new ObservableMiscellaneousClient(gitHubClient.Miscellaneous);
Notification = new ObservableNotificationsClient(gitHubClient);
Organization = new ObservableOrganizationsClient(gitHubClient);
Repository = new ObservableRepositoriesClient(gitHubClient);
SshKey = new ObservableSshKeysClient(gitHubClient);
User = new ObservableUsersClient(gitHubClient);
Release = new ObservableReleasesClient(gitHubClient);
GitDatabase = new ObservableGitDatabaseClient(gitHubClient);
Gist = new ObservableGistsClient(gitHubClient);
Search = new ObservableSearchClient(gitHubClient);
}
示例10: ObservableGitHubClient
public ObservableGitHubClient(IGitHubClient gitHubClient)
{
Ensure.ArgumentNotNull(gitHubClient, "githubClient");
_gitHubClient = gitHubClient;
Authorization = new ObservableAuthorizationsClient(gitHubClient);
Activity = new ObservableActivitiesClient(gitHubClient);
Issue = new ObservableIssuesClient(gitHubClient);
Miscellaneous = new ObservableMiscellaneousClient(gitHubClient);
Oauth = new ObservableOauthClient(gitHubClient);
Organization = new ObservableOrganizationsClient(gitHubClient);
PullRequest = new ObservablePullRequestsClient(gitHubClient);
Repository = new ObservableRepositoriesClient(gitHubClient);
User = new ObservableUsersClient(gitHubClient);
Git = new ObservableGitDatabaseClient(gitHubClient);
Gist = new ObservableGistsClient(gitHubClient);
Search = new ObservableSearchClient(gitHubClient);
Enterprise = new ObservableEnterpriseClient(gitHubClient);
Migration = new ObservableMigrationClient(gitHubClient);
Reaction = new ObservableReactionsClient(gitHubClient);
}
示例11: IsALukeWarmObservable
public async Task IsALukeWarmObservable()
{
var repository = new Repository();
var response = Task.Factory.StartNew<IResponse<Repository>>(() =>
new ApiResponse<Repository> { BodyAsObject = repository });
var connection = Substitute.For<IConnection>();
connection.GetAsync<Repository>(Args.Uri, null, null).Returns(response);
var gitHubClient = new GitHubClient(connection);
var client = new ObservableRepositoriesClient(gitHubClient);
var observable = client.Get("stark", "ned");
connection.Received(0).GetAsync<Repository>(Args.Uri);
var result = await observable;
connection.Received(1).GetAsync<Repository>(Args.Uri, null, null);
var result2 = await observable;
// TODO: If we change this to a warm observable, we'll need to change this to Received(2)
connection.Received(1).GetAsync<Repository>(Args.Uri, null, null);
Assert.Same(repository, result);
Assert.Same(repository, result2);
}
示例12: EnsuresArguments
public async Task EnsuresArguments()
{
var github = Substitute.For<IGitHubClient>();
var nonreactiveClient = new RepositoriesClient(Substitute.For<IApiConnection>());
github.Repository.Returns(nonreactiveClient);
var client = new ObservableRepositoriesClient(github);
var update = new RepositoryUpdate();
Assert.Throws<ArgumentNullException>(() => client.Edit(null, "repo", update));
Assert.Throws<ArgumentNullException>(() => client.Edit("owner", null, update));
Assert.Throws<ArgumentNullException>(() => client.Edit("owner", "repo", null));
Assert.Throws<ArgumentException>(() => client.Edit("", "repo", update));
Assert.Throws<ArgumentException>(() => client.Edit("owner", "", update));
}
示例13: CallsIntoClient
public void CallsIntoClient()
{
var github = Substitute.For<IGitHubClient>();
var client = new ObservableRepositoriesClient(github);
client.GetBranch("owner", "repo", "branch");
github.Repository.Received(1).GetBranch("owner", "repo", "branch");
}
示例14: GetsCorrectUrl
public void GetsCorrectUrl()
{
var github = Substitute.For<IGitHubClient>();
var client = new ObservableRepositoriesClient(github);
var expected = new Uri("repos/owner/repo/tags", UriKind.Relative);
client.GetAllTags("owner", "repo");
github.Connection.Received(1).GetResponse<List<RepositoryTag>>(expected);
}
示例15: RequestsTheCorrectUrlWithRepositoryId
public void RequestsTheCorrectUrlWithRepositoryId()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableRepositoriesClient(gitHubClient);
var expected = new Uri("repositories/1/languages", UriKind.Relative);
client.GetAllLanguages(1);
gitHubClient.Connection.Received(1).GetResponse<List<Tuple<string, long>>>(expected);
}