diff --git a/Octokit.Reactive/Clients/IObservableCheckRunsClient.cs b/Octokit.Reactive/Clients/IObservableCheckRunsClient.cs
new file mode 100644
index 0000000000..9980baf349
--- /dev/null
+++ b/Octokit.Reactive/Clients/IObservableCheckRunsClient.cs
@@ -0,0 +1,261 @@
+using System;
+
+namespace Octokit.Reactive
+{
+ ///
+ /// A client for GitHub's Check Runs API
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ public interface IObservableCheckRunsClient
+ {
+ ///
+ /// Creates a new check run for a specific commit in a repository
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// Details of the Check Run to create
+ IObservable Create(string owner, string name, NewCheckRun newCheckRun);
+
+ ///
+ /// Creates a new check run for a specific commit in a repository
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// Details of the Check Run to create
+ IObservable Create(long repositoryId, NewCheckRun newCheckRun);
+
+ ///
+ /// Updates a check run for a specific commit in a repository
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The Id of the check run
+ /// The updates to the check run
+ IObservable Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate);
+
+ ///
+ /// Updates a check run for a specific commit in a repository
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// The Id of the check run
+ /// The updates to the check run
+ IObservable Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate);
+
+ ///
+ /// Lists check runs for a commit ref. The ref can be a SHA, branch name, or a tag name
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The commit reference (can be a SHA, branch name, or a tag name)
+ IObservable GetAllForReference(string owner, string name, string reference);
+
+ ///
+ /// Lists check runs for a commit ref. The ref can be a SHA, branch name, or a tag name
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// The commit reference (can be a SHA, branch name, or a tag name)
+ IObservable GetAllForReference(long repositoryId, string reference);
+
+ ///
+ /// Lists check runs for a commit ref. The ref can be a SHA, branch name, or a tag name
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The commit reference (can be a SHA, branch name, or a tag name)
+ /// Details to filter the request, such as by check name
+ IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest);
+
+ ///
+ /// Lists check runs for a commit ref. The ref can be a SHA, branch name, or a tag name
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// The commit reference (can be a SHA, branch name, or a tag name)
+ /// Details to filter the request, such as by check name
+ IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest);
+
+ ///
+ /// Lists check runs for a commit ref. The ref can be a SHA, branch name, or a tag name
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The commit reference (can be a SHA, branch name, or a tag name)
+ /// Details to filter the request, such as by check name
+ /// Options to change the API response
+ IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options);
+
+ ///
+ /// Lists check runs for a commit ref. The ref can be a SHA, branch name, or a tag name
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// The commit reference (can be a SHA, branch name, or a tag name)
+ /// Details to filter the request, such as by check name
+ /// Options to change the API response
+ IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options);
+
+ ///
+ /// Lists check runs for a check suite using its Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The Id of the check suite
+ IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId);
+
+ ///
+ /// Lists check runs for a check suite using its Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// The Id of the check suite
+ IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId);
+
+ ///
+ /// Lists check runs for a check suite using its Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The Id of the check suite
+ /// Details to filter the request, such as by check name
+ IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest);
+
+ ///
+ /// Lists check runs for a check suite using its Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// The Id of the check suite
+ /// Details to filter the request, such as by check name
+ IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest);
+
+ ///
+ /// Lists check runs for a check suite using its Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The Id of the check suite
+ /// Details to filter the request, such as by check name
+ /// Options to change the API response
+ IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options);
+
+ ///
+ /// Lists check runs for a check suite using its Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// The Id of the check suite
+ /// Details to filter the request, such as by check name
+ /// Options to change the API response
+ IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options);
+
+ ///
+ /// Gets a single check run using its Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The Id of the check run
+ IObservable Get(string owner, string name, long checkRunId);
+
+ ///
+ /// Gets a single check run using its Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// The Id of the check run
+ IObservable Get(long repositoryId, long checkRunId);
+
+ ///
+ /// Lists annotations for a check run using the check run Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The Id of the check run
+ IObservable GetAllAnnotations(string owner, string name, long checkRunId);
+
+ ///
+ /// Lists annotations for a check run using the check run Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// The Id of the check run
+ ///
+ IObservable GetAllAnnotations(long repositoryId, long checkRunId);
+
+ ///
+ /// Lists annotations for a check run using the check run Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The Id of the check run
+ /// Options to change the API response
+ IObservable GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options);
+
+ ///
+ /// Lists annotations for a check run using the check run Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// The Id of the check run
+ /// Options to change the API response
+ IObservable GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options);
+ }
+}
\ No newline at end of file
diff --git a/Octokit.Reactive/Clients/IObservableChecksClient.cs b/Octokit.Reactive/Clients/IObservableChecksClient.cs
index a5127ae78f..ad64e42214 100644
--- a/Octokit.Reactive/Clients/IObservableChecksClient.cs
+++ b/Octokit.Reactive/Clients/IObservableChecksClient.cs
@@ -8,6 +8,14 @@
///
public interface IObservableChecksClient
{
+ ///
+ /// A client for GitHub's Check Runs API.
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ IObservableCheckRunsClient Run { get; }
+
///
/// A client for GitHub's Check Suites API.
///
diff --git a/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs b/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs
new file mode 100644
index 0000000000..ee5ebb5f03
--- /dev/null
+++ b/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs
@@ -0,0 +1,409 @@
+using System;
+using System.Reactive.Threading.Tasks;
+using Octokit.Reactive.Internal;
+
+namespace Octokit.Reactive
+{
+ ///
+ /// A client for GitHub's Check Runs API
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ public class ObservableCheckRunsClient : IObservableCheckRunsClient
+ {
+ readonly ICheckRunsClient _client;
+ readonly IConnection _connection;
+
+ ///
+ /// Initializes a new GitHub Check Runs API client
+ ///
+ /// An used to make the requests
+ public ObservableCheckRunsClient(IGitHubClient client)
+ {
+ Ensure.ArgumentNotNull(client, nameof(client));
+
+ _client = client.Check.Run;
+ _connection = client.Connection;
+ }
+
+ ///
+ /// Creates a new check run for a specific commit in a repository
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// Details of the Check Run to create
+ public IObservable Create(string owner, string name, NewCheckRun newCheckRun)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
+ Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
+ Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun));
+
+ return _client.Create(owner, name, newCheckRun).ToObservable();
+ }
+
+ ///
+ /// Creates a new check run for a specific commit in a repository
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// Details of the Check Run to create
+ public IObservable Create(long repositoryId, NewCheckRun newCheckRun)
+ {
+ Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun));
+
+ return _client.Create(repositoryId, newCheckRun).ToObservable();
+ }
+
+ ///
+ /// Updates a check run for a specific commit in a repository
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The Id of the check run
+ /// The updates to the check run
+ public IObservable Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
+ Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
+ Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate));
+
+ return _client.Update(owner, name, checkRunId, checkRunUpdate).ToObservable();
+ }
+
+ ///
+ /// Updates a check run for a specific commit in a repository
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// The Id of the check run
+ /// The updates to the check run
+ public IObservable Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate)
+ {
+ Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate));
+
+ return _client.Update(repositoryId, checkRunId, checkRunUpdate).ToObservable();
+ }
+
+ ///
+ /// Lists check runs for a commit ref. The ref can be a SHA, branch name, or a tag name
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The commit reference (can be a SHA, branch name, or a tag name)
+ public IObservable GetAllForReference(string owner, string name, string reference)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
+ Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
+ Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));
+
+ return GetAllForReference(owner, name, reference, new CheckRunRequest(), ApiOptions.None);
+ }
+
+ ///
+ /// Lists check runs for a commit ref. The ref can be a SHA, branch name, or a tag name
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// The commit reference (can be a SHA, branch name, or a tag name)
+ public IObservable GetAllForReference(long repositoryId, string reference)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));
+
+ return GetAllForReference(repositoryId, reference, new CheckRunRequest(), ApiOptions.None);
+ }
+
+ ///
+ /// Lists check runs for a commit ref. The ref can be a SHA, branch name, or a tag name
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The commit reference (can be a SHA, branch name, or a tag name)
+ /// Details to filter the request, such as by check name
+ public IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
+ Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
+ Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));
+ Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest));
+
+ return GetAllForReference(owner, name, reference, checkRunRequest, ApiOptions.None);
+ }
+
+ ///
+ /// Lists check runs for a commit ref. The ref can be a SHA, branch name, or a tag name
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// The commit reference (can be a SHA, branch name, or a tag name)
+ /// Details to filter the request, such as by check name
+ public IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));
+ Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest));
+
+ return GetAllForReference(repositoryId, reference, checkRunRequest, ApiOptions.None);
+ }
+
+ ///
+ /// Lists check runs for a commit ref. The ref can be a SHA, branch name, or a tag name
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The commit reference (can be a SHA, branch name, or a tag name)
+ /// Details to filter the request, such as by check name
+ /// Options to change the API response
+ public IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
+ Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
+ Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));
+ Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest));
+ Ensure.ArgumentNotNull(options, nameof(options));
+
+ return _connection.GetAndFlattenAllPages(ApiUrls.CheckRunsForReference(owner, name, reference), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options);
+ }
+
+ ///
+ /// Lists check runs for a commit ref. The ref can be a SHA, branch name, or a tag name
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// The commit reference (can be a SHA, branch name, or a tag name)
+ /// Details to filter the request, such as by check name
+ /// Options to change the API response
+ public IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));
+ Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest));
+ Ensure.ArgumentNotNull(options, nameof(options));
+
+ return _connection.GetAndFlattenAllPages(ApiUrls.CheckRunsForReference(repositoryId, reference), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options);
+ }
+
+ ///
+ /// Lists check runs for a check suite using its Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The Id of the check suite
+ public IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
+ Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
+
+ return GetAllForCheckSuite(owner, name, checkSuiteId, new CheckRunRequest(), ApiOptions.None);
+ }
+
+ ///
+ /// Lists check runs for a check suite using its Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// The Id of the check suite
+ public IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId)
+ {
+ return GetAllForCheckSuite(repositoryId, checkSuiteId, new CheckRunRequest(), ApiOptions.None);
+ }
+
+ ///
+ /// Lists check runs for a check suite using its Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The Id of the check suite
+ /// Details to filter the request, such as by check name
+ public IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
+ Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
+ Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest));
+
+ return GetAllForCheckSuite(owner, name, checkSuiteId, checkRunRequest, ApiOptions.None);
+ }
+
+ ///
+ /// Lists check runs for a check suite using its Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// The Id of the check suite
+ /// Details to filter the request, such as by check name
+ public IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest)
+ {
+ Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest));
+
+ return GetAllForCheckSuite(repositoryId, checkSuiteId, checkRunRequest, ApiOptions.None);
+ }
+
+ ///
+ /// Lists check runs for a check suite using its Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The Id of the check suite
+ /// Details to filter the request, such as by check name
+ /// Options to change the API response
+ public IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
+ Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
+ Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest));
+ Ensure.ArgumentNotNull(options, nameof(options));
+
+ return _connection.GetAndFlattenAllPages(ApiUrls.CheckRunsForCheckSuite(owner, name, checkSuiteId), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options);
+ }
+
+ ///
+ /// Lists check runs for a check suite using its Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// The Id of the check suite
+ /// Details to filter the request, such as by check name
+ /// Options to change the API response
+ public IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options)
+ {
+ Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest));
+ Ensure.ArgumentNotNull(options, nameof(options));
+
+ return _connection.GetAndFlattenAllPages(ApiUrls.CheckRunsForCheckSuite(repositoryId, checkSuiteId), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options);
+ }
+
+ ///
+ /// Gets a single check run using its Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The Id of the check run
+ public IObservable Get(string owner, string name, long checkRunId)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
+ Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
+
+ return _client.Get(owner, name, checkRunId).ToObservable();
+ }
+
+ ///
+ /// Gets a single check run using its Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// The Id of the check run
+ public IObservable Get(long repositoryId, long checkRunId)
+ {
+ return _client.Get(repositoryId, checkRunId).ToObservable();
+ }
+
+ ///
+ /// Lists annotations for a check run using the check run Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The Id of the check run
+ public IObservable GetAllAnnotations(string owner, string name, long checkRunId)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
+ Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
+
+ return GetAllAnnotations(owner, name, checkRunId, ApiOptions.None);
+ }
+
+ ///
+ /// Lists annotations for a check run using the check run Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// The Id of the check run
+ ///
+ public IObservable GetAllAnnotations(long repositoryId, long checkRunId)
+ {
+ return GetAllAnnotations(repositoryId, checkRunId, ApiOptions.None);
+ }
+
+ ///
+ /// Lists annotations for a check run using the check run Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The Id of the check run
+ /// Options to change the API response
+ public IObservable GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
+ Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
+ Ensure.ArgumentNotNull(options, nameof(options));
+
+ return _connection.GetAndFlattenAllPages(ApiUrls.CheckRunAnnotations(owner, name, checkRunId), null, AcceptHeaders.ChecksApiPreview, options);
+ }
+
+ ///
+ /// Lists annotations for a check run using the check run Id
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ /// The Id of the repository
+ /// The Id of the check run
+ /// Options to change the API response
+ public IObservable GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options)
+ {
+ Ensure.ArgumentNotNull(options, nameof(options));
+
+ return _connection.GetAndFlattenAllPages(ApiUrls.CheckRunAnnotations(repositoryId, checkRunId), null, AcceptHeaders.ChecksApiPreview, options);
+ }
+ }
+}
diff --git a/Octokit.Reactive/Clients/ObservableChecksClient.cs b/Octokit.Reactive/Clients/ObservableChecksClient.cs
index 90c4b72dcd..eb3d829f6e 100644
--- a/Octokit.Reactive/Clients/ObservableChecksClient.cs
+++ b/Octokit.Reactive/Clients/ObservableChecksClient.cs
@@ -8,13 +8,26 @@
///
public class ObservableChecksClient : IObservableChecksClient
{
+ ///
+ /// Initializes a new GitHub Checks API client.
+ ///
+ /// An used to make the requests
public ObservableChecksClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, nameof(client));
+ Run = new ObservableCheckRunsClient(client);
Suite = new ObservableCheckSuitesClient(client);
}
+ ///
+ /// A client for GitHub's Check Runs API.
+ ///
+ ///
+ /// See the Check Runs API documentation for more information.
+ ///
+ public IObservableCheckRunsClient Run { get; private set; }
+
///
/// A client for GitHub's Check Suites API.
///
diff --git a/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs b/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs
new file mode 100644
index 0000000000..7adaf503e3
--- /dev/null
+++ b/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs
@@ -0,0 +1,460 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Octokit.Tests.Integration.Helpers;
+using Xunit;
+
+namespace Octokit.Tests.Integration.Clients
+{
+ public class CheckRunsClientTests
+ {
+ public class TheCreateMethod
+ {
+ IGitHubClient _github;
+ IGitHubClient _githubAppInstallation;
+
+ public TheCreateMethod()
+ {
+ _github = Helper.GetAuthenticatedClient();
+
+ // Authenticate as a GitHubApp Installation
+ _githubAppInstallation = Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName);
+ }
+
+ [GitHubAppsTest]
+ public async Task CreatesCheckRun()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.Queued
+ };
+ var result = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckRun);
+
+ // Check result
+ Assert.NotNull(result);
+ Assert.Equal(featureBranch.Object.Sha, result.HeadSha);
+ }
+ }
+
+ [GitHubAppsTest]
+ public async Task CreatesCheckRunWithRepositoryId()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.Queued
+ };
+ var result = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryId, newCheckRun);
+
+ // Check result
+ Assert.NotNull(result);
+ Assert.Equal(featureBranch.Object.Sha, result.HeadSha);
+ }
+ }
+ }
+
+ public class TheUpdateMethod
+ {
+ IGitHubClient _github;
+ IGitHubClient _githubAppInstallation;
+
+ public TheUpdateMethod()
+ {
+ _github = Helper.GetAuthenticatedClient();
+
+ // Authenticate as a GitHubApp Installation
+ _githubAppInstallation = Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName);
+ }
+
+ [GitHubAppsTest]
+ public async Task UpdatesCheckRun()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.Queued
+ };
+ var checkRun = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckRun);
+
+ // Update the check run
+ var update = new CheckRunUpdate("new-name")
+ {
+ Status = CheckStatus.InProgress
+ };
+ var result = await _githubAppInstallation.Check.Run.Update(repoContext.RepositoryOwner, repoContext.RepositoryName, checkRun.Id, update);
+
+ // Check result
+ Assert.NotNull(result);
+ Assert.Equal(featureBranch.Object.Sha, result.HeadSha);
+ Assert.Equal("new-name", result.Name);
+ Assert.Equal(CheckStatus.InProgress, result.Status);
+ }
+ }
+
+ [GitHubAppsTest]
+ public async Task UpdatesCheckRunWithRepositoryId()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.Queued
+ };
+ var checkRun = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryId, newCheckRun);
+
+ // Update the check run
+ var update = new CheckRunUpdate("new-name")
+ {
+ Status = CheckStatus.InProgress
+ };
+ var result = await _githubAppInstallation.Check.Run.Update(repoContext.RepositoryId, checkRun.Id, update);
+
+ // Check result
+ Assert.NotNull(result);
+ Assert.Equal(featureBranch.Object.Sha, result.HeadSha);
+ Assert.Equal("new-name", result.Name);
+ Assert.Equal(CheckStatus.InProgress, result.Status);
+ }
+ }
+ }
+
+ public class TheGetAllForReferenceMethod
+ {
+ IGitHubClient _github;
+ IGitHubClient _githubAppInstallation;
+
+ public TheGetAllForReferenceMethod()
+ {
+ _github = Helper.GetAuthenticatedClient();
+
+ // Authenticate as a GitHubApp Installation
+ _githubAppInstallation = Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName);
+ }
+
+ [GitHubAppsTest]
+ public async Task GetsAllCheckRuns()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.InProgress
+ };
+ await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckRun);
+
+ // Get the check
+ var request = new CheckRunRequest
+ {
+ CheckName = "name",
+ Status = CheckStatusFilter.InProgress
+ };
+ var checkRuns = await _githubAppInstallation.Check.Run.GetAllForReference(repoContext.RepositoryOwner, repoContext.RepositoryName, featureBranch.Object.Sha, request);
+
+ // Check result
+ Assert.NotEmpty(checkRuns.CheckRuns);
+ foreach (var checkRun in checkRuns.CheckRuns)
+ {
+ Assert.Equal(featureBranch.Object.Sha, checkRun.HeadSha);
+ Assert.Equal("name", checkRun.Name);
+ Assert.Equal(CheckStatus.InProgress, checkRun.Status);
+ }
+ }
+ }
+
+ [GitHubAppsTest]
+ public async Task GetsAllCheckRunsWithRepositoryId()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.InProgress
+ };
+ await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryId, newCheckRun);
+
+ // Get the check
+ var request = new CheckRunRequest
+ {
+ CheckName = "name",
+ Status = CheckStatusFilter.InProgress
+ };
+ var checkRuns = await _githubAppInstallation.Check.Run.GetAllForReference(repoContext.RepositoryId, featureBranch.Object.Sha, request);
+
+ // Check result
+ Assert.NotEmpty(checkRuns.CheckRuns);
+ foreach (var checkRun in checkRuns.CheckRuns)
+ {
+ Assert.Equal(featureBranch.Object.Sha, checkRun.HeadSha);
+ Assert.Equal("name", checkRun.Name);
+ Assert.Equal(CheckStatus.InProgress, checkRun.Status);
+ }
+ }
+ }
+ }
+
+ public class TheGetAllForCheckSuiteMethod
+ {
+ IGitHubClient _github;
+ IGitHubClient _githubAppInstallation;
+
+ public TheGetAllForCheckSuiteMethod()
+ {
+ _github = Helper.GetAuthenticatedClient();
+
+ // Authenticate as a GitHubApp Installation
+ _githubAppInstallation = Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName);
+ }
+
+ [GitHubAppsTest]
+ public async Task GetsAllCheckRuns()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.InProgress
+ };
+ var created = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckRun);
+
+ // Get the check
+ var request = new CheckRunRequest
+ {
+ CheckName = "name",
+ Status = CheckStatusFilter.InProgress
+ };
+
+ var checkRuns = await _githubAppInstallation.Check.Run.GetAllForCheckSuite(repoContext.RepositoryOwner, repoContext.RepositoryName, created.CheckSuite.Id, request);
+
+ // Check result
+ Assert.NotEmpty(checkRuns.CheckRuns);
+ foreach (var checkRun in checkRuns.CheckRuns)
+ {
+ Assert.Equal(featureBranch.Object.Sha, checkRun.HeadSha);
+ Assert.Equal("name", checkRun.Name);
+ Assert.Equal(CheckStatus.InProgress, checkRun.Status);
+ }
+ }
+ }
+
+ [GitHubAppsTest]
+ public async Task GetsAllCheckRunsWithRepositoryId()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.InProgress
+ };
+ var created = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryId, newCheckRun);
+
+ // Get the check
+ var request = new CheckRunRequest
+ {
+ CheckName = "name",
+ Status = CheckStatusFilter.InProgress
+ };
+ var checkRuns = await _githubAppInstallation.Check.Run.GetAllForCheckSuite(repoContext.RepositoryId, created.CheckSuite.Id, request);
+
+ // Check result
+ Assert.NotEmpty(checkRuns.CheckRuns);
+ foreach (var checkRun in checkRuns.CheckRuns)
+ {
+ Assert.Equal(featureBranch.Object.Sha, checkRun.HeadSha);
+ Assert.Equal("name", checkRun.Name);
+ Assert.Equal(CheckStatus.InProgress, checkRun.Status);
+ }
+ }
+ }
+ }
+
+ public class TheGetMethod
+ {
+ IGitHubClient _github;
+ IGitHubClient _githubAppInstallation;
+
+ public TheGetMethod()
+ {
+ _github = Helper.GetAuthenticatedClient();
+
+ // Authenticate as a GitHubApp Installation
+ _githubAppInstallation = Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName);
+ }
+
+ [GitHubAppsTest]
+ public async Task GetsCheckRun()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.InProgress
+ };
+ var created = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckRun);
+
+ // Get the check
+ var checkRun = await _githubAppInstallation.Check.Run.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, created.Id);
+
+ // Check result
+ Assert.Equal(featureBranch.Object.Sha, checkRun.HeadSha);
+ Assert.Equal("name", checkRun.Name);
+ Assert.Equal(CheckStatus.InProgress, checkRun.Status);
+ }
+ }
+
+ [GitHubAppsTest]
+ public async Task GetsCheckRunWithRepositoryId()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.InProgress
+ };
+ var created = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryId, newCheckRun);
+
+ // Get the check
+ var checkRun = await _githubAppInstallation.Check.Run.Get(repoContext.RepositoryId, created.Id);
+
+ // Check result
+ Assert.Equal(featureBranch.Object.Sha, checkRun.HeadSha);
+ Assert.Equal("name", checkRun.Name);
+ Assert.Equal(CheckStatus.InProgress, checkRun.Status);
+ }
+ }
+ }
+
+ public class TheGetAllAnnotationsMethod
+ {
+ IGitHubClient _github;
+ IGitHubClient _githubAppInstallation;
+
+ public TheGetAllAnnotationsMethod()
+ {
+ _github = Helper.GetAuthenticatedClient();
+
+ // Authenticate as a GitHubApp Installation
+ _githubAppInstallation = Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName);
+ }
+
+ [GitHubAppsTest]
+ public async Task GetsAllAnnotations()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.InProgress,
+ Output = new NewCheckRunOutput("title", "summary")
+ {
+ Annotations = new[]
+ {
+ new NewCheckRunAnnotation("file.txt", "blob", 1, 1, CheckWarningLevel.Warning, "this is a warning")
+ }
+ }
+ };
+ var created = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckRun);
+
+ // Get the annotations
+ var annotations = await _githubAppInstallation.Check.Run.GetAllAnnotations(repoContext.RepositoryOwner, repoContext.RepositoryName, created.Id);
+
+ // Check result
+ Assert.Equal(1, annotations.Count);
+ Assert.Equal("this is a warning", annotations.First().Message);
+ Assert.Equal(CheckWarningLevel.Warning, annotations.First().WarningLevel);
+ }
+ }
+
+ [GitHubAppsTest]
+ public async Task GetsAllAnnotationsWithRepositoryId()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.InProgress,
+ Output = new NewCheckRunOutput("title", "summary")
+ {
+ Annotations = new[]
+ {
+ new NewCheckRunAnnotation("file.txt", "blob", 1, 1, CheckWarningLevel.Warning, "this is a warning")
+ }
+ }
+ };
+ var created = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryId, newCheckRun);
+
+ // Get the annotations
+ var annotations = await _githubAppInstallation.Check.Run.GetAllAnnotations(repoContext.RepositoryId, created.Id);
+
+ // Check result
+ Assert.Equal(1, annotations.Count);
+ Assert.Equal("this is a warning", annotations.First().Message);
+ Assert.Equal(CheckWarningLevel.Warning, annotations.First().WarningLevel);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Octokit.Tests.Integration/Reactive/ObservableCheckRunsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableCheckRunsClientTests.cs
new file mode 100644
index 0000000000..7c8352c45f
--- /dev/null
+++ b/Octokit.Tests.Integration/Reactive/ObservableCheckRunsClientTests.cs
@@ -0,0 +1,461 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Reactive.Linq;
+using System.Threading.Tasks;
+using Octokit.Reactive;
+using Octokit.Tests.Integration.Helpers;
+using Xunit;
+
+namespace Octokit.Tests.Integration.Reactive
+{
+ public class ObservableCheckRunsClientTests
+ {
+ public class TheCreateMethod
+ {
+ IObservableGitHubClient _github;
+ IObservableGitHubClient _githubAppInstallation;
+
+ public TheCreateMethod()
+ {
+ _github = new ObservableGitHubClient(Helper.GetAuthenticatedClient());
+
+ // Authenticate as a GitHubApp Installation
+ _githubAppInstallation = new ObservableGitHubClient(Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName));
+ }
+
+ [GitHubAppsTest]
+ public async Task CreatesCheckRun()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.Queued
+ };
+ var result = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckRun);
+
+ // Check result
+ Assert.NotNull(result);
+ Assert.Equal(featureBranch.Object.Sha, result.HeadSha);
+ }
+ }
+
+ [GitHubAppsTest]
+ public async Task CreatesCheckRunWithRepositoryId()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.Queued
+ };
+ var result = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryId, newCheckRun);
+
+ // Check result
+ Assert.NotNull(result);
+ Assert.Equal(featureBranch.Object.Sha, result.HeadSha);
+ }
+ }
+ }
+
+ public class TheUpdateMethod
+ {
+ IObservableGitHubClient _github;
+ IObservableGitHubClient _githubAppInstallation;
+
+ public TheUpdateMethod()
+ {
+ _github = new ObservableGitHubClient(Helper.GetAuthenticatedClient());
+
+ // Authenticate as a GitHubApp Installation
+ _githubAppInstallation = new ObservableGitHubClient(Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName));
+ }
+
+ [GitHubAppsTest]
+ public async Task UpdatesCheckRun()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.Queued
+ };
+ var checkRun = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckRun);
+
+ // Update the check run
+ var update = new CheckRunUpdate("new-name")
+ {
+ Status = CheckStatus.InProgress
+ };
+ var result = await _githubAppInstallation.Check.Run.Update(repoContext.RepositoryOwner, repoContext.RepositoryName, checkRun.Id, update);
+
+ // Check result
+ Assert.NotNull(result);
+ Assert.Equal(featureBranch.Object.Sha, result.HeadSha);
+ Assert.Equal("new-name", result.Name);
+ Assert.Equal(CheckStatus.InProgress, result.Status);
+ }
+ }
+
+ [GitHubAppsTest]
+ public async Task UpdatesCheckRunWithRepositoryId()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.Queued
+ };
+ var checkRun = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryId, newCheckRun);
+
+ // Update the check run
+ var update = new CheckRunUpdate("new-name")
+ {
+ Status = CheckStatus.InProgress
+ };
+ var result = await _githubAppInstallation.Check.Run.Update(repoContext.RepositoryId, checkRun.Id, update);
+
+ // Check result
+ Assert.NotNull(result);
+ Assert.Equal(featureBranch.Object.Sha, result.HeadSha);
+ Assert.Equal("new-name", result.Name);
+ Assert.Equal(CheckStatus.InProgress, result.Status);
+ }
+ }
+ }
+
+ public class TheGetAllForReferenceMethod
+ {
+ IObservableGitHubClient _github;
+ IObservableGitHubClient _githubAppInstallation;
+
+ public TheGetAllForReferenceMethod()
+ {
+ _github = new ObservableGitHubClient(Helper.GetAuthenticatedClient());
+
+ // Authenticate as a GitHubApp Installation
+ _githubAppInstallation = new ObservableGitHubClient(Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName));
+ }
+
+ [GitHubAppsTest]
+ public async Task GetsAllCheckRuns()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.InProgress
+ };
+ await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckRun);
+
+ // Get the check
+ var request = new CheckRunRequest
+ {
+ CheckName = "name",
+ Status = CheckStatusFilter.InProgress
+ };
+ var checkRuns = await _githubAppInstallation.Check.Run.GetAllForReference(repoContext.RepositoryOwner, repoContext.RepositoryName, featureBranch.Object.Sha, request);
+
+ // Check result
+ Assert.NotEmpty(checkRuns.CheckRuns);
+ foreach (var checkRun in checkRuns.CheckRuns)
+ {
+ Assert.Equal(featureBranch.Object.Sha, checkRun.HeadSha);
+ Assert.Equal("name", checkRun.Name);
+ Assert.Equal(CheckStatus.InProgress, checkRun.Status);
+ }
+ }
+ }
+
+ [GitHubAppsTest]
+ public async Task GetsAllCheckRunsWithRepositoryId()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.InProgress
+ };
+ await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryId, newCheckRun);
+
+ // Get the check
+ var request = new CheckRunRequest
+ {
+ CheckName = "name",
+ Status = CheckStatusFilter.InProgress
+ };
+ var checkRuns = await _githubAppInstallation.Check.Run.GetAllForReference(repoContext.RepositoryId, featureBranch.Object.Sha, request);
+
+ // Check result
+ Assert.NotEmpty(checkRuns.CheckRuns);
+ foreach (var checkRun in checkRuns.CheckRuns)
+ {
+ Assert.Equal(featureBranch.Object.Sha, checkRun.HeadSha);
+ Assert.Equal("name", checkRun.Name);
+ Assert.Equal(CheckStatus.InProgress, checkRun.Status);
+ }
+ }
+ }
+ }
+
+ public class TheGetAllForCheckSuiteMethod
+ {
+ IObservableGitHubClient _github;
+ IObservableGitHubClient _githubAppInstallation;
+
+ public TheGetAllForCheckSuiteMethod()
+ {
+ _github = new ObservableGitHubClient(Helper.GetAuthenticatedClient());
+
+ // Authenticate as a GitHubApp Installation
+ _githubAppInstallation = new ObservableGitHubClient(Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName));
+ }
+
+ [GitHubAppsTest]
+ public async Task GetsAllCheckRuns()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.InProgress
+ };
+ var created = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckRun);
+
+ // Get the check
+ var request = new CheckRunRequest
+ {
+ CheckName = "name",
+ Status = CheckStatusFilter.InProgress
+ };
+ var checkRuns = await _githubAppInstallation.Check.Run.GetAllForCheckSuite(repoContext.RepositoryOwner, repoContext.RepositoryName, created.CheckSuite.Id, request);
+
+ // Check result
+ Assert.NotEmpty(checkRuns.CheckRuns);
+ foreach (var checkRun in checkRuns.CheckRuns)
+ {
+ Assert.Equal(featureBranch.Object.Sha, checkRun.HeadSha);
+ Assert.Equal("name", checkRun.Name);
+ Assert.Equal(CheckStatus.InProgress, checkRun.Status);
+ }
+ }
+ }
+
+ [GitHubAppsTest]
+ public async Task GetsAllCheckRunsWithRepositoryId()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.InProgress
+ };
+ var created = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryId, newCheckRun);
+
+ // Get the check
+ var request = new CheckRunRequest
+ {
+ CheckName = "name",
+ Status = CheckStatusFilter.InProgress
+ };
+ var checkRuns = await _githubAppInstallation.Check.Run.GetAllForCheckSuite(repoContext.RepositoryId, created.CheckSuite.Id, request);
+
+ // Check result
+ Assert.NotEmpty(checkRuns.CheckRuns);
+ foreach (var checkRun in checkRuns.CheckRuns)
+ {
+ Assert.Equal(featureBranch.Object.Sha, checkRun.HeadSha);
+ Assert.Equal("name", checkRun.Name);
+ Assert.Equal(CheckStatus.InProgress, checkRun.Status);
+ }
+ }
+ }
+ }
+
+ public class TheGetMethod
+ {
+ IObservableGitHubClient _github;
+ IObservableGitHubClient _githubAppInstallation;
+
+ public TheGetMethod()
+ {
+ _github = new ObservableGitHubClient(Helper.GetAuthenticatedClient());
+
+ // Authenticate as a GitHubApp Installation
+ _githubAppInstallation = new ObservableGitHubClient(Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName));
+ }
+
+ [GitHubAppsTest]
+ public async Task GetsCheckRun()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.InProgress
+ };
+ var created = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckRun);
+
+ // Get the check
+ var checkRun = await _githubAppInstallation.Check.Run.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, created.Id);
+
+ // Check result
+ Assert.Equal(featureBranch.Object.Sha, checkRun.HeadSha);
+ Assert.Equal("name", checkRun.Name);
+ Assert.Equal(CheckStatus.InProgress, checkRun.Status);
+ }
+ }
+
+ [GitHubAppsTest]
+ public async Task GetsCheckRunWithRepositoryId()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.InProgress
+ };
+ var created = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryId, newCheckRun);
+
+ // Get the check
+ var checkRun = await _githubAppInstallation.Check.Run.Get(repoContext.RepositoryId, created.Id);
+
+ // Check result
+ Assert.Equal(featureBranch.Object.Sha, checkRun.HeadSha);
+ Assert.Equal("name", checkRun.Name);
+ Assert.Equal(CheckStatus.InProgress, checkRun.Status);
+ }
+ }
+ }
+
+ public class TheGetAllAnnotationsMethod
+ {
+ IObservableGitHubClient _github;
+ IObservableGitHubClient _githubAppInstallation;
+
+ public TheGetAllAnnotationsMethod()
+ {
+ _github = new ObservableGitHubClient(Helper.GetAuthenticatedClient());
+
+ // Authenticate as a GitHubApp Installation
+ _githubAppInstallation = new ObservableGitHubClient(Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName));
+ }
+
+ [GitHubAppsTest]
+ public async Task GetsAllAnnotations()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.InProgress,
+ Output = new NewCheckRunOutput("title", "summary")
+ {
+ Annotations = new[]
+ {
+ new NewCheckRunAnnotation("file.txt", "blob", 1, 1, CheckWarningLevel.Warning, "this is a warning")
+ }
+ }
+ };
+ var created = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckRun);
+
+ // Get the annotations
+ var annotations = await _githubAppInstallation.Check.Run.GetAllAnnotations(repoContext.RepositoryOwner, repoContext.RepositoryName, created.Id).ToList();
+
+ // Check result
+ Assert.Equal(1, annotations.Count);
+ Assert.Equal("this is a warning", annotations.First().Message);
+ Assert.Equal(CheckWarningLevel.Warning, annotations.First().WarningLevel);
+ }
+ }
+
+ [GitHubAppsTest]
+ public async Task GetsAllAnnotationsWithRepositoryId()
+ {
+ using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true }))
+ {
+ // Create a new feature branch
+ var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master");
+ var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature");
+
+ // Create a check run for the feature branch
+ var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha)
+ {
+ Status = CheckStatus.InProgress,
+ Output = new NewCheckRunOutput("title", "summary")
+ {
+ Annotations = new[]
+ {
+ new NewCheckRunAnnotation("file.txt", "blob", 1, 1, CheckWarningLevel.Warning, "this is a warning")
+ }
+ }
+ };
+ var created = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryId, newCheckRun);
+
+ // Get the annotations
+ var annotations = await _githubAppInstallation.Check.Run.GetAllAnnotations(repoContext.RepositoryId, created.Id).ToList();
+
+ // Check result
+ Assert.Equal(1, annotations.Count);
+ Assert.Equal("this is a warning", annotations.First().Message);
+ Assert.Equal(CheckWarningLevel.Warning, annotations.First().WarningLevel);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Octokit.Tests/Clients/CheckRunsClientTests.cs b/Octokit.Tests/Clients/CheckRunsClientTests.cs
new file mode 100644
index 0000000000..546c9da4e4
--- /dev/null
+++ b/Octokit.Tests/Clients/CheckRunsClientTests.cs
@@ -0,0 +1,631 @@
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using NSubstitute;
+using Xunit;
+
+namespace Octokit.Tests.Clients
+{
+ public class CheckRunsClientTests
+ {
+ public class TheCtor
+ {
+ [Fact]
+ public void EnsuresNonNullArguments()
+ {
+ Assert.Throws(() => new CheckRunsClient(null));
+ }
+ }
+
+ public class TheCreateMethod
+ {
+ [Fact]
+ public async Task RequestsCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var newCheckRun = new NewCheckRun("status", "123abc") { Status = CheckStatus.Queued };
+
+ await client.Create("fake", "repo", newCheckRun);
+
+ connection.Received().Post(
+ Arg.Is(u => u.ToString() == "repos/fake/repo/check-runs"),
+ newCheckRun,
+ "application/vnd.github.antiope-preview+json");
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var newCheckRun = new NewCheckRun("status", "123abc") { Status = CheckStatus.Queued };
+
+ await client.Create(1, newCheckRun);
+
+ connection.Received().Post(
+ Arg.Is(u => u.ToString() == "repositories/1/check-runs"),
+ newCheckRun,
+ "application/vnd.github.antiope-preview+json");
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var newCheckRun = new NewCheckRun("status", "123abc") { Status = CheckStatus.Queued };
+
+ await Assert.ThrowsAsync(() => client.Create(null, "repo", newCheckRun));
+ await Assert.ThrowsAsync(() => client.Create("fake", null, newCheckRun));
+ await Assert.ThrowsAsync(() => client.Create("fake", "repo", null));
+
+ await Assert.ThrowsAsync(() => client.Create(1, null));
+ }
+
+ [Fact]
+ public async Task EnsuresNonEmptyArguments()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var newCheckRun = new NewCheckRun("status", "123abc") { Status = CheckStatus.Queued };
+
+ await Assert.ThrowsAsync(() => client.Create("", "repo", newCheckRun));
+ await Assert.ThrowsAsync(() => client.Create("fake", "", newCheckRun));
+ }
+ }
+
+ public class TheUpdateMethod
+ {
+ [Fact]
+ public async Task RequestsCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var update = new CheckRunUpdate("status") { Status = CheckStatus.InProgress };
+
+ await client.Update("fake", "repo", 1, update);
+
+ connection.Received().Patch(
+ Arg.Is(u => u.ToString() == "repos/fake/repo/check-runs/1"),
+ update,
+ "application/vnd.github.antiope-preview+json");
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var update = new CheckRunUpdate("status") { Status = CheckStatus.InProgress };
+
+ await client.Update(1, 1, update);
+
+ connection.Received().Patch(
+ Arg.Is(u => u.ToString() == "repositories/1/check-runs/1"),
+ update,
+ "application/vnd.github.antiope-preview+json");
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var update = new CheckRunUpdate("status") { Status = CheckStatus.InProgress };
+
+ await Assert.ThrowsAsync(() => client.Update(null, "repo", 1, update));
+ await Assert.ThrowsAsync(() => client.Update("fake", null, 1, update));
+ await Assert.ThrowsAsync(() => client.Update("fake", "repo", 1, null));
+ }
+
+ [Fact]
+ public async Task EnsuresNonEmptyArguments()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var update = new CheckRunUpdate("status") { Status = CheckStatus.InProgress };
+
+ await Assert.ThrowsAsync(() => client.Update("", "repo", 1, update));
+ await Assert.ThrowsAsync(() => client.Update("fake", "", 1, update));
+ }
+ }
+
+ public class TheGetAllForReferenceMethod
+ {
+ [Fact]
+ public async Task RequestsCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ await client.GetAllForReference("fake", "repo", "ref");
+
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "repos/fake/repo/commits/ref/check-runs"),
+ Args.EmptyDictionary,
+ "application/vnd.github.antiope-preview+json",
+ Args.ApiOptions);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ await client.GetAllForReference(1, "ref");
+
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "repositories/1/commits/ref/check-runs"),
+ Args.EmptyDictionary,
+ "application/vnd.github.antiope-preview+json",
+ Args.ApiOptions);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRequest()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var request = new CheckRunRequest { CheckName = "build", Filter = CheckRunCompletedAtFilter.Latest, Status = CheckStatusFilter.InProgress };
+
+ await client.GetAllForReference("fake", "repo", "ref", request);
+
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "repos/fake/repo/commits/ref/check-runs"),
+ Arg.Is>(x =>
+ x.Count == 3
+ && x["check_name"] == "build"
+ && x["status"] == "in_progress"
+ && x["filter"] == "latest"),
+ "application/vnd.github.antiope-preview+json",
+ Args.ApiOptions);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRequestWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var request = new CheckRunRequest { CheckName = "build", Filter = CheckRunCompletedAtFilter.Latest, Status = CheckStatusFilter.InProgress };
+
+ await client.GetAllForReference(1, "ref", request);
+
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "repositories/1/commits/ref/check-runs"),
+ Arg.Is>(x =>
+ x.Count == 3
+ && x["check_name"] == "build"
+ && x["status"] == "in_progress"
+ && x["filter"] == "latest"),
+ "application/vnd.github.antiope-preview+json",
+ Args.ApiOptions);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRequestWithApiOptions()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var request = new CheckRunRequest { CheckName = "build", Filter = CheckRunCompletedAtFilter.Latest, Status = CheckStatusFilter.InProgress };
+ var options = new ApiOptions { PageSize = 1 };
+
+ await client.GetAllForReference("fake", "repo", "ref", request, options);
+
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "repos/fake/repo/commits/ref/check-runs"),
+ Arg.Is>(x =>
+ x.Count == 3
+ && x["check_name"] == "build"
+ && x["status"] == "in_progress"
+ && x["filter"] == "latest"),
+ "application/vnd.github.antiope-preview+json",
+ options);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRequestWithApiOptionsWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var request = new CheckRunRequest { CheckName = "build", Filter = CheckRunCompletedAtFilter.Latest, Status = CheckStatusFilter.InProgress };
+ var options = new ApiOptions { PageSize = 1 };
+
+ await client.GetAllForReference(1, "ref", request, options);
+
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "repositories/1/commits/ref/check-runs"),
+ Arg.Is>(x =>
+ x.Count == 3
+ && x["check_name"] == "build"
+ && x["status"] == "in_progress"
+ && x["filter"] == "latest"),
+ "application/vnd.github.antiope-preview+json",
+ options);
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var request = new CheckRunRequest { CheckName = "build" };
+
+ await Assert.ThrowsAsync(() => client.GetAllForReference(null, "repo", "ref"));
+ await Assert.ThrowsAsync(() => client.GetAllForReference("fake", null, "ref"));
+ await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "repo", null));
+
+ await Assert.ThrowsAsync(() => client.GetAllForReference(null, "repo", "ref", request));
+ await Assert.ThrowsAsync(() => client.GetAllForReference("fake", null, "ref", request));
+ await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "repo", null, request));
+ await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "repo", "ref", null));
+
+ await Assert.ThrowsAsync(() => client.GetAllForReference(null, "repo", "ref", request, ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForReference("fake", null, "ref", request, ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "repo", null, request, ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "repo", "ref", null, ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "repo", "ref", request, null));
+
+ await Assert.ThrowsAsync(() => client.GetAllForReference(1, null));
+
+ await Assert.ThrowsAsync(() => client.GetAllForReference(1, null, request));
+ await Assert.ThrowsAsync(() => client.GetAllForReference(1, "ref", null));
+
+ await Assert.ThrowsAsync(() => client.GetAllForReference(1, null, request, ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForReference(1, "ref", null, ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForReference(1, "ref", request, null));
+ }
+
+ [Fact]
+ public async Task EnsuresNonEmptyArguments()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var request = new CheckRunRequest { CheckName = "build" };
+
+ await Assert.ThrowsAsync(() => client.GetAllForReference("", "repo", "ref"));
+ await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "", "ref"));
+ await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "repo", ""));
+
+ await Assert.ThrowsAsync(() => client.GetAllForReference("", "repo", "ref", request));
+ await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "", "ref", request));
+ await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "repo", "", request));
+
+ await Assert.ThrowsAsync(() => client.GetAllForReference("", "repo", "ref", request, ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "", "ref", request, ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "repo", "", request, ApiOptions.None));
+
+ await Assert.ThrowsAsync(() => client.GetAllForReference(1, ""));
+
+ await Assert.ThrowsAsync(() => client.GetAllForReference(1, "", request));
+
+ await Assert.ThrowsAsync(() => client.GetAllForReference(1, "", request, ApiOptions.None));
+ }
+ }
+
+ public class TheGetAllForCheckSuiteMethod
+ {
+ [Fact]
+ public async Task RequestsCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ await client.GetAllForCheckSuite("fake", "repo", 1);
+
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "repos/fake/repo/check-suites/1/check-runs"),
+ Args.EmptyDictionary,
+ "application/vnd.github.antiope-preview+json",
+ Args.ApiOptions);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ await client.GetAllForCheckSuite(1, 1);
+
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "repositories/1/check-suites/1/check-runs"),
+ Args.EmptyDictionary,
+ "application/vnd.github.antiope-preview+json",
+ Args.ApiOptions);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRequest()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var request = new CheckRunRequest { CheckName = "build", Filter = CheckRunCompletedAtFilter.Latest, Status = CheckStatusFilter.InProgress };
+
+ await client.GetAllForCheckSuite("fake", "repo", 1, request);
+
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "repos/fake/repo/check-suites/1/check-runs"),
+ Arg.Is>(x =>
+ x.Count == 3
+ && x["check_name"] == "build"
+ && x["status"] == "in_progress"
+ && x["filter"] == "latest"),
+ "application/vnd.github.antiope-preview+json",
+ Args.ApiOptions);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRequestWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var request = new CheckRunRequest { CheckName = "build", Filter = CheckRunCompletedAtFilter.Latest, Status = CheckStatusFilter.InProgress };
+
+ await client.GetAllForCheckSuite(1, 1, request);
+
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "repositories/1/check-suites/1/check-runs"),
+ Arg.Is>(x =>
+ x.Count == 3
+ && x["check_name"] == "build"
+ && x["status"] == "in_progress"
+ && x["filter"] == "latest"),
+ "application/vnd.github.antiope-preview+json",
+ Args.ApiOptions);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRequestWithApiOptions()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var request = new CheckRunRequest { CheckName = "build", Filter = CheckRunCompletedAtFilter.Latest, Status = CheckStatusFilter.InProgress };
+ var options = new ApiOptions { PageSize = 1 };
+
+ await client.GetAllForCheckSuite("fake", "repo", 1, request, options);
+
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "repos/fake/repo/check-suites/1/check-runs"),
+ Arg.Is>(x =>
+ x.Count == 3
+ && x["check_name"] == "build"
+ && x["status"] == "in_progress"
+ && x["filter"] == "latest"),
+ "application/vnd.github.antiope-preview+json",
+ options);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRequestWithApiOptionsWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var request = new CheckRunRequest { CheckName = "build", Filter = CheckRunCompletedAtFilter.Latest, Status = CheckStatusFilter.InProgress };
+ var options = new ApiOptions { PageSize = 1 };
+
+ await client.GetAllForCheckSuite(1, 1, request, options);
+
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "repositories/1/check-suites/1/check-runs"),
+ Arg.Is>(x =>
+ x.Count == 3
+ && x["check_name"] == "build"
+ && x["status"] == "in_progress"
+ && x["filter"] == "latest"),
+ "application/vnd.github.antiope-preview+json",
+ options);
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var request = new CheckRunRequest { CheckName = "build" };
+
+ await Assert.ThrowsAsync(() => client.GetAllForCheckSuite(null, "repo", 1));
+ await Assert.ThrowsAsync(() => client.GetAllForCheckSuite("fake", null, 1));
+
+ await Assert.ThrowsAsync(() => client.GetAllForCheckSuite(null, "repo", 1, request));
+ await Assert.ThrowsAsync(() => client.GetAllForCheckSuite("fake", null, 1, request));
+ await Assert.ThrowsAsync(() => client.GetAllForCheckSuite("fake", "repo", 1, null));
+
+ await Assert.ThrowsAsync(() => client.GetAllForCheckSuite(null, "repo", 1, request, ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForCheckSuite("fake", null, 1, request, ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForCheckSuite("fake", "repo", 1, null, ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForCheckSuite("fake", "repo", 1, request, null));
+
+ await Assert.ThrowsAsync(() => client.GetAllForCheckSuite(1, 1, null));
+
+ await Assert.ThrowsAsync(() => client.GetAllForCheckSuite(1, 1, null, ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForCheckSuite(1, 1, request, null));
+ }
+
+ [Fact]
+ public async Task EnsuresNonEmptyArguments()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var request = new CheckRunRequest { CheckName = "build" };
+
+ await Assert.ThrowsAsync(() => client.GetAllForCheckSuite("", "repo", 1));
+ await Assert.ThrowsAsync(() => client.GetAllForCheckSuite("fake", "", 1));
+
+ await Assert.ThrowsAsync(() => client.GetAllForCheckSuite("", "repo", 1, request));
+ await Assert.ThrowsAsync(() => client.GetAllForCheckSuite("fake", "", 1, request));
+
+ await Assert.ThrowsAsync(() => client.GetAllForCheckSuite("", "repo", 1, request, ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForCheckSuite("fake", "", 1, request, ApiOptions.None));
+ }
+ }
+
+ public class TheGetMethod
+ {
+ [Fact]
+ public async Task RequestsCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ await client.Get("fake", "repo", 1);
+
+ connection.Received().Get(
+ Arg.Is(u => u.ToString() == "repos/fake/repo/check-runs/1"),
+ null,
+ "application/vnd.github.antiope-preview+json");
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ await client.Get(1, 1);
+
+ connection.Received().Get(
+ Arg.Is(u => u.ToString() == "repositories/1/check-runs/1"),
+ null,
+ "application/vnd.github.antiope-preview+json");
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ await Assert.ThrowsAsync(() => client.Get(null, "repo", 1));
+ await Assert.ThrowsAsync(() => client.Get("fake", null, 1));
+ }
+
+ [Fact]
+ public async Task EnsuresNonEmptyArguments()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ await Assert.ThrowsAsync(() => client.Get("", "repo", 1));
+ await Assert.ThrowsAsync(() => client.Get("fake", "", 1));
+ }
+ }
+
+ public class TheGetAllAnnotationsMethod
+ {
+ [Fact]
+ public async Task RequestsCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ await client.GetAllAnnotations("fake", "repo", 1);
+
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "repos/fake/repo/check-runs/1/annotations"),
+ null,
+ "application/vnd.github.antiope-preview+json",
+ Args.ApiOptions);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ await client.GetAllAnnotations(1, 1);
+
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "repositories/1/check-runs/1/annotations"),
+ null,
+ "application/vnd.github.antiope-preview+json",
+ Args.ApiOptions);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithApiOptions()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var options = new ApiOptions { PageSize = 1 };
+
+ await client.GetAllAnnotations("fake", "repo", 1, options);
+
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "repos/fake/repo/check-runs/1/annotations"),
+ null,
+ "application/vnd.github.antiope-preview+json",
+ options);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ var options = new ApiOptions { PageSize = 1 };
+
+ await client.GetAllAnnotations(1, 1, options);
+
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "repositories/1/check-runs/1/annotations"),
+ null,
+ "application/vnd.github.antiope-preview+json",
+ options);
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ await Assert.ThrowsAsync(() => client.GetAllAnnotations(null, "repo", 1));
+ await Assert.ThrowsAsync(() => client.GetAllAnnotations("fake", null, 1));
+
+ await Assert.ThrowsAsync(() => client.GetAllAnnotations(null, "repo", 1, ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllAnnotations("fake", null, 1, ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllAnnotations("fake", "repo", 1, null));
+
+ await Assert.ThrowsAsync(() => client.GetAllAnnotations(1, 1, null));
+ }
+
+ [Fact]
+ public async Task EnsuresNonEmptyArguments()
+ {
+ var connection = Substitute.For();
+ var client = new CheckRunsClient(connection);
+
+ await Assert.ThrowsAsync(() => client.GetAllAnnotations("", "repo", 1));
+ await Assert.ThrowsAsync(() => client.GetAllAnnotations("fake", "", 1));
+
+ await Assert.ThrowsAsync(() => client.GetAllAnnotations("", "repo", 1, ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllAnnotations("fake", "", 1, ApiOptions.None));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Octokit.Tests/Clients/EventsClientTests.cs b/Octokit.Tests/Clients/EventsClientTests.cs
index 3c9a79d2ac..99a65a7cd4 100644
--- a/Octokit.Tests/Clients/EventsClientTests.cs
+++ b/Octokit.Tests/Clients/EventsClientTests.cs
@@ -553,6 +553,7 @@ public async Task EnsuresNonNullArguments()
private readonly Dictionary _activityTypes = new Dictionary
{
+ {"CheckRunEvent", typeof(CheckRunEventPayload)},
{"CheckSuiteEvent", typeof(CheckSuiteEventPayload)},
{"CommitCommentEvent", typeof(CommitCommentPayload)},
{"ForkEvent", typeof(ForkEventPayload)},
diff --git a/Octokit.Tests/Models/CheckRunEventTests.cs b/Octokit.Tests/Models/CheckRunEventTests.cs
new file mode 100644
index 0000000000..1038fda9f1
--- /dev/null
+++ b/Octokit.Tests/Models/CheckRunEventTests.cs
@@ -0,0 +1,256 @@
+using Octokit.Internal;
+using Xunit;
+
+namespace Octokit.Tests.Models
+{
+ public class CheckRunEventTests
+ {
+ [Fact]
+ public void CanBeDeserialized()
+ {
+ const string json = @"{
+ ""action"": ""rerequested"",
+ ""check_run"": {
+ ""id"": 4,
+ ""head_sha"": ""d6fde92930d4715a2b49857d24b940956b26d2d3"",
+ ""external_id"": """",
+ ""url"": ""https://api.github.com/repos/github/hello-world/check-runs/4"",
+ ""html_url"": ""http://github.com/github/hello-world/runs/4"",
+ ""status"": ""completed"",
+ ""conclusion"": ""neutral"",
+ ""started_at"": ""2018-05-04T01:14:52Z"",
+ ""completed_at"": ""2018-05-04T01:14:52Z"",
+ ""output"": {
+ ""title"": ""Report"",
+ ""summary"": ""It's all good."",
+ ""text"": ""Minus odio facilis repudiandae. Soluta odit aut amet magni nobis. Et voluptatibus ex dolorem et eum."",
+ ""annotations_count"": 2,
+ ""annotations_url"": ""https://api.github.com/repos/github/hello-world/check-runs/4/annotations""
+ },
+ ""name"": ""randscape"",
+ ""check_suite"": {
+ ""id"": 5,
+ ""head_branch"": ""master"",
+ ""head_sha"": ""d6fde92930d4715a2b49857d24b940956b26d2d3"",
+ ""status"": ""completed"",
+ ""conclusion"": ""neutral"",
+ ""url"": ""https://api.github.com/repos/github/hello-world/check-suites/5"",
+ ""before"": ""146e867f55c26428e5f9fade55a9bbf5e95a7912"",
+ ""after"": ""d6fde92930d4715a2b49857d24b940956b26d2d3"",
+ ""pull_requests"": [
+
+ ],
+ ""app"": {
+ ""id"": 2,
+ ""node_id"": ""MDExOkludGVncmF0aW9uMQ=="",
+ ""owner"": {
+ ""login"": ""github"",
+ ""id"": 340,
+ ""node_id"": ""MDEyOk9yZ2FuaXphdGlvbjE="",
+ ""avatar_url"": ""http://alambic.github.com/avatars/u/340?"",
+ ""gravatar_id"": """",
+ ""url"": ""https://api.github.com/users/github"",
+ ""html_url"": ""http://github.com/github"",
+ ""followers_url"": ""https://api.github.com/users/github/followers"",
+ ""following_url"": ""https://api.github.com/users/github/following{/other_user}"",
+ ""gists_url"": ""https://api.github.com/users/github/gists{/gist_id}"",
+ ""starred_url"": ""https://api.github.com/users/github/starred{/owner}{/repo}"",
+ ""subscriptions_url"": ""https://api.github.com/users/github/subscriptions"",
+ ""organizations_url"": ""https://api.github.com/users/github/orgs"",
+ ""repos_url"": ""https://api.github.com/users/github/repos"",
+ ""events_url"": ""https://api.github.com/users/github/events{/privacy}"",
+ ""received_events_url"": ""https://api.github.com/users/github/received_events"",
+ ""type"": ""Organization"",
+ ""site_admin"": false
+ },
+ ""name"": ""Super Duper"",
+ ""description"": null,
+ ""external_url"": ""http://super-duper.example.com"",
+ ""html_url"": ""http://github.com/apps/super-duper"",
+ ""created_at"": ""2018-04-25T20:42:10Z"",
+ ""updated_at"": ""2018-04-25T20:42:10Z""
+ },
+ ""created_at"": ""2018-05-04T01:14:52Z"",
+ ""updated_at"": ""2018-05-04T01:14:52Z""
+ },
+ ""app"": {
+ ""id"": 2,
+ ""node_id"": ""MDExOkludGVncmF0aW9uMQ=="",
+ ""owner"": {
+ ""login"": ""github"",
+ ""id"": 340,
+ ""node_id"": ""MDEyOk9yZ2FuaXphdGlvbjE="",
+ ""avatar_url"": ""http://alambic.github.com/avatars/u/340?"",
+ ""gravatar_id"": """",
+ ""url"": ""https://api.github.com/users/github"",
+ ""html_url"": ""http://github.com/github"",
+ ""followers_url"": ""https://api.github.com/users/github/followers"",
+ ""following_url"": ""https://api.github.com/users/github/following{/other_user}"",
+ ""gists_url"": ""https://api.github.com/users/github/gists{/gist_id}"",
+ ""starred_url"": ""https://api.github.com/users/github/starred{/owner}{/repo}"",
+ ""subscriptions_url"": ""https://api.github.com/users/github/subscriptions"",
+ ""organizations_url"": ""https://api.github.com/users/github/orgs"",
+ ""repos_url"": ""https://api.github.com/users/github/repos"",
+ ""events_url"": ""https://api.github.com/users/github/events{/privacy}"",
+ ""received_events_url"": ""https://api.github.com/users/github/received_events"",
+ ""type"": ""Organization"",
+ ""site_admin"": false
+ },
+ ""name"": ""Super Duper"",
+ ""description"": null,
+ ""external_url"": ""http://super-duper.example.com"",
+ ""html_url"": ""http://github.com/apps/super-duper"",
+ ""created_at"": ""2018-04-25T20:42:10Z"",
+ ""updated_at"": ""2018-04-25T20:42:10Z""
+ },
+ ""pull_requests"": [
+
+ ]
+ },
+ ""repository"": {
+ ""id"": 526,
+ ""node_id"": ""MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM="",
+ ""name"": ""hello-world"",
+ ""full_name"": ""github/hello-world"",
+ ""owner"": {
+ ""login"": ""github"",
+ ""id"": 340,
+ ""node_id"": ""MDQ6VXNlcjIxMDMxMDY3"",
+ ""avatar_url"": ""http://alambic.github.com/avatars/u/340?"",
+ ""gravatar_id"": """",
+ ""url"": ""https://api.github.com/users/github"",
+ ""html_url"": ""http://github.com/github"",
+ ""followers_url"": ""https://api.github.com/users/github/followers"",
+ ""following_url"": ""https://api.github.com/users/github/following{/other_user}"",
+ ""gists_url"": ""https://api.github.com/users/github/gists{/gist_id}"",
+ ""starred_url"": ""https://api.github.com/users/github/starred{/owner}{/repo}"",
+ ""subscriptions_url"": ""https://api.github.com/users/github/subscriptions"",
+ ""organizations_url"": ""https://api.github.com/users/github/orgs"",
+ ""repos_url"": ""https://api.github.com/users/github/repos"",
+ ""events_url"": ""https://api.github.com/users/github/events{/privacy}"",
+ ""received_events_url"": ""https://api.github.com/users/github/received_events"",
+ ""type"": ""Organization"",
+ ""site_admin"": false
+ },
+ ""private"": false,
+ ""html_url"": ""http://github.com/github/hello-world"",
+ ""description"": null,
+ ""fork"": false,
+ ""url"": ""https://api.github.com/repos/github/hello-world"",
+ ""forks_url"": ""https://api.github.com/repos/github/hello-world/forks"",
+ ""keys_url"": ""https://api.github.com/repos/github/hello-world/keys{/key_id}"",
+ ""collaborators_url"": ""https://api.github.com/repos/github/hello-world/collaborators{/collaborator}"",
+ ""teams_url"": ""https://api.github.com/repos/github/hello-world/teams"",
+ ""hooks_url"": ""https://api.github.com/repos/github/hello-world/hooks"",
+ ""issue_events_url"": ""https://api.github.com/repos/github/hello-world/issues/events{/number}"",
+ ""events_url"": ""https://api.github.com/repos/github/hello-world/events"",
+ ""assignees_url"": ""https://api.github.com/repos/github/hello-world/assignees{/user}"",
+ ""branches_url"": ""https://api.github.com/repos/github/hello-world/branches{/branch}"",
+ ""tags_url"": ""https://api.github.com/repos/github/hello-world/tags"",
+ ""blobs_url"": ""https://api.github.com/repos/github/hello-world/git/blobs{/sha}"",
+ ""git_tags_url"": ""https://api.github.com/repos/github/hello-world/git/tags{/sha}"",
+ ""git_refs_url"": ""https://api.github.com/repos/github/hello-world/git/refs{/sha}"",
+ ""trees_url"": ""https://api.github.com/repos/github/hello-world/git/trees{/sha}"",
+ ""statuses_url"": ""https://api.github.com/repos/github/hello-world/statuses/{sha}"",
+ ""languages_url"": ""https://api.github.com/repos/github/hello-world/languages"",
+ ""stargazers_url"": ""https://api.github.com/repos/github/hello-world/stargazers"",
+ ""contributors_url"": ""https://api.github.com/repos/github/hello-world/contributors"",
+ ""subscribers_url"": ""https://api.github.com/repos/github/hello-world/subscribers"",
+ ""subscription_url"": ""https://api.github.com/repos/github/hello-world/subscription"",
+ ""commits_url"": ""https://api.github.com/repos/github/hello-world/commits{/sha}"",
+ ""git_commits_url"": ""https://api.github.com/repos/github/hello-world/git/commits{/sha}"",
+ ""comments_url"": ""https://api.github.com/repos/github/hello-world/comments{/number}"",
+ ""issue_comment_url"": ""https://api.github.com/repos/github/hello-world/issues/comments{/number}"",
+ ""contents_url"": ""https://api.github.com/repos/github/hello-world/contents/{+path}"",
+ ""compare_url"": ""https://api.github.com/repos/github/hello-world/compare/{base}...{head}"",
+ ""merges_url"": ""https://api.github.com/repos/github/hello-world/merges"",
+ ""archive_url"": ""https://api.github.com/repos/github/hello-world/{archive_format}{/ref}"",
+ ""downloads_url"": ""https://api.github.com/repos/github/hello-world/downloads"",
+ ""issues_url"": ""https://api.github.com/repos/github/hello-world/issues{/number}"",
+ ""pulls_url"": ""https://api.github.com/repos/github/hello-world/pulls{/number}"",
+ ""milestones_url"": ""https://api.github.com/repos/github/hello-world/milestones{/number}"",
+ ""notifications_url"": ""https://api.github.com/repos/github/hello-world/notifications{?since,all,participating}"",
+ ""labels_url"": ""https://api.github.com/repos/github/hello-world/labels{/name}"",
+ ""releases_url"": ""https://api.github.com/repos/github/hello-world/releases{/id}"",
+ ""deployments_url"": ""https://api.github.com/repos/github/hello-world/deployments"",
+ ""created_at"": ""2018-04-25T20:42:10Z"",
+ ""updated_at"": ""2018-04-25T20:43:34Z"",
+ ""pushed_at"": ""2018-05-04T01:14:47Z"",
+ ""git_url"": ""git://github.com/github/hello-world.git"",
+ ""ssh_url"": ""ssh://git@localhost:3035/github/hello-world.git"",
+ ""clone_url"": ""http://github.com/github/hello-world.git"",
+ ""svn_url"": ""http://github.com/github/hello-world"",
+ ""homepage"": null,
+ ""size"": 0,
+ ""stargazers_count"": 0,
+ ""watchers_count"": 0,
+ ""language"": null,
+ ""has_issues"": true,
+ ""has_projects"": true,
+ ""has_downloads"": true,
+ ""has_wiki"": true,
+ ""has_pages"": false,
+ ""forks_count"": 0,
+ ""mirror_url"": null,
+ ""archived"": false,
+ ""open_issues_count"": 3,
+ ""license"": null,
+ ""forks"": 0,
+ ""open_issues"": 3,
+ ""watchers"": 0,
+ ""default_branch"": ""master""
+ },
+ ""organization"": {
+ ""login"": ""github"",
+ ""id"": 340,
+ ""node_id"": ""MDEyOk9yZ2FuaXphdGlvbjM4MzAyODk5"",
+ ""url"": ""https://api.github.com/orgs/github"",
+ ""repos_url"": ""https://api.github.com/orgs/github/repos"",
+ ""events_url"": ""https://api.github.com/orgs/github/events"",
+ ""hooks_url"": ""https://api.github.com/orgs/github/hooks"",
+ ""issues_url"": ""https://api.github.com/orgs/github/issues"",
+ ""members_url"": ""https://api.github.com/orgs/github/members{/member}"",
+ ""public_members_url"": ""https://api.github.com/orgs/github/public_members{/member}"",
+ ""avatar_url"": ""http://alambic.github.com/avatars/u/340?"",
+ ""description"": ""How people build software.""
+ },
+ ""sender"": {
+ ""login"": ""octocat"",
+ ""id"": 5346,
+ ""node_id"": ""MDQ6VXNlcjIxMDMxMDY3"",
+ ""avatar_url"": ""http://alambic.github.com/avatars/u/5346?"",
+ ""gravatar_id"": """",
+ ""url"": ""https://api.github.com/users/octocat"",
+ ""html_url"": ""http://github.com/octocat"",
+ ""followers_url"": ""https://api.github.com/users/octocat/followers"",
+ ""following_url"": ""https://api.github.com/users/octocat/following{/other_user}"",
+ ""gists_url"": ""https://api.github.com/users/octocat/gists{/gist_id}"",
+ ""starred_url"": ""https://api.github.com/users/octocat/starred{/owner}{/repo}"",
+ ""subscriptions_url"": ""https://api.github.com/users/octocat/subscriptions"",
+ ""organizations_url"": ""https://api.github.com/users/octocat/orgs"",
+ ""repos_url"": ""https://api.github.com/users/octocat/repos"",
+ ""events_url"": ""https://api.github.com/users/octocat/events{/privacy}"",
+ ""received_events_url"": ""https://api.github.com/users/octocat/received_events"",
+ ""type"": ""User"",
+ ""site_admin"": false
+ },
+ ""installation"": {
+ ""id"": 1
+ }
+}";
+
+ var serializer = new SimpleJsonSerializer();
+
+ var payload = serializer.Deserialize(json);
+
+ Assert.Equal("rerequested", payload.Action);
+ Assert.Equal("d6fde92930d4715a2b49857d24b940956b26d2d3", payload.CheckRun.HeadSha);
+ Assert.Equal(4, payload.CheckRun.Id);
+ Assert.Equal(CheckStatus.Completed, payload.CheckRun.Status);
+ Assert.Equal(CheckConclusion.Neutral, payload.CheckRun.Conclusion);
+ Assert.Equal(5, payload.CheckRun.CheckSuite.Id);
+ Assert.Equal(CheckStatus.Completed, payload.CheckRun.CheckSuite.Status.Value);
+ Assert.Equal(CheckConclusion.Neutral, payload.CheckRun.CheckSuite.Conclusion);
+ }
+ }
+}
diff --git a/Octokit.Tests/Reactive/ObservableCheckRunsClientTests.cs b/Octokit.Tests/Reactive/ObservableCheckRunsClientTests.cs
new file mode 100644
index 0000000000..8391353e4e
--- /dev/null
+++ b/Octokit.Tests/Reactive/ObservableCheckRunsClientTests.cs
@@ -0,0 +1,622 @@
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using NSubstitute;
+using Octokit.Reactive;
+using Xunit;
+
+namespace Octokit.Tests.Clients
+{
+ public class ObservableCheckRunsClientTests
+ {
+ public class TheCtor
+ {
+ [Fact]
+ public void EnsuresNonNullArguments()
+ {
+ Assert.Throws(() => new ObservableCheckRunsClient(null));
+ }
+ }
+
+ public class TheCreateMethod
+ {
+ [Fact]
+ public async Task RequestsCorrectUrl()
+ {
+ var gitHubClient = Substitute.For();
+ var client = new ObservableCheckRunsClient(gitHubClient);
+
+ var newCheckRun = new NewCheckRun("status", "123abc") { Status = CheckStatus.Queued };
+
+ client.Create("fake", "repo", newCheckRun);
+
+ gitHubClient.Check.Run.Received().Create("fake", "repo", newCheckRun);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRepositoryId()
+ {
+ var gitHubClient = Substitute.For();
+ var client = new ObservableCheckRunsClient(gitHubClient);
+
+ var newCheckRun = new NewCheckRun("status", "123abc") { Status = CheckStatus.Queued };
+
+ client.Create(1, newCheckRun);
+
+ gitHubClient.Check.Run.Received().Create(1, newCheckRun);
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var gitHubClient = Substitute.For();
+ var client = new ObservableCheckRunsClient(gitHubClient);
+
+ var newCheckRun = new NewCheckRun("status", "123abc") { Status = CheckStatus.Queued };
+
+ Assert.Throws(() => client.Create(null, "repo", newCheckRun));
+ Assert.Throws(() => client.Create("fake", null, newCheckRun));
+ Assert.Throws(() => client.Create("fake", "repo", null));
+
+ Assert.Throws(() => client.Create(1, null));
+ }
+
+ [Fact]
+ public async Task EnsuresNonEmptyArguments()
+ {
+ var gitHubClient = Substitute.For();
+ var client = new ObservableCheckRunsClient(gitHubClient);
+
+ var newCheckRun = new NewCheckRun("status", "123abc") { Status = CheckStatus.Queued };
+
+ Assert.Throws(() => client.Create("", "repo", newCheckRun));
+ Assert.Throws(() => client.Create("fake", "", newCheckRun));
+ }
+ }
+
+ public class TheUpdateMethod
+ {
+ [Fact]
+ public async Task RequestsCorrectUrl()
+ {
+ var gitHubClient = Substitute.For();
+ var client = new ObservableCheckRunsClient(gitHubClient);
+
+ var update = new CheckRunUpdate("status") { Status = CheckStatus.InProgress };
+
+ client.Update("fake", "repo", 1, update);
+
+ gitHubClient.Check.Run.Received().Update("fake", "repo", 1, update);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRepositoryId()
+ {
+ var gitHubClient = Substitute.For();
+ var client = new ObservableCheckRunsClient(gitHubClient);
+
+ var update = new CheckRunUpdate("status") { Status = CheckStatus.InProgress };
+
+ client.Update(1, 1, update);
+
+ gitHubClient.Check.Run.Received().Update(1, 1, update);
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var gitHubClient = Substitute.For();
+ var client = new ObservableCheckRunsClient(gitHubClient);
+
+ var update = new CheckRunUpdate("status") { Status = CheckStatus.InProgress };
+
+ Assert.Throws(() => client.Update(null, "repo", 1, update));
+ Assert.Throws(() => client.Update("fake", null, 1, update));
+ Assert.Throws(() => client.Update("fake", "repo", 1, null));
+ }
+
+ [Fact]
+ public async Task EnsuresNonEmptyArguments()
+ {
+ var gitHubClient = Substitute.For();
+ var client = new ObservableCheckRunsClient(gitHubClient);
+
+ var update = new CheckRunUpdate("status") { Status = CheckStatus.InProgress };
+
+ Assert.Throws(() => client.Update("", "repo", 1, update));
+ Assert.Throws(() => client.Update("fake", "", 1, update));
+ }
+ }
+
+ public class TheGetAllForReferenceMethod
+ {
+ [Fact]
+ public async Task RequestsCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var gitHubClient = new GitHubClient(connection);
+ var client = new ObservableCheckRunsClient(gitHubClient);
+
+ client.GetAllForReference("fake", "repo", "ref");
+
+ connection.Received().Get>(
+ Arg.Is(u => u.ToString() == "repos/fake/repo/commits/ref/check-runs"),
+ Args.EmptyDictionary,
+ "application/vnd.github.antiope-preview+json");
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var gitHubClient = new GitHubClient(connection);
+ var client = new ObservableCheckRunsClient(gitHubClient);
+
+ client.GetAllForReference(1, "ref");
+
+ connection.Received().Get>(
+ Arg.Is(u => u.ToString() == "repositories/1/commits/ref/check-runs"),
+ Args.EmptyDictionary,
+ "application/vnd.github.antiope-preview+json");
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRequest()
+ {
+ var connection = Substitute.For();
+ var gitHubClient = new GitHubClient(connection);
+ var client = new ObservableCheckRunsClient(gitHubClient);
+
+ var request = new CheckRunRequest { CheckName = "build", Filter = CheckRunCompletedAtFilter.Latest, Status = CheckStatusFilter.InProgress };
+
+ client.GetAllForReference("fake", "repo", "ref", request);
+
+ connection.Received().Get>(
+ Arg.Is(u => u.ToString() == "repos/fake/repo/commits/ref/check-runs"),
+ Arg.Is>(x =>
+ x.Count == 3
+ && x["check_name"] == "build"
+ && x["status"] == "in_progress"
+ && x["filter"] == "latest"),
+ "application/vnd.github.antiope-preview+json");
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRequestWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var gitHubClient = new GitHubClient(connection);
+ var client = new ObservableCheckRunsClient(gitHubClient);
+
+ var request = new CheckRunRequest { CheckName = "build", Filter = CheckRunCompletedAtFilter.Latest, Status = CheckStatusFilter.InProgress };
+
+ client.GetAllForReference(1, "ref", request);
+
+ connection.Received().Get>(
+ Arg.Is(u => u.ToString() == "repositories/1/commits/ref/check-runs"),
+ Arg.Is>(x =>
+ x.Count == 3
+ && x["check_name"] == "build"
+ && x["status"] == "in_progress"
+ && x["filter"] == "latest"),
+ "application/vnd.github.antiope-preview+json");
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRequestWithApiOptions()
+ {
+ var connection = Substitute.For();
+ var gitHubClient = new GitHubClient(connection);
+ var client = new ObservableCheckRunsClient(gitHubClient);
+
+ var request = new CheckRunRequest { CheckName = "build", Filter = CheckRunCompletedAtFilter.Latest, Status = CheckStatusFilter.InProgress };
+ var options = new ApiOptions { PageSize = 1 };
+
+ client.GetAllForReference("fake", "repo", "ref", request, options);
+
+ connection.Received().Get>(
+ Arg.Is(u => u.ToString() == "repos/fake/repo/commits/ref/check-runs"),
+ Arg.Is>(x =>
+ x.Count == 4
+ && x["per_page"] == "1"
+ && x["check_name"] == "build"
+ && x["status"] == "in_progress"
+ && x["filter"] == "latest"),
+ "application/vnd.github.antiope-preview+json");
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRequestWithApiOptionsWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var gitHubClient = new GitHubClient(connection);
+ var client = new ObservableCheckRunsClient(gitHubClient);
+
+ var request = new CheckRunRequest { CheckName = "build", Filter = CheckRunCompletedAtFilter.Latest, Status = CheckStatusFilter.InProgress };
+ var options = new ApiOptions { PageSize = 1 };
+
+ client.GetAllForReference(1, "ref", request, options);
+
+ connection.Received().Get>(
+ Arg.Is(u => u.ToString() == "repositories/1/commits/ref/check-runs"),
+ Arg.Is