Example #1
0
        /// <summary>
        /// Initializes a new GitHub Repos API client.
        /// </summary>
        /// <param name="apiConnection">An API connection</param>
        public RepositoriesClient(IApiConnection apiConnection) : base(apiConnection)
        {
            Status = new CommitStatusClient(apiConnection);
            Hooks  = new RepositoryHooksClient(apiConnection);
            Forks  = new RepositoryForksClient(apiConnection);
#pragma warning disable CS0618 // Type or member is obsolete
            RepoCollaborators = new RepoCollaboratorsClient(apiConnection);
#pragma warning restore CS0618 // Type or member is obsolete
            Collaborator = new RepoCollaboratorsClient(apiConnection);
            Statistics   = new StatisticsClient(apiConnection);
            Deployment   = new DeploymentsClient(apiConnection);
            PullRequest  = new PullRequestsClient(apiConnection);
#pragma warning disable CS0618 // Type or member is obsolete
            RepositoryComments = new RepositoryCommentsClient(apiConnection);
#pragma warning restore CS0618 // Type or member is obsolete
            Comment = new RepositoryCommentsClient(apiConnection);
#pragma warning disable CS0618 // Type or member is obsolete
            Commits = new RepositoryCommitsClient(apiConnection);
#pragma warning restore CS0618 // Type or member is obsolete
            Commit     = new RepositoryCommitsClient(apiConnection);
            Release    = new ReleasesClient(apiConnection);
            DeployKeys = new RepositoryDeployKeysClient(apiConnection);
            Merging    = new MergingClient(apiConnection);
            Content    = new RepositoryContentsClient(apiConnection);
        }
        /// <summary>
        /// Initializes a new GitHub Repos API client.
        /// </summary>
        /// <param name="apiConnection">An API connection</param>
        public RepositoriesClient(IApiConnection apiConnection) : base(apiConnection)
        {
            Status = new CommitStatusClient(apiConnection);
            Hooks = new RepositoryHooksClient(apiConnection);
            Forks = new RepositoryForksClient(apiConnection);
#pragma warning disable CS0618 // Type or member is obsolete
            RepoCollaborators = new RepoCollaboratorsClient(apiConnection);
#pragma warning restore CS0618 // Type or member is obsolete
            Collaborator = new RepoCollaboratorsClient(apiConnection);
            Statistics = new StatisticsClient(apiConnection);
            Deployment = new DeploymentsClient(apiConnection);
            PullRequest = new PullRequestsClient(apiConnection);
#pragma warning disable CS0618 // Type or member is obsolete
            RepositoryComments = new RepositoryCommentsClient(apiConnection);
#pragma warning restore CS0618 // Type or member is obsolete
            Comment = new RepositoryCommentsClient(apiConnection);
#pragma warning disable CS0618 // Type or member is obsolete
            Commits = new RepositoryCommitsClient(apiConnection);
#pragma warning restore CS0618 // Type or member is obsolete
            Commit = new RepositoryCommitsClient(apiConnection);
            Release = new ReleasesClient(apiConnection);
            DeployKeys = new RepositoryDeployKeysClient(apiConnection);
            Merging = new MergingClient(apiConnection);
            Content = new RepositoryContentsClient(apiConnection);
            Page = new RepositoryPagesClient(apiConnection);
        }
        public async Task RequestsCorrectUrlWithRepositoryId()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new RepositoryCommentsClient(connection);

            await client.GetAllForRepository(1);

            connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments"), Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview", Args.ApiOptions);
        }
        public async Task RequestsCorrectUrl()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new RepositoryCommentsClient(connection);

            await client.Get("fake", "repo", 42);

            connection.Received().Get<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/42"), Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview");
        }
Example #5
0
 /// <summary>
 /// Initializes a new GitHub Repos API client.
 /// </summary>
 /// <param name="apiConnection">An API connection</param>
 public RepositoriesClient(IApiConnection apiConnection) : base(apiConnection)
 {
     CommitStatus = new CommitStatusClient(apiConnection);
     RepoCollaborators = new RepoCollaboratorsClient(apiConnection);
     Statistics = new StatisticsClient(apiConnection);
     Deployment = new DeploymentsClient(apiConnection);
     PullRequest = new PullRequestsClient(apiConnection);
     RepositoryComments = new RepositoryCommentsClient(apiConnection);
 }
        public void RequestsCorrectUrl()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new RepositoryCommentsClient(connection);

            client.GetAllForCommit("fake", "repo", "sha");

            connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits/sha/comments"));
        }
        public async Task EnsuresNonNullArguments()
        {
            var client = new RepositoryCommentsClient(Substitute.For<IApiConnection>());

            await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "name", 1));
            await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", "name", 1));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null, 1));
            await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "", 1));
        }
        public async Task RequestsCorrectUrlWithRepositoryId()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new RepositoryCommentsClient(connection);

            await client.GetAllForRepository(1);

            connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments"), Args.ApiOptions);
        }
        public async Task RequestsCorrectUrl()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new RepositoryCommentsClient(connection);

            await client.Get("fake", "repo", 42);

            connection.Received().Get<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/42"));
        }
 /// <summary>
 /// Initializes a new GitHub Repos API client.
 /// </summary>
 /// <param name="apiConnection">An API connection</param>
 public RepositoriesClient(IApiConnection apiConnection) : base(apiConnection)
 {
     CommitStatus       = new CommitStatusClient(apiConnection);
     RepoCollaborators  = new RepoCollaboratorsClient(apiConnection);
     Statistics         = new StatisticsClient(apiConnection);
     Deployment         = new DeploymentsClient(apiConnection);
     PullRequest        = new PullRequestsClient(apiConnection);
     RepositoryComments = new RepositoryCommentsClient(apiConnection);
     Commits            = new RepositoryCommitsClient(apiConnection);
 }
        public async Task EnsuresArgumentsNotNull()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new RepositoryCommentsClient(connection);

            await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name"));
            await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name"));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null));
            await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", ""));
        }
        public async Task EnsuresArgumentsNotNull()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new RepositoryCommentsClient(connection);

            await AssertEx.Throws<ArgumentNullException>(async () => await client.GetForCommit(null, "name", "sha"));
            await AssertEx.Throws<ArgumentException>(async () => await client.GetForCommit("", "name", "sha"));
            await AssertEx.Throws<ArgumentNullException>(async () => await client.GetForCommit("owner", null, "sha"));
            await AssertEx.Throws<ArgumentException>(async () => await client.GetForCommit("owner", "", "sha"));
            await AssertEx.Throws<ArgumentNullException>(async () => await client.GetForCommit("owner", "name", null));
            await AssertEx.Throws<ArgumentException>(async () => await client.GetForCommit("owner", "name", ""));
        }
 /// <summary>
 /// Initializes a new GitHub Repos API client.
 /// </summary>
 /// <param name="apiConnection">An API connection</param>
 public RepositoriesClient(IApiConnection apiConnection) : base(apiConnection)
 {
     CommitStatus       = new CommitStatusClient(apiConnection);
     Hooks              = new RepositoryHooksClient(apiConnection);
     Forks              = new RepositoryForksClient(apiConnection);
     RepoCollaborators  = new RepoCollaboratorsClient(apiConnection);
     Statistics         = new StatisticsClient(apiConnection);
     Deployment         = new DeploymentsClient(apiConnection);
     PullRequest        = new PullRequestsClient(apiConnection);
     RepositoryComments = new RepositoryCommentsClient(apiConnection);
     Commits            = new RepositoryCommitsClient(apiConnection);
     DeployKeys         = new RepositoryDeployKeysClient(apiConnection);
     Merging            = new MergingClient(apiConnection);
     Content            = new RepositoryContentsClient(apiConnection);
 }
Example #14
0
 /// <summary>
 /// Initializes a new GitHub Repos API client.
 /// </summary>
 /// <param name="apiConnection">An API connection</param>
 public RepositoriesClient(IApiConnection apiConnection) : base(apiConnection)
 {
     CommitStatus = new CommitStatusClient(apiConnection);
     Hooks = new RepositoryHooksClient(apiConnection);
     Forks = new RepositoryForksClient(apiConnection);
     RepoCollaborators = new RepoCollaboratorsClient(apiConnection);
     Statistics = new StatisticsClient(apiConnection);
     Deployment = new DeploymentsClient(apiConnection);
     PullRequest = new PullRequestsClient(apiConnection);
     RepositoryComments = new RepositoryCommentsClient(apiConnection);
     Commits = new RepositoryCommitsClient(apiConnection);
     DeployKeys = new RepositoryDeployKeysClient(apiConnection);
     Merging = new MergingClient(apiConnection);
     Content = new RepositoryContentsClient(apiConnection);
 }
        public async Task RequestsCorrectUrlWithApiOptions()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new RepositoryCommentsClient(connection);

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

            await client.GetAllForRepository("fake", "repo", options);

            connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments"), Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview", options);
        }
        public async Task RequestsCorrectUrlWithApiOptions()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new RepositoryCommentsClient(connection);

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

            await client.GetAllForRepository("fake", "repo", options);

            connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments"), options);
        }
 /// <summary>
 /// Initializes a new GitHub Repos API client.
 /// </summary>
 /// <param name="apiConnection">An API connection</param>
 public RepositoriesClient(IApiConnection apiConnection) : base(apiConnection)
 {
     Status = new CommitStatusClient(apiConnection);
     Hooks = new RepositoryHooksClient(apiConnection);
     Forks = new RepositoryForksClient(apiConnection);
     Collaborator = new RepoCollaboratorsClient(apiConnection);
     Statistics = new StatisticsClient(apiConnection);
     Deployment = new DeploymentsClient(apiConnection);
     PullRequest = new PullRequestsClient(apiConnection);
     Comment = new RepositoryCommentsClient(apiConnection);
     Commit = new RepositoryCommitsClient(apiConnection);
     Release = new ReleasesClient(apiConnection);
     DeployKeys = new RepositoryDeployKeysClient(apiConnection);
     Merging = new MergingClient(apiConnection);
     Content = new RepositoryContentsClient(apiConnection);
     Page = new RepositoryPagesClient(apiConnection);
     Invitation = new RepositoryInvitationsClient(apiConnection);
     Branch = new RepositoryBranchesClient(apiConnection);
 }
Example #18
0
 /// <summary>
 /// Initializes a new GitHub Repos API client.
 /// </summary>
 /// <param name="apiConnection">An API connection</param>
 public RepositoriesClient(IApiConnection apiConnection) : base(apiConnection)
 {
     Status       = new CommitStatusClient(apiConnection);
     Hooks        = new RepositoryHooksClient(apiConnection);
     Forks        = new RepositoryForksClient(apiConnection);
     Collaborator = new RepoCollaboratorsClient(apiConnection);
     Statistics   = new StatisticsClient(apiConnection);
     Deployment   = new DeploymentsClient(apiConnection);
     PullRequest  = new PullRequestsClient(apiConnection);
     Comment      = new RepositoryCommentsClient(apiConnection);
     Commit       = new RepositoryCommitsClient(apiConnection);
     Release      = new ReleasesClient(apiConnection);
     DeployKeys   = new RepositoryDeployKeysClient(apiConnection);
     Merging      = new MergingClient(apiConnection);
     Content      = new RepositoryContentsClient(apiConnection);
     Page         = new RepositoryPagesClient(apiConnection);
     Invitation   = new RepositoryInvitationsClient(apiConnection);
     Branch       = new RepositoryBranchesClient(apiConnection);
 }
        public void PostsToCorrectUrl()
        {
            const string issueCommentUpdate = "updated comment";
            var connection = Substitute.For<IApiConnection>();
            var client = new RepositoryCommentsClient(connection);

            client.Update("fake", "repo", 42, issueCommentUpdate);

            connection.Received().Patch<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/42"), Arg.Any<object>());
        }
        public async Task EnsuresNonNullArgumentsOrEmpty()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new RepositoryCommentsClient(connection);

            await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete(null, "name", 42));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete("owner", null, 42));

            await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("", "name", 42));
            await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("owner", "", 42));
        }
        public async Task DeletesCorrectUrlWithRepositoryId()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new RepositoryCommentsClient(connection);

            await client.Delete(1, 42);

            connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/42"));
        }
        public async Task PostsToCorrectUrlWithRepositoryId()
        {
            const string issueCommentUpdate = "updated comment";
            var connection = Substitute.For<IApiConnection>();
            var client = new RepositoryCommentsClient(connection);

            await client.Update(1, 42, issueCommentUpdate);

            connection.Received().Patch<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/42"), Arg.Any<object>());
        }
        public async Task EnsuresNonNullArguments()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new RepositoryCommentsClient(connection);

            await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, "name", "sha", new NewCommitComment("body")));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", null, "sha", new NewCommitComment("body")));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "name", null, new NewCommitComment("body")));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "name", "sha", null));

            await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(1, null, new NewCommitComment("body")));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(1, "sha", null));

            await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", "sha", new NewCommitComment("body")));
            await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", "sha", new NewCommitComment("body")));
            await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "name", "", new NewCommitComment("body")));
            await Assert.ThrowsAsync<ArgumentException>(() => client.Create(1, "", new NewCommitComment("body")));
        }
        public async Task PostsToCorrectUrlWithRepositoryId()
        {
            var newComment = new NewCommitComment("body");

            var connection = Substitute.For<IApiConnection>();
            var client = new RepositoryCommentsClient(connection);

            await client.Create(1, "sha", newComment);

            connection.Received().Post<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/commits/sha/comments"), Arg.Any<object>());
        }
        public async Task EnsuresNonNullArguments()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new RepositoryCommentsClient(connection);

            await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCommit(null, "name", "sha"));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCommit("owner", null, "sha"));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCommit("owner", "name", null));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCommit(null, "name", "sha", ApiOptions.None));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCommit("owner", null, "sha", ApiOptions.None));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCommit("owner", "name", null, ApiOptions.None));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCommit("owner", "name", "sha", null));

            await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCommit(1, null, ApiOptions.None));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCommit(1, "sha", null));
            
            await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForCommit("", "name", "sha"));
            await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForCommit("owner", "", "sha"));
            await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForCommit("owner", "name", ""));
            await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForCommit("", "name", "sha", ApiOptions.None));
            await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForCommit("owner", "", "sha", ApiOptions.None));
            await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForCommit("owner", "name", "", ApiOptions.None));

            await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForCommit(1, "", ApiOptions.None));
        }
        public void PostsToCorrectUrl()
        {
            NewCommitComment newComment = new NewCommitComment("body");
            
            var connection = Substitute.For<IApiConnection>();
            var client = new RepositoryCommentsClient(connection);

            client.Create("fake", "repo", "sha", newComment);

            connection.Received().Post<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits/sha/comments"), Arg.Any<object>());
        }
        public void DeletesCorrectUrl()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new RepositoryCommentsClient(connection);

            client.Delete("fake", "repo", 42);

            connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/42"));
        }