public async Task EnsuresNonEmptyArguments() { var client = new DeploymentsClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", newDeployment)); await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", newDeployment)); }
/// <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 EnsuresNonNullArguments() { var client = new DeploymentsClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "name")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null)); }
public async Task EnsuresNonWhitespaceArguments(string whitespace) { var client = new DeploymentsClient(Substitute.For<IApiConnection>()); await AssertEx.Throws<ArgumentException>(() => client.GetAll(whitespace, "name")); await AssertEx.Throws<ArgumentException>(() => client.GetAll("owner", whitespace)); }
/// <summary> /// Create a new instance of the GitHub API v3 client using the specified connection. /// </summary> /// <param name="connection">The underlying <seealso cref="IConnection"/> used to make requests</param> public GitHubClient(IConnection connection) { Ensure.ArgumentNotNull(connection, "connection"); Connection = connection; var apiConnection = new ApiConnection(connection); Activity = new ActivitiesClient(apiConnection); Authorization = new AuthorizationsClient(apiConnection); Deployment = new DeploymentsClient(apiConnection); Enterprise = new EnterpriseClient(apiConnection); Gist = new GistsClient(apiConnection); Git = new GitDatabaseClient(apiConnection); Issue = new IssuesClient(apiConnection); Migration = new MigrationClient(apiConnection); Miscellaneous = new MiscellaneousClient(connection); Notification = new NotificationsClient(apiConnection); Oauth = new OauthClient(connection); Organization = new OrganizationsClient(apiConnection); PullRequest = new PullRequestsClient(apiConnection); Repository = new RepositoriesClient(apiConnection); Search = new SearchClient(apiConnection); SshKey = new SshKeysClient(apiConnection); User = new UsersClient(apiConnection); Reaction = new ReactionsClient(apiConnection); }
public async Task EnsuresNonEmptyArguments() { var client = new DeploymentsClient(Substitute.For<IApiConnection>()); Assert.Throws<ArgumentException>(() => client.GetAll("", "name")); Assert.Throws<ArgumentException>(() => client.GetAll("owner", "")); }
/// <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); }
public void EnsuresNonNullArguments() { var client = new DeploymentsClient(Substitute.For<IApiConnection>()); AssertEx.Throws<ArgumentNullException>(() => client.Create(null, "name", newDeployment)); AssertEx.Throws<ArgumentNullException>(() => client.Create("owner", null, newDeployment)); AssertEx.Throws<ArgumentNullException>(() => client.Create("owner", "name", null)); }
/// <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); }
public void RequestsCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new DeploymentsClient(connection); var expectedUrl = "repos/owner/name/deployments"; client.GetAll("owner", "name"); connection.Received(1).GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl)); }
public void RequestsCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new DeploymentsClient(connection); var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name); client.GetAll(owner, name); connection.Received(1) .GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), Args.ApiOptions); }
public void UsesPreviewAcceptsHeader() { var connection = Substitute.For<IApiConnection>(); var client = new DeploymentsClient(connection); client.GetAll("owner", "name"); connection.Received().GetAll<Deployment>(Arg.Any<Uri>(), Arg.Any<IDictionary<string, string>>(), ExpectedAcceptHeader); }
public async Task RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new DeploymentsClient(connection); var expectedUrl = string.Format("repositories/{0}/deployments", repositoryId); await client.GetAll(repositoryId); connection.Received(1) .GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), Args.ApiOptions); }
public async Task RequestsCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new DeploymentsClient(connection); var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name); await client.GetAll(owner, name); connection.Received(1) .GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), null, "application/vnd.github.ant-man-preview+json", Args.ApiOptions); }
/// <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 void RequestsCorrectUrlWithApiOptions() { var connection = Substitute.For<IApiConnection>(); var client = new DeploymentsClient(connection); var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name); var options = new ApiOptions { PageSize = 1, PageCount = 1, StartPage = 1 }; client.GetAll(owner, name, options); connection.Received(1) .GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), 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); }
/// <summary> /// Create a new instance of the GitHub API v3 client using the specified connection. /// </summary> /// <param name="connection">The underlying <seealso cref="IConnection"/> used to make requests</param> public GitHubClient(IConnection connection) { Ensure.ArgumentNotNull(connection, "connection"); Connection = connection; var apiConnection = new ApiConnection(connection); Authorization = new AuthorizationsClient(apiConnection); Activity = new ActivitiesClient(apiConnection); Issue = new IssuesClient(apiConnection); Miscellaneous = new MiscellaneousClient(connection); Notification = new NotificationsClient(apiConnection); Oauth = new OauthClient(connection); Organization = new OrganizationsClient(apiConnection); PullRequest = new PullRequestsClient(apiConnection); Repository = new RepositoriesClient(apiConnection); Gist = new GistsClient(apiConnection); Release = new ReleasesClient(apiConnection); User = new UsersClient(apiConnection); SshKey = new SshKeysClient(apiConnection); GitDatabase = new GitDatabaseClient(apiConnection); Search = new SearchClient(apiConnection); Deployment = new DeploymentsClient(apiConnection); }
public async Task RequestsCorrectUrlWithRepostoryIdWithApiOptions() { var connection = Substitute.For<IApiConnection>(); var client = new DeploymentsClient(connection); var expectedUrl = string.Format("repositories/{0}/deployments", repositoryId); var options = new ApiOptions { PageSize = 1, PageCount = 1, StartPage = 1 }; await client.GetAll(repositoryId, options); connection.Received(1) .GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), options); }
public void SetsStatusesClient() { var client = new DeploymentsClient(Substitute.For<IApiConnection>()); Assert.NotNull(client.Status); }
public void PostsToDeploymentsUrl() { var connection = Substitute.For<IApiConnection>(); var client = new DeploymentsClient(connection); var expectedUrl = "repos/owner/name/deployments"; client.Create("owner", "name", newDeployment); connection.Received(1).Post<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), newDeployment, "application/vnd.github.ant-man-preview+json"); }
public void PassesNewDeploymentRequest() { var connection = Substitute.For<IApiConnection>(); var client = new DeploymentsClient(connection); client.Create("owner", "name", newDeployment); connection.Received(1).Post<Deployment>(Arg.Any<Uri>(), newDeployment, Arg.Any<string>()); }
public void UsesPreviewAcceptsHeader() { var connection = Substitute.For<IApiConnection>(); var client = new DeploymentsClient(connection); client.Create("owner", "name", newDeployment); connection.Received().Post<Deployment>(Arg.Any<Uri>(), Arg.Any<NewDeployment>(), Arg.Is(ExpectedAcceptHeader)); }
public void PostsToDeploymentsUrl() { var connection = Substitute.For<IApiConnection>(); var client = new DeploymentsClient(connection); var expectedUrl = "repos/owner/name/deployments"; client.Create("owner", "name", newDeployment); connection.Received(1).Post<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), Arg.Any<NewDeployment>(), Arg.Any<string>()); }
public void EnsuresNonWhitespaceArguments(string whitespace) { var client = new DeploymentsClient(Substitute.For<IApiConnection>()); Assert.Throws<ArgumentException>(() => client.Create(whitespace, "name", newDeployment)); Assert.Throws<ArgumentException>(() => client.Create("owner", whitespace, newDeployment)); }
public void RequestsCorrectUrlWithPreviewAcceptHeaders() { var connection = Substitute.For<IApiConnection>(); var client = new DeploymentsClient(connection); var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name); client.GetAll(owner, name); connection.Received(1) .GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), Arg.Any<IDictionary<string, string>>(), Arg.Is<string>(s => s == AcceptHeaders.DeploymentApiPreview), Args.ApiOptions); }
public void SendsPreviewAcceptHeaders() { var connection = Substitute.For<IApiConnection>(); var client = new DeploymentsClient(connection); client.Create("owner", "name", newDeployment); connection.Received(1).Post<Deployment>(Arg.Any<Uri>(), Arg.Any<NewDeployment>(), Arg.Is<string>(s => s == AcceptHeaders.DeploymentApiPreview)); }
public void PostsToDeploymentsUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new DeploymentsClient(connection); var expectedUrl = "repositories/1/deployments"; client.Create(1, newDeployment); connection.Received(1).Post<Deployment>(Arg.Is<Uri>(uri => uri.ToString() == expectedUrl), newDeployment); }