• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# RepositoriesClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中RepositoriesClient的典型用法代码示例。如果您正苦于以下问题:C# RepositoriesClient类的具体用法?C# RepositoriesClient怎么用?C# RepositoriesClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RepositoriesClient类属于命名空间,在下文中一共展示了RepositoriesClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: EnsuresNonNullArguments

            public async Task EnsuresNonNullArguments()
            {
                var client = new RepositoriesClient(Substitute.For<IApiConnection>());

                await AssertEx.Throws<ArgumentNullException>(async () => await client.Create(null));
                await AssertEx.Throws<ArgumentException>(async () => await client.Create(new NewRepository { Name = null }));
            }
开发者ID:ninjanye,项目名称:octokit.net,代码行数:7,代码来源:RepositoriesClientTests.cs


示例2: EnsuresNonNullArguments

            public async Task EnsuresNonNullArguments()
            {
                var client = new RepositoriesClient(Substitute.For<IApiConnection>());

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Hooks.Get(null, "name", 123));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Hooks.Get("owner", null, 123));
            }
开发者ID:LiyeXu,项目名称:octokit.net,代码行数:7,代码来源:RepositoryHooksClientTest.cs


示例3: EnsuresNonNullArguments

            public async Task EnsuresNonNullArguments()
            {
                var client = new RepositoriesClient(Substitute.For<IApiConnection>());

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Forks.Create(null, "name", new NewRepositoryFork()));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Forks.Create("owner", null, new NewRepositoryFork()));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Forks.Create("owner", "name", null));
            }
开发者ID:cloudRoutine,项目名称:octokit.net,代码行数:8,代码来源:RepositoryForksClientTests.cs


示例4: UsesTheUserReposUrl

            public void UsesTheUserReposUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);

                client.Create(new NewRepository { Name = "aName" });

                connection.Received().Post<Repository>(Arg.Is<Uri>(u => u.ToString() == "user/repos"), Arg.Any<NewRepository>());
            }
开发者ID:ninjanye,项目名称:octokit.net,代码行数:9,代码来源:RepositoriesClientTests.cs


示例5: RequestsCorrectUrl

            public void RequestsCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);

                client.Hooks.Get("fake", "repo", 12345678);

                connection.Received().Get<RepositoryHook>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/hooks/12345678"));
            }
开发者ID:LiyeXu,项目名称:octokit.net,代码行数:9,代码来源:RepositoryHooksClientTest.cs


示例6: RequestsCorrectUrl

            public void RequestsCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);

                client.Forks.GetAll("fake", "repo", null);

                connection.Received().GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/forks"));
            }
开发者ID:cloudRoutine,项目名称:octokit.net,代码行数:9,代码来源:RepositoryForksClientTests.cs


示例7: UsesTheSuppliedHook

            public void UsesTheSuppliedHook()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);
                var newRepositoryFork = new NewRepositoryFork { Organization = "aName" };

                client.Forks.Create("owner", "repo", newRepositoryFork);

                connection.Received().Post<Repository>(Arg.Any<Uri>(), newRepositoryFork);
            }
开发者ID:cloudRoutine,项目名称:octokit.net,代码行数:10,代码来源:RepositoryForksClientTests.cs


示例8: UsesTheSuppliedHook

            public void UsesTheSuppliedHook()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);
                var newRepositoryHook = new NewRepositoryHook("name", new Dictionary<string, string> { { "config", "" } });

                client.Hooks.Create("owner", "repo", newRepositoryHook);

                connection.Received().Post<RepositoryHook>(Arg.Any<Uri>(), newRepositoryHook);
            }
开发者ID:LiyeXu,项目名称:octokit.net,代码行数:10,代码来源:RepositoryHooksClientTest.cs


示例9: TheNewRepositoryDescription

            public void TheNewRepositoryDescription()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);
                var newRepository = new NewRepository { Name = "aName" };

                client.Create(newRepository);

                connection.Received().Post<Repository>(Arg.Any<Uri>(), newRepository);
            }
开发者ID:ninjanye,项目名称:octokit.net,代码行数:10,代码来源:RepositoriesClientTests.cs


示例10: UsesTheOrganizatinosReposUrl

            public async Task UsesTheOrganizatinosReposUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);

                await client.Create("theLogin", new NewRepository { Name = "aName" });

                connection.Received().Post<Repository>(
                    Arg.Is<Uri>(u => u.ToString() == "orgs/theLogin/repos"),
                    Args.NewRepository);
            }
开发者ID:ninjanye,项目名称:octokit.net,代码行数:11,代码来源:RepositoriesClientTests.cs


示例11: RequestsCorrectUrlWithRequestParameters

            public void RequestsCorrectUrlWithRequestParameters()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);

                client.Forks.GetAll("fake", "repo", new RepositoryForksListRequest { Sort = Sort.Stargazers });

                connection.Received().GetAll<Repository>(
                    Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/forks"),
                    Arg.Is<Dictionary<string, string>>(d => d["sort"] == "stargazers"));
            }
开发者ID:cloudRoutine,项目名称:octokit.net,代码行数:11,代码来源:RepositoryForksClientTests.cs


示例12: RequestsCorrectUrlWithApiOptions

            public void RequestsCorrectUrlWithApiOptions()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);

                var options = new ApiOptions
                {
                    PageCount = 1,
                    PageSize = 1,
                    StartPage = 1
                };

                client.Hooks.GetAll("fake", "repo", options);

                connection.Received(1)
                    .GetAll<RepositoryHook>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/hooks"),
                        options);
            }
开发者ID:jrusbatch,项目名称:octokit.net,代码行数:18,代码来源:RepositoryHooksClientTest.cs


示例13: ThrowsRepositoryExistsExceptionWhenRepositoryExistsForCurrentUser

            public async Task ThrowsRepositoryExistsExceptionWhenRepositoryExistsForCurrentUser()
            {
                var newRepository = new NewRepository("aName");
                var response = Substitute.For<IResponse>();
                response.StatusCode.Returns((HttpStatusCode)422);
                response.Body.Returns(@"{""message"":""Validation Failed"",""documentation_url"":"
                    + @"""http://developer.github.com/v3/repos/#create"",""errors"":[{""resource"":""Repository"","
                    + @"""code"":""custom"",""field"":""name"",""message"":""name already exists on this account""}]}");
                var credentials = new Credentials("haacked", "pwd");
                var connection = Substitute.For<IApiConnection>();
                connection.Connection.BaseAddress.Returns(GitHubClient.GitHubApiUrl);
                connection.Connection.Credentials.Returns(credentials);
                connection.Post<Repository>(Args.Uri, newRepository)
                    .Returns<Task<Repository>>(_ => { throw new ApiValidationException(response); });
                var client = new RepositoriesClient(connection);

                var exception = await Assert.ThrowsAsync<RepositoryExistsException>(
                    () => client.Create(newRepository));

                Assert.False(exception.OwnerIsOrganization);
                Assert.Null(exception.Organization);
                Assert.Equal("aName", exception.RepositoryName);
                Assert.Null(exception.ExistingRepositoryWebUrl);
            }
开发者ID:RadicalLove,项目名称:octokit.net,代码行数:24,代码来源:RepositoriesClientTests.cs


示例14: RequestsTheCorrectUrlWithApiOptions

            public async Task RequestsTheCorrectUrlWithApiOptions()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);

                var options = new ApiOptions
                {
                    PageCount = 1,
                    StartPage = 1,
                    PageSize = 1
                };

                await client.GetAllTeams("owner", "name", options);

                connection.Received()
                    .GetAll<Team>(
                        Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/teams"),
                        options);
            }
开发者ID:RadicalLove,项目名称:octokit.net,代码行数:19,代码来源:RepositoriesClientTests.cs


示例15: 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));
            }
开发者ID:Feng2012,项目名称:octokit.net,代码行数:14,代码来源:ObservableRepositoriesClientTests.cs


示例16: RequestsTheCorrectUrlWithRepositoryId

            public async Task RequestsTheCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);

                await client.GetBranch(1, "branch");

                connection.Received()
                    .Get<Branch>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch"), null, "application/vnd.github.loki-preview+json");
            }
开发者ID:RadicalLove,项目名称:octokit.net,代码行数:10,代码来源:RepositoriesClientTests.cs


示例17: ReturnsReadmeHtml

            public async Task ReturnsReadmeHtml()
            {
                var connection = Substitute.For<IApiConnection>();
                connection.GetHtml(Args.Uri, null).Returns(Task.FromResult("<html>README</html>"));
                var reposEndpoint = new RepositoriesClient(connection);

                var readme = await reposEndpoint.GetReadmeHtml("fake", "repo");

                connection.Received().GetHtml(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/readme"), null);
                Assert.Equal("<html>README</html>", readme);
            }
开发者ID:ninjanye,项目名称:octokit.net,代码行数:11,代码来源:RepositoriesClientTests.cs


示例18: ReturnsReadme

            public async Task ReturnsReadme()
            {
                string encodedContent = Convert.ToBase64String(Encoding.UTF8.GetBytes("Hello world"));
                var readmeInfo = new ReadmeResponse
                {
                    Content = encodedContent,
                    Encoding = "base64",
                    Name = "README.md",
                    Url = "https://github.example.com/readme.md",
                    HtmlUrl = "https://github.example.com/readme"
                };
                var connection = Substitute.For<IApiConnection>();
                connection.Get<ReadmeResponse>(Args.Uri, null).Returns(Task.FromResult(readmeInfo));
                connection.GetHtml(Args.Uri, null).Returns(Task.FromResult("<html>README</html>"));
                var reposEndpoint = new RepositoriesClient(connection);

                var readme = await reposEndpoint.GetReadme("fake", "repo");

                Assert.Equal("README.md", readme.Name);
                connection.Received().Get<ReadmeResponse>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/readme"), 
                    null);
                connection.DidNotReceive().GetHtml(Arg.Is<Uri>(u => u.ToString() == "https://github.example.com/readme"), 
                    null);
                var htmlReadme = await readme.GetHtmlContent();
                Assert.Equal("<html>README</html>", htmlReadme);
                connection.Received().GetHtml(Arg.Is<Uri>(u => u.ToString() == "https://github.example.com/readme"), null);
            }
开发者ID:ninjanye,项目名称:octokit.net,代码行数:27,代码来源:RepositoriesClientTests.cs


示例19: RequestsCorrectUrl

            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);

                await client.Delete("theOwner", "theRepoName");

                connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repos/theOwner/theRepoName"));
            }
开发者ID:ninjanye,项目名称:octokit.net,代码行数:9,代码来源:RepositoriesClientTests.cs


示例20: EnsuresNonNullArguments

            public async Task EnsuresNonNullArguments()
            {
                var client = new RepositoriesClient(Substitute.For<IApiConnection>());

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetBranch(null, "repo", "branch"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetBranch("owner", null, "branch"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetBranch("owner", "repo", null));

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetBranch(1, null));

                await Assert.ThrowsAsync<ArgumentException>(() => client.GetBranch("", "repo", "branch"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetBranch("owner", "", "branch"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetBranch("owner", "repo", ""));
            }
开发者ID:RadicalLove,项目名称:octokit.net,代码行数:14,代码来源:RepositoriesClientTests.cs



注:本文中的RepositoriesClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Repository类代码示例发布时间:2022-05-24
下一篇:
C# ReportViewer类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap