diff --git a/.travis.yml b/.travis.yml index cc3ced7c..5acd1c06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,6 @@ os: - osx - linux install: - - curl -sS http://storage.bos.xamarin.com/bot-provisioning/PortableReferenceAssemblies-2014-04-14.zip > /tmp/pcl-assemblies.zip - - unzip /tmp/pcl-assemblies.zip -d /tmp/pcl-assemblies && mv /tmp/pcl-assemblies/PortableReferenceAssemblies-2014-04-14 /tmp/pcl-assemblies/.NETPortable - - export XBUILD_FRAMEWORK_FOLDERS_PATH=/tmp/pcl-assemblies/ - nuget restore Octokit-Mono.sln script: - mono tools/nuget/NuGet.exe restore Octokit-Mono.sln diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 64a9bb71..f55ffc71 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -123,7 +123,7 @@ flagged as a spammer. ### Testing Documentation If you are making changes to the documentation for Octokit, you can test these -changes locally using the [guide](https://github.com/shiftkey/octokit.net/blob/rewrite-contributing/docs/contributing.md) +changes locally using the [guide](https://github.com/octokit/octokit.net/blob/master/docs/contributing.md) under the `docs` folder. ### Submitting Changes diff --git a/Octokit.Reactive/Clients/IObservableAuthorizationsClient.cs b/Octokit.Reactive/Clients/IObservableAuthorizationsClient.cs index 0e5083fd..1b7505ca 100644 --- a/Octokit.Reactive/Clients/IObservableAuthorizationsClient.cs +++ b/Octokit.Reactive/Clients/IObservableAuthorizationsClient.cs @@ -190,7 +190,7 @@ namespace Octokit.Reactive IObservable CheckApplicationAuthentication(string clientId, string accessToken); /// - /// Resets a valid OAuth token for an OAuth application without end user involvment. + /// Resets a valid OAuth token for an OAuth application without end user involvement. /// /// /// This method requires authentication. diff --git a/Octokit.Reactive/Clients/IObservableCommitStatusClient.cs b/Octokit.Reactive/Clients/IObservableCommitStatusClient.cs index d2168f80..b1a970fb 100644 --- a/Octokit.Reactive/Clients/IObservableCommitStatusClient.cs +++ b/Octokit.Reactive/Clients/IObservableCommitStatusClient.cs @@ -15,6 +15,18 @@ namespace Octokit.Reactive /// IObservable GetAll(string owner, string name, string reference); + /// + /// Retrieves commit statuses for the specified reference. A reference can be a commit SHA, a branch name, or + /// a tag name. + /// + /// Only users with pull access can see this. + /// The owner of the repository + /// The name of the repository + /// The reference (SHA, branch name, or tag name) to list commits for + /// Options for changing the API response + /// + IObservable GetAll(string owner, string name, string reference, ApiOptions options); + /// /// Retrieves a combined view of statuses for the specified reference. A reference can be a commit SHA, a branch name, or /// a tag name. diff --git a/Octokit.Reactive/Clients/IObservableDeploymentsClient.cs b/Octokit.Reactive/Clients/IObservableDeploymentsClient.cs index 3a77e846..23fbee4a 100644 --- a/Octokit.Reactive/Clients/IObservableDeploymentsClient.cs +++ b/Octokit.Reactive/Clients/IObservableDeploymentsClient.cs @@ -16,6 +16,19 @@ namespace Octokit.Reactive /// All the s for the specified repository. IObservable GetAll(string owner, string name); + /// + /// Gets all the deployments for the specified repository. Any user with pull access + /// to a repository can view deployments. + /// + /// + /// http://developer.github.com/v3/repos/deployments/#list-deployments + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the specified repository. + IObservable GetAll(string owner, string name, ApiOptions options); + /// /// Creates a new deployment for the specified repository. /// Users with push access can create a deployment for a given ref. diff --git a/Octokit.Reactive/Clients/IObservableEventsClient.cs b/Octokit.Reactive/Clients/IObservableEventsClient.cs index 5c037fdb..50f49490 100644 --- a/Octokit.Reactive/Clients/IObservableEventsClient.cs +++ b/Octokit.Reactive/Clients/IObservableEventsClient.cs @@ -14,6 +14,16 @@ namespace Octokit.Reactive [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] IObservable GetAll(); + /// + /// Gets all the public events + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events + /// + /// Options for changing the API response + /// All the public s for the particular user. + IObservable GetAll(ApiOptions options); + /// /// Gets all the events for a given repository /// @@ -25,6 +35,18 @@ namespace Octokit.Reactive /// All the s for the particular repository. IObservable GetAllForRepository(string owner, string name); + /// + /// Gets all the events for a given repository + /// + /// + /// http://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the particular repository. + IObservable GetAllForRepository(string owner, string name, ApiOptions options); + /// /// Gets all the events for a given repository network /// @@ -36,6 +58,18 @@ namespace Octokit.Reactive /// All the s for the particular repository network. IObservable GetAllForRepositoryNetwork(string owner, string name); + /// + /// Gets all the events for a given repository network + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-a-network-of-repositories + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the particular repository network. + IObservable GetAllForRepositoryNetwork(string owner, string name, ApiOptions options); + /// /// Gets all the events for a given organization /// @@ -46,6 +80,17 @@ namespace Octokit.Reactive /// All the s for the particular organization. IObservable GetAllForOrganization(string organization); + /// + /// Gets all the events for a given organization + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-an-organization + /// + /// The name of the organization + /// Options for changing the API response + /// All the s for the particular organization. + IObservable GetAllForOrganization(string organization, ApiOptions options); + /// /// Gets all the events that have been received by a given user. /// @@ -56,6 +101,17 @@ namespace Octokit.Reactive /// All the s that a particular user has received. IObservable GetAllUserReceived(string user); + /// + /// Gets all the events that have been received by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-that-a-user-has-received + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has received. + IObservable GetAllUserReceived(string user, ApiOptions options); + /// /// Gets all the events that have been received by a given user. /// @@ -66,6 +122,17 @@ namespace Octokit.Reactive /// All the s that a particular user has received. IObservable GetAllUserReceivedPublic(string user); + /// + /// Gets all the events that have been received by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-that-a-user-has-received + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has received. + IObservable GetAllUserReceivedPublic(string user, ApiOptions options); + /// /// Gets all the events that have been performed by a given user. /// @@ -76,6 +143,17 @@ namespace Octokit.Reactive /// All the s that a particular user has performed. IObservable GetAllUserPerformed(string user); + /// + /// Gets all the events that have been performed by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-performed-by-a-user + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has performed. + IObservable GetAllUserPerformed(string user, ApiOptions options); + /// /// Gets all the public events that have been performed by a given user. /// @@ -86,6 +164,17 @@ namespace Octokit.Reactive /// All the public s that a particular user has performed. IObservable GetAllUserPerformedPublic(string user); + /// + /// Gets all the public events that have been performed by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-performed-by-a-user + /// + /// The login of the user + /// Options for changing the API response + /// All the public s that a particular user has performed. + IObservable GetAllUserPerformedPublic(string user, ApiOptions options); + /// /// Gets all the events that are associated with an organization. /// @@ -96,5 +185,17 @@ namespace Octokit.Reactive /// The name of the organization /// All the public s that are associated with an organization. IObservable GetAllForAnOrganization(string user, string organization); + + /// + /// Gets all the events that are associated with an organization. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-for-an-organization + /// + /// The login of the user + /// The name of the organization + /// Options for changing the API response + /// All the public s that are associated with an organization. + IObservable GetAllForAnOrganization(string user, string organization, ApiOptions options); } } \ No newline at end of file diff --git a/Octokit.Reactive/Clients/IObservableFollowersClient.cs b/Octokit.Reactive/Clients/IObservableFollowersClient.cs index 46a38fc1..32030bc1 100644 --- a/Octokit.Reactive/Clients/IObservableFollowersClient.cs +++ b/Octokit.Reactive/Clients/IObservableFollowersClient.cs @@ -16,6 +16,17 @@ namespace Octokit.Reactive [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] IObservable GetAllForCurrent(); + /// + /// List the authenticated user’s followers + /// + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that follow the authenticated user. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + IObservable GetAllForCurrent(ApiOptions options); + /// /// List a user’s followers /// @@ -26,6 +37,17 @@ namespace Octokit.Reactive /// A of s that follow the passed user. IObservable GetAll(string login); + /// + /// List a user’s followers + /// + /// Options for changing the API response + /// The login name for the user + /// + /// See the API documentation for more information. + /// + /// A of s that follow the passed user. + IObservable GetAll(string login, ApiOptions options); + /// /// List who the authenticated user is following /// @@ -36,6 +58,16 @@ namespace Octokit.Reactive [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] IObservable GetAllFollowingForCurrent(); + /// + /// List who the authenticated user is following + /// + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that the authenticated user follows. + IObservable GetAllFollowingForCurrent(ApiOptions options); + /// /// List who a user is following /// @@ -46,6 +78,17 @@ namespace Octokit.Reactive /// A of s that the passed user follows. IObservable GetAllFollowing(string login); + /// + /// List who a user is following + /// + /// The login name of the user + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that the passed user follows. + IObservable GetAllFollowing(string login, ApiOptions options); + /// /// Check if the authenticated user follows another user /// diff --git a/Octokit.Reactive/Clients/IObservableGistCommentsClient.cs b/Octokit.Reactive/Clients/IObservableGistCommentsClient.cs index be577f16..ea817b2f 100644 --- a/Octokit.Reactive/Clients/IObservableGistCommentsClient.cs +++ b/Octokit.Reactive/Clients/IObservableGistCommentsClient.cs @@ -25,6 +25,15 @@ namespace Octokit.Reactive /// IObservable{GistComment}. IObservable GetAllForGist(string gistId); + /// + /// Gets all comments for the gist with the specified id. + /// + /// http://developer.github.com/v3/gists/comments/#list-comments-on-a-gist + /// The id of the gist + /// Options for changing the API response + /// IObservable{GistComment}. + IObservable GetAllForGist(string gistId, ApiOptions options); + /// /// Creates a comment for the gist with the specified id. /// diff --git a/Octokit.Reactive/Clients/IObservableGistsClient.cs b/Octokit.Reactive/Clients/IObservableGistsClient.cs index efdc6ac2..a0493845 100644 --- a/Octokit.Reactive/Clients/IObservableGistsClient.cs +++ b/Octokit.Reactive/Clients/IObservableGistsClient.cs @@ -28,6 +28,16 @@ namespace Octokit.Reactive /// IObservable GetAll(); + /// + /// List the authenticated user’s gists or if called anonymously, + /// this will return all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + IObservable GetAll(ApiOptions options); + /// /// List the authenticated user’s gists or if called anonymously, /// this will return all public gists @@ -38,6 +48,17 @@ namespace Octokit.Reactive /// Only gists updated at or after this time are returned IObservable GetAll(DateTimeOffset since); + /// + /// List the authenticated user’s gists or if called anonymously, + /// this will return all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + IObservable GetAll(DateTimeOffset since, ApiOptions options); + /// /// Lists all public gists /// @@ -46,6 +67,15 @@ namespace Octokit.Reactive /// IObservable GetAllPublic(); + /// + /// Lists all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + IObservable GetAllPublic(ApiOptions options); + /// /// Lists all public gists /// @@ -55,6 +85,16 @@ namespace Octokit.Reactive /// Only gists updated at or after this time are returned IObservable GetAllPublic(DateTimeOffset since); + /// + /// Lists all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + IObservable GetAllPublic(DateTimeOffset since, ApiOptions options); + /// /// List the authenticated user’s starred gists /// @@ -63,6 +103,15 @@ namespace Octokit.Reactive /// IObservable GetAllStarred(); + /// + /// List the authenticated user’s starred gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + IObservable GetAllStarred(ApiOptions options); + /// /// List the authenticated user’s starred gists /// @@ -72,6 +121,16 @@ namespace Octokit.Reactive /// Only gists updated at or after this time are returned IObservable GetAllStarred(DateTimeOffset since); + /// + /// List the authenticated user’s starred gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + IObservable GetAllStarred(DateTimeOffset since, ApiOptions options); + /// /// List a user's gists /// @@ -81,6 +140,16 @@ namespace Octokit.Reactive /// The user IObservable GetAllForUser(string user); + /// + /// List a user's gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// The user + /// Options for changing the API response + IObservable GetAllForUser(string user, ApiOptions options); + /// /// List a user's gists /// @@ -91,6 +160,17 @@ namespace Octokit.Reactive /// Only gists updated at or after this time are returned IObservable GetAllForUser(string user, DateTimeOffset since); + /// + /// List a user's gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// The user + /// Only gists updated at or after this time are returned + /// Options for changing the API response + IObservable GetAllForUser(string user, DateTimeOffset since, ApiOptions options); + /// /// List gist commits /// @@ -100,6 +180,16 @@ namespace Octokit.Reactive /// The id of the gist IObservable GetAllCommits(string id); + /// + /// List gist commits + /// + /// + /// http://developer.github.com/v3/gists/#list-gists-commits + /// + /// The id of the gist + /// Options for changing the API response + IObservable GetAllCommits(string id, ApiOptions options); + /// /// List gist forks /// @@ -109,6 +199,16 @@ namespace Octokit.Reactive /// The id of the gist IObservable GetAllForks(string id); + /// + /// List gist forks + /// + /// + /// http://developer.github.com/v3/gists/#list-gists-forks + /// + /// The id of the gist + /// Options for changing the API response + IObservable GetAllForks(string id, ApiOptions options); + /// /// Creates a new gist /// diff --git a/Octokit.Reactive/Clients/IObservableIssueCommentsClient.cs b/Octokit.Reactive/Clients/IObservableIssueCommentsClient.cs index bc93a4e1..906a8814 100644 --- a/Octokit.Reactive/Clients/IObservableIssueCommentsClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssueCommentsClient.cs @@ -27,6 +27,16 @@ namespace Octokit.Reactive /// The list of s for the specified Repository. IObservable GetAllForRepository(string owner, string name); + /// + /// Gets Issue Comments for a repository. + /// + /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// The list of s for the specified Repository. + IObservable GetAllForRepository(string owner, string name, ApiOptions options); + /// /// Gets Issue Comments for a specified Issue. /// @@ -37,6 +47,17 @@ namespace Octokit.Reactive /// The list of s for the specified Issue. IObservable GetAllForIssue(string owner, string name, int number); + /// + /// Gets Issue Comments for a specified Issue. + /// + /// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// Options for changing the API response + /// The list of s for the specified Issue. + IObservable GetAllForIssue(string owner, string name, int number, ApiOptions options); + /// /// Creates a new Issue Comment for a specified Issue. /// diff --git a/Octokit.Reactive/Clients/IObservableIssuesClient.cs b/Octokit.Reactive/Clients/IObservableIssuesClient.cs index 008d9955..d9ca53a3 100644 --- a/Octokit.Reactive/Clients/IObservableIssuesClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssuesClient.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics.CodeAnalysis; +using System.Reactive; namespace Octokit.Reactive { @@ -156,5 +157,25 @@ namespace Octokit.Reactive /// /// IObservable Update(string owner, string name, int number, IssueUpdate issueUpdate); + + /// + /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. + /// + /// https://developer.github.com/v3/issues/#lock-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// + IObservable Lock(string owner, string name, int number); + + /// + /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. + /// + /// https://developer.github.com/v3/issues/#unlock-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// + IObservable Unlock(string owner, string name, int number); } -} +} \ No newline at end of file diff --git a/Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs b/Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs index 8f1f3bdb..25d63bc4 100644 --- a/Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs +++ b/Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs @@ -53,7 +53,7 @@ namespace Octokit.Reactive IObservable GetAllLicenses(); /// - /// Retrieves a license based on the licence key such as "mit" + /// Retrieves a license based on the license key such as "mit" /// /// /// A that includes the license key, text, and attributes of the license. diff --git a/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs b/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs index f89cef99..5d15d246 100644 --- a/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs +++ b/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs @@ -50,15 +50,6 @@ namespace Octokit.Reactive /// IObservable GetAll(string org, OrganizationMembersFilter filter); - /// - /// Obsolete, - /// - /// The login for the organization - /// The user filter - /// The users - [Obsolete("No longer supported, use GetAll(string, OrganizationMembersFilter) instead")] - IObservable GetAll(string org, string filter); - /// /// /// List all users who are members of an organization. A member is a user that diff --git a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs index 123860bc..8f47b4fe 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs @@ -16,7 +16,7 @@ namespace Octokit.Reactive /// /// Creates a new repository in the specified organization. /// - /// The login of the organization in which to create the repostiory + /// The login of the organization in which to create the repository /// A instance describing the new repository to create /// An instance for the created repository IObservable Create(string organizationLogin, NewRepository newRepository); @@ -256,7 +256,7 @@ namespace Octokit.Reactive /// /// The owner of the repository /// The name of the repository - /// All of the repositorys tags. + /// All of the repositories tags. IObservable GetAllTags(string owner, string name); /// diff --git a/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs b/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs index 29d4d55e..2cc9c479 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs @@ -14,7 +14,7 @@ namespace Octokit.Reactive /// The reference to use as the head commit /// [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "base")] - IObservable Compare(string owner, string name, string @base, string @head); + IObservable Compare(string owner, string name, string @base, string head); /// /// Gets all commits for a given repository @@ -35,6 +35,15 @@ namespace Octokit.Reactive /// IObservable GetAll(string owner, string name); + /// + /// Gets all commits for a given repository + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// + IObservable GetAll(string owner, string name, ApiOptions options); + /// /// Gets all commits for a given repository /// @@ -44,6 +53,16 @@ namespace Octokit.Reactive /// IObservable GetAll(string owner, string name, CommitRequest request); + /// + /// Gets all commits for a given repository + /// + /// The owner of the repository + /// The name of the repository + /// Used to filter list of commits returned + /// Options for changing the API response + /// + IObservable GetAll(string owner, string name, CommitRequest request, ApiOptions options); + /// /// Get the SHA-1 of a commit reference /// diff --git a/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs index 45d07226..1ab8ab7b 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs @@ -23,20 +23,7 @@ namespace Octokit.Reactive /// The name of the repository /// IObservable GetReadmeHtml(string owner, string name); - - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// - [Obsolete("Use GetArchive to download the archive instead")] - IObservable GetArchiveLink(string owner, string name); - + /// /// Get an archive of a given repository's contents /// @@ -46,20 +33,6 @@ namespace Octokit.Reactive /// A promise, containing the binary contents of the archive IObservable GetArchive(string owner, string name); - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// The format of the archive. Can be either tarball or zipball - /// - [Obsolete("Use GetArchive to download the archive instead")] - IObservable GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat); - /// /// Get an archive of a given repository's contents, in a specific format /// @@ -70,21 +43,6 @@ namespace Octokit.Reactive /// A promise, containing the binary contents of the archive IObservable GetArchive(string owner, string name, ArchiveFormat archiveFormat); - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// The format of the archive. Can be either tarball or zipball - /// A valid Git reference. - /// - [Obsolete("Use GetArchive to download the archive instead")] - IObservable GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat, string reference); - /// /// Get an archive of a given repository's contents, using a specific format and reference /// diff --git a/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs index f3176e0a..53d2f592 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs @@ -10,9 +10,21 @@ namespace Octokit.Reactive /// Gets the list of hooks defined for a repository /// /// See API documentation for more information. + /// The repository's owner + /// The repository's name /// IObservable GetAll(string owner, string repositoryName); + /// + /// Gets the list of hooks defined for a repository + /// + /// See API documentation for more information. + /// The repository's owner + /// The repository's name + /// Options for changing the API response + /// + IObservable GetAll(string owner, string repositoryName, ApiOptions options); + /// /// Gets a single hook defined for a repository by id /// diff --git a/Octokit.Reactive/Clients/IObservableTeamsClient.cs b/Octokit.Reactive/Clients/IObservableTeamsClient.cs index e6671028..0ca0a385 100644 --- a/Octokit.Reactive/Clients/IObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/IObservableTeamsClient.cs @@ -27,10 +27,20 @@ namespace Octokit.Reactive /// /// Returns all s for the current org. /// + /// Organization to list all teams of. /// Thrown when a general API error occurs. /// A list of the orgs's teams s. IObservable GetAll(string org); + /// + /// Returns all s for the current org. + /// + /// Organization to list all teams of. + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// A list of the orgs's teams s. + IObservable GetAll(string org, ApiOptions options); + /// /// Returns all s for the current user. /// @@ -39,17 +49,38 @@ namespace Octokit.Reactive [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] IObservable GetAllForCurrent(); + /// + /// Returns all s for the current user. + /// + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// A list of the user's s. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + IObservable GetAllForCurrent(ApiOptions options); + /// /// Returns all members of the given team. /// - /// The team identifier /// /// https://developer.github.com/v3/orgs/teams/#list-team-members /// + /// The team identifier /// Thrown when a general API error occurs. /// A list of the team's member s. IObservable GetAllMembers(int id); + /// + /// Returns all members of the given team. + /// + /// + /// https://developer.github.com/v3/orgs/teams/#list-team-members + /// + /// The team identifier + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// A list of the team's member s. + IObservable GetAllMembers(int id, ApiOptions options); + /// /// Returns newly created for the current org. /// @@ -94,16 +125,6 @@ namespace Octokit.Reactive /// if the user was removed from the team; otherwise. IObservable RemoveMembership(int id, string login); - /// - /// Gets whether the user with the given - /// is a member of the team with the given . - /// - /// The team to check. - /// The user to check. - /// if the user is a member of the team; otherwise. - [Obsolete("Use GetMembership(id, login) to detect pending memberships")] - IObservable IsMember(int id, string login); - /// /// Gets whether the user with the given /// is a member of the team with the given . @@ -116,10 +137,20 @@ namespace Octokit.Reactive /// /// Returns all team's repositories. /// + /// Team Id. /// Thrown when a general API error occurs. /// The team's repositories IObservable GetAllRepositories(int id); + /// + /// Returns all team's repositories. + /// + /// Team Id. + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// The team's repositories + IObservable GetAllRepositories(int id, ApiOptions options); + /// /// Remove a repository from the team /// diff --git a/Octokit.Reactive/Clients/ObservableAuthorizationsClient.cs b/Octokit.Reactive/Clients/ObservableAuthorizationsClient.cs index a79c9f8c..fa1956a0 100644 --- a/Octokit.Reactive/Clients/ObservableAuthorizationsClient.cs +++ b/Octokit.Reactive/Clients/ObservableAuthorizationsClient.cs @@ -264,7 +264,7 @@ namespace Octokit.Reactive } /// - /// Resets a valid OAuth token for an OAuth application without end user involvment. + /// Resets a valid OAuth token for an OAuth application without end user involvement. /// /// /// This method requires authentication. diff --git a/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs b/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs index b6390bc1..e34ed7a9 100644 --- a/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs +++ b/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs @@ -28,7 +28,31 @@ namespace Octokit.Reactive /// public IObservable GetAll(string owner, string name, string reference) { - return _connection.GetAndFlattenAllPages(ApiUrls.CommitStatuses(owner, name, reference)); + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); + + return GetAll(owner, name ,reference, ApiOptions.None); + } + + /// + /// Retrieves commit statuses for the specified reference. A reference can be a commit SHA, a branch name, or + /// a tag name. + /// + /// Only users with pull access can see this. + /// The owner of the repository + /// The name of the repository + /// The reference (SHA, branch name, or tag name) to list commits for + /// Options for changing the API response + /// + public IObservable GetAll(string owner, string name, string reference, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.CommitStatuses(owner, name, reference), options); } /// diff --git a/Octokit.Reactive/Clients/ObservableDeploymentsClient.cs b/Octokit.Reactive/Clients/ObservableDeploymentsClient.cs index 3d2ab9f1..9a32ace1 100644 --- a/Octokit.Reactive/Clients/ObservableDeploymentsClient.cs +++ b/Octokit.Reactive/Clients/ObservableDeploymentsClient.cs @@ -34,8 +34,28 @@ namespace Octokit.Reactive.Clients Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); + return GetAll(owner, name, ApiOptions.None); + } + + /// + /// Gets all the deployments for the specified repository. Any user with pull access + /// to a repository can view deployments. + /// + /// + /// http://developer.github.com/v3/repos/deployments/#list-deployments + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the specified repository. + public IObservable GetAll(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + return _connection.GetAndFlattenAllPages( - ApiUrls.Deployments(owner, name)); + ApiUrls.Deployments(owner, name), options); } /// diff --git a/Octokit.Reactive/Clients/ObservableEventsClient.cs b/Octokit.Reactive/Clients/ObservableEventsClient.cs index ad871c29..18de33fd 100644 --- a/Octokit.Reactive/Clients/ObservableEventsClient.cs +++ b/Octokit.Reactive/Clients/ObservableEventsClient.cs @@ -23,7 +23,22 @@ namespace Octokit.Reactive /// All the public s for the particular user. public IObservable GetAll() { - return _connection.GetAndFlattenAllPages(ApiUrls.Events()); + return GetAll(ApiOptions.None); + } + + /// + /// Gets all the public events + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events + /// + /// Options for changing the API response + /// All the public s for the particular user. + public IObservable GetAll(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.Events(), options); } /// @@ -40,7 +55,26 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return _connection.GetAndFlattenAllPages(ApiUrls.IssuesEvents(owner, name)); + return GetAllForRepository(owner, name, ApiOptions.None); + } + + /// + /// Gets all the events for a given repository + /// + /// + /// http://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the particular repository. + public IObservable GetAllForRepository(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.IssuesEvents(owner, name), options); } /// @@ -57,7 +91,26 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return _connection.GetAndFlattenAllPages(ApiUrls.NetworkEvents(owner, name)); + return GetAllForRepositoryNetwork(owner, name, ApiOptions.None); + } + + /// + /// Gets all the events for a given repository network + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-a-network-of-repositories + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the particular repository network. + public IObservable GetAllForRepositoryNetwork(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.NetworkEvents(owner, name), options); } /// @@ -72,7 +125,24 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); - return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationEvents(organization)); + return GetAllForOrganization(organization, ApiOptions.None); + } + + /// + /// Gets all the events for a given organization + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-an-organization + /// + /// The name of the organization + /// Options for changing the API response + /// All the s for the particular organization. + public IObservable GetAllForOrganization(string organization, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationEvents(organization), options); } /// @@ -87,7 +157,24 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return _connection.GetAndFlattenAllPages(ApiUrls.ReceivedEvents(user)); + return GetAllUserReceived(user, ApiOptions.None); + } + + /// + /// Gets all the events that have been received by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-that-a-user-has-received + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has received. + public IObservable GetAllUserReceived(string user, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.ReceivedEvents(user), options); } /// @@ -102,7 +189,24 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return _connection.GetAndFlattenAllPages(ApiUrls.ReceivedEvents(user, true)); + return GetAllUserReceivedPublic(user, ApiOptions.None); + } + + /// + /// Gets all the events that have been received by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-that-a-user-has-received + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has received. + public IObservable GetAllUserReceivedPublic(string user, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.ReceivedEvents(user, true), options); } /// @@ -117,7 +221,24 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return _connection.GetAndFlattenAllPages(ApiUrls.PerformedEvents(user)); + return GetAllUserPerformed(user, ApiOptions.None); + } + + /// + /// Gets all the events that have been performed by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-performed-by-a-user + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has performed. + public IObservable GetAllUserPerformed(string user, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.PerformedEvents(user), options); } /// @@ -132,7 +253,24 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return _connection.GetAndFlattenAllPages(ApiUrls.PerformedEvents(user, true)); + return GetAllUserPerformedPublic(user, ApiOptions.None); + } + + /// + /// Gets all the public events that have been performed by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-performed-by-a-user + /// + /// The login of the user + /// Options for changing the API response + /// All the public s that a particular user has performed. + public IObservable GetAllUserPerformedPublic(string user, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.PerformedEvents(user, true), options); } /// @@ -149,7 +287,26 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(user, "user"); Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); - return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationEvents(user, organization)); + return GetAllForAnOrganization(user, organization, ApiOptions.None); + } + + /// + /// Gets all the events that are associated with an organization. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-for-an-organization + /// + /// The login of the user + /// The name of the organization + /// Options for changing the API response + /// All the public s that are associated with an organization. + public IObservable GetAllForAnOrganization(string user, string organization, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationEvents(user, organization),options); } } } diff --git a/Octokit.Reactive/Clients/ObservableFollowersClient.cs b/Octokit.Reactive/Clients/ObservableFollowersClient.cs index c77b4571..955b5309 100644 --- a/Octokit.Reactive/Clients/ObservableFollowersClient.cs +++ b/Octokit.Reactive/Clients/ObservableFollowersClient.cs @@ -31,7 +31,22 @@ namespace Octokit.Reactive /// A of s that follow the authenticated user. public IObservable GetAllForCurrent() { - return _connection.GetAndFlattenAllPages(ApiUrls.Followers()); + return GetAllForCurrent(ApiOptions.None); + } + + /// + /// List the authenticated user’s followers + /// + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that follow the authenticated user. + public IObservable GetAllForCurrent(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.Followers(), options); } /// @@ -46,7 +61,24 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNullOrEmptyString(login, "login"); - return _connection.GetAndFlattenAllPages(ApiUrls.Followers(login)); + return GetAll(login, ApiOptions.None); + } + + /// + /// List a user’s followers + /// + /// The login name for the user + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that follow the passed user. + public IObservable GetAll(string login, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.Followers(login), options); } /// @@ -58,7 +90,22 @@ namespace Octokit.Reactive /// A of s that the authenticated user follows. public IObservable GetAllFollowingForCurrent() { - return _connection.GetAndFlattenAllPages(ApiUrls.Following()); + return GetAllFollowingForCurrent(ApiOptions.None); + } + + /// + /// List who the authenticated user is following + /// + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that the authenticated user follows. + public IObservable GetAllFollowingForCurrent(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.Following(), options); } /// @@ -73,7 +120,24 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNullOrEmptyString(login, "login"); - return _connection.GetAndFlattenAllPages(ApiUrls.Following(login)); + return GetAllFollowing(login, ApiOptions.None); + } + + /// + /// List who a user is following + /// + /// The login name of the user + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that the passed user follows. + public IObservable GetAllFollowing(string login, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.Following(login), options); } /// diff --git a/Octokit.Reactive/Clients/ObservableGistCommentsClient.cs b/Octokit.Reactive/Clients/ObservableGistCommentsClient.cs index 7dc639bf..57165687 100644 --- a/Octokit.Reactive/Clients/ObservableGistCommentsClient.cs +++ b/Octokit.Reactive/Clients/ObservableGistCommentsClient.cs @@ -38,7 +38,24 @@ namespace Octokit.Reactive /// IObservable{GistComment}. public IObservable GetAllForGist(string gistId) { - return _connection.GetAndFlattenAllPages(ApiUrls.GistComments(gistId)); + Ensure.ArgumentNotNullOrEmptyString(gistId, "gistId"); + + return GetAllForGist(gistId, ApiOptions.None); + } + + /// + /// Gets all comments for the gist with the specified id. + /// + /// http://developer.github.com/v3/gists/comments/#list-comments-on-a-gist + /// The id of the gist + /// Options for changing the API response + /// IObservable{GistComment}. + public IObservable GetAllForGist(string gistId, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(gistId, "gistId"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.GistComments(gistId), options); } /// diff --git a/Octokit.Reactive/Clients/ObservableGistsClient.cs b/Octokit.Reactive/Clients/ObservableGistsClient.cs index 9d63c775..1dbd817a 100644 --- a/Octokit.Reactive/Clients/ObservableGistsClient.cs +++ b/Octokit.Reactive/Clients/ObservableGistsClient.cs @@ -84,7 +84,22 @@ namespace Octokit.Reactive /// public IObservable GetAll() { - return _connection.GetAndFlattenAllPages(ApiUrls.Gist()); + return GetAll(ApiOptions.None); + } + + /// + /// List the authenticated user’s gists or if called anonymously, + /// this will return all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + public IObservable GetAll(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.Gist(), options); } /// @@ -96,9 +111,25 @@ namespace Octokit.Reactive /// /// Only gists updated at or after this time are returned public IObservable GetAll(DateTimeOffset since) + { + return GetAll(since, ApiOptions.None); + } + + /// + /// List the authenticated user’s gists or if called anonymously, + /// this will return all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + public IObservable GetAll(DateTimeOffset since, ApiOptions options) { + Ensure.ArgumentNotNull(options, "options"); + var request = new GistRequest(since); - return _connection.GetAndFlattenAllPages(ApiUrls.Gist(), request.ToParametersDictionary()); + return _connection.GetAndFlattenAllPages(ApiUrls.Gist(), request.ToParametersDictionary(), options); } /// @@ -109,7 +140,21 @@ namespace Octokit.Reactive /// public IObservable GetAllPublic() { - return _connection.GetAndFlattenAllPages(ApiUrls.PublicGists()); + return GetAllPublic(ApiOptions.None); + } + + /// + /// Lists all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + public IObservable GetAllPublic(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.PublicGists(), options); } /// @@ -121,8 +166,23 @@ namespace Octokit.Reactive /// Only gists updated at or after this time are returned public IObservable GetAllPublic(DateTimeOffset since) { + return GetAllPublic(since, ApiOptions.None); + } + + /// + /// Lists all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + public IObservable GetAllPublic(DateTimeOffset since, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + var request = new GistRequest(since); - return _connection.GetAndFlattenAllPages(ApiUrls.PublicGists(), request.ToParametersDictionary()); + return _connection.GetAndFlattenAllPages(ApiUrls.PublicGists(), request.ToParametersDictionary(), options); } /// @@ -133,7 +193,21 @@ namespace Octokit.Reactive /// public IObservable GetAllStarred() { - return _connection.GetAndFlattenAllPages(ApiUrls.StarredGists()); + return GetAllStarred(ApiOptions.None); + } + + /// + /// List the authenticated user’s starred gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + public IObservable GetAllStarred(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.StarredGists(), options); } /// @@ -145,8 +219,23 @@ namespace Octokit.Reactive /// Only gists updated at or after this time are returned public IObservable GetAllStarred(DateTimeOffset since) { + return GetAllStarred(since, ApiOptions.None); + } + + /// + /// List the authenticated user’s starred gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + public IObservable GetAllStarred(DateTimeOffset since, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + var request = new GistRequest(since); - return _connection.GetAndFlattenAllPages(ApiUrls.StarredGists(), request.ToParametersDictionary()); + return _connection.GetAndFlattenAllPages(ApiUrls.StarredGists(), request.ToParametersDictionary(), options); } /// @@ -158,9 +247,25 @@ namespace Octokit.Reactive /// The user public IObservable GetAllForUser(string user) { - Ensure.ArgumentNotNull(user, "user"); + Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return _connection.GetAndFlattenAllPages(ApiUrls.UsersGists(user)); + return GetAllForUser(user, ApiOptions.None); + } + + /// + /// List a user's gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// The user + /// Options for changing the API response + public IObservable GetAllForUser(string user, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.UsersGists(user), options); } /// @@ -173,10 +278,27 @@ namespace Octokit.Reactive /// Only gists updated at or after this time are returned public IObservable GetAllForUser(string user, DateTimeOffset since) { - Ensure.ArgumentNotNull(user, "user"); + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + + return GetAllForUser(user, since, ApiOptions.None); + } + + /// + /// List a user's gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// The user + /// Only gists updated at or after this time are returned + /// Options for changing the API response + public IObservable GetAllForUser(string user, DateTimeOffset since, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); var request = new GistRequest(since); - return _connection.GetAndFlattenAllPages(ApiUrls.UsersGists(user), request.ToParametersDictionary()); + return _connection.GetAndFlattenAllPages(ApiUrls.UsersGists(user), request.ToParametersDictionary(), options); } /// @@ -190,7 +312,23 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNullOrEmptyString(id, "id"); - return _connection.GetAndFlattenAllPages(ApiUrls.GistCommits(id)); + return GetAllCommits(id, ApiOptions.None); + } + + /// + /// List gist commits + /// + /// + /// http://developer.github.com/v3/gists/#list-gists-commits + /// + /// The id of the gist + /// Options for changing the API response + public IObservable GetAllCommits(string id, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(id, "id"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.GistCommits(id), options); } /// @@ -204,7 +342,23 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNullOrEmptyString(id, "id"); - return _connection.GetAndFlattenAllPages(ApiUrls.ForkGist(id)); + return GetAllForks(id, ApiOptions.None); + } + + /// + /// List gist forks + /// + /// + /// http://developer.github.com/v3/gists/#list-gists-forks + /// + /// The id of the gist + /// Options for changing the API response + public IObservable GetAllForks(string id, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(id, "id"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.ForkGist(id), options); } /// diff --git a/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs b/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs index 2a8494a4..37b4bccd 100644 --- a/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs @@ -46,7 +46,24 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return _connection.GetAndFlattenAllPages(ApiUrls.IssueComments(owner, name)); + return GetAllForRepository(owner, name, ApiOptions.None); + } + + /// + /// Gets Issue Comments for a repository. + /// + /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// The list of s for the specified Repository. + public IObservable GetAllForRepository(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.IssueComments(owner, name), options); } /// @@ -62,7 +79,25 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return _connection.GetAndFlattenAllPages(ApiUrls.IssueComments(owner, name, number)); + return GetAllForIssue(owner, name, number, ApiOptions.None); + } + + /// + /// Gets Issue Comments for a specified Issue. + /// + /// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// Options for changing the API response + /// The list of s for the specified Issue. + public IObservable GetAllForIssue(string owner, string name, int number, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.IssueComments(owner, name, number), options); } /// diff --git a/Octokit.Reactive/Clients/ObservableIssuesClient.cs b/Octokit.Reactive/Clients/ObservableIssuesClient.cs index 45716963..007b743d 100644 --- a/Octokit.Reactive/Clients/ObservableIssuesClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssuesClient.cs @@ -1,6 +1,7 @@ using System; using System.Reactive.Threading.Tasks; using Octokit.Reactive.Internal; +using System.Reactive; namespace Octokit.Reactive { @@ -222,5 +223,37 @@ namespace Octokit.Reactive return _client.Update(owner, name, number, issueUpdate).ToObservable(); } + + /// + /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. + /// + /// https://developer.github.com/v3/issues/#lock-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// + public IObservable Lock(string owner, string name, int number) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return _client.Lock(owner, name, number).ToObservable(); + } + + /// + /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. + /// + /// https://developer.github.com/v3/issues/#unlock-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// + public IObservable Unlock(string owner, string name, int number) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return _client.Unlock(owner, name, number).ToObservable(); + } } } diff --git a/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs b/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs index ea9c4096..cf6a5860 100644 --- a/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs +++ b/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs @@ -9,6 +9,7 @@ namespace Octokit.Reactive { readonly IMiscellaneousClient _client; + [Obsolete("Please use the IGitHubClient overload constructor")] public ObservableMiscellaneousClient(IMiscellaneousClient client) { Ensure.ArgumentNotNull(client, "client"); @@ -16,6 +17,13 @@ namespace Octokit.Reactive _client = client; } + public ObservableMiscellaneousClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, "client"); + + _client = client.Miscellaneous; + } + /// /// Gets all the emojis available to use on GitHub. /// @@ -78,7 +86,7 @@ namespace Octokit.Reactive } /// - /// Retrieves a license based on the licence key such as "mit" + /// Retrieves a license based on the license key such as "mit" /// /// /// A that includes the license key, text, and attributes of the license. diff --git a/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs b/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs index b2b1d900..0bb84d35 100644 --- a/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs +++ b/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs @@ -77,21 +77,6 @@ namespace Octokit.Reactive return _connection.GetAndFlattenAllPages(ApiUrls.Members(org, filter)); } - /// - /// Obsolete, - /// - /// The login for the organization - /// The user filter - /// The users - [Obsolete("No longer supported, use GetAll(string, OrganizationMembersFilter) instead")] - public IObservable GetAll(string org, string filter) - { - Ensure.ArgumentNotNullOrEmptyString(org, "org"); - Ensure.ArgumentNotNullOrEmptyString(filter, "filter"); - - return _connection.GetAndFlattenAllPages(ApiUrls.Members(org, filter)); - } - /// /// /// List all users who are members of an organization. A member is a user that diff --git a/Octokit.Reactive/Clients/ObservableReleasesClient.cs b/Octokit.Reactive/Clients/ObservableReleasesClient.cs index 100bd131..880580c1 100644 --- a/Octokit.Reactive/Clients/ObservableReleasesClient.cs +++ b/Octokit.Reactive/Clients/ObservableReleasesClient.cs @@ -33,7 +33,7 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return _connection.GetAndFlattenAllPages(ApiUrls.Releases(owner, name)); + return GetAll(owner, name, ApiOptions.None); } /// diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs index 005270bb..d7d7d4cd 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs @@ -61,7 +61,7 @@ namespace Octokit.Reactive /// /// Creates a new repository in the specified organization. /// - /// The login of the organization in which to create the repostiory + /// The login of the organization in which to create the repository /// A instance describing the new repository to create /// An instance for the created repository public IObservable Create(string organizationLogin, NewRepository newRepository) @@ -374,7 +374,7 @@ namespace Octokit.Reactive /// /// The owner of the repository /// The name of the repository - /// All of the repositorys tags. + /// All of the repositories tags. public IObservable GetAllTags(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); diff --git a/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs b/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs index 629142d7..3304e261 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs @@ -54,7 +54,26 @@ namespace Octokit.Reactive /// public IObservable GetAll(string owner, string name) { - return GetAll(owner, name, new CommitRequest()); + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return GetAll(owner, name, new CommitRequest(), ApiOptions.None); + } + + /// + /// Gets all commits for a given repository + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// + public IObservable GetAll(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return GetAll(owner, name, new CommitRequest(), options); } /// @@ -70,8 +89,24 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(request, "request"); - return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryCommits(owner, name), - request.ToParametersDictionary()); + return GetAll(owner, name, request, ApiOptions.None); + } + + /// + /// Gets all commits for a given repository + /// + /// The owner of the repository + /// The name of the repository + /// Used to filter list of commits returned + /// Options for changing the API response + /// + public IObservable GetAll(string owner, string name, CommitRequest request, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(request, "request"); + + return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryCommits(owner, name), request.ToParametersDictionary(), options); } /// diff --git a/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs index 6d05f60b..456ce31b 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs @@ -48,23 +48,6 @@ namespace Octokit.Reactive return _client.Repository.Content.GetReadmeHtml(owner, name).ToObservable(); } - - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// - [Obsolete("Use GetArchive to download the archive instead")] - public IObservable GetArchiveLink(string owner, string name) - { - return GetArchiveLink(owner, name, ArchiveFormat.Tarball, string.Empty); - } - /// /// Get an archive of a given repository's contents /// @@ -77,23 +60,6 @@ namespace Octokit.Reactive return GetArchive(owner, name, ArchiveFormat.Tarball); } - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// The format of the archive. Can be either tarball or zipball - /// - [Obsolete("Use GetArchive to download the archive instead")] - public IObservable GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat) - { - return GetArchiveLink(owner, name, archiveFormat, string.Empty); - } - /// /// Get an archive of a given repository's contents, in a specific format /// @@ -107,27 +73,6 @@ namespace Octokit.Reactive return GetArchive(owner, name, archiveFormat, string.Empty); } - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// The format of the archive. Can be either tarball or zipball - /// A valid Git reference. - /// - [Obsolete("Use GetArchive to download the archive instead")] - public IObservable GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat, string reference) - { - Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - - return _client.Repository.Content.GetArchiveLink(owner, name, archiveFormat, reference).ToObservable(); - } - /// /// Get an archive of a given repository's contents, using a specific format and reference /// diff --git a/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs index 7b229dd2..24bca1f4 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs @@ -22,13 +22,32 @@ namespace Octokit.Reactive /// Gets the list of hooks defined for a repository /// /// See API documentation for more information. + /// The repository's owner + /// The repository's name /// public IObservable GetAll(string owner, string repositoryName) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryHooks(owner, repositoryName)); + return GetAll(owner, repositoryName, ApiOptions.None); + } + + /// + /// Gets the list of hooks defined for a repository + /// + /// See API documentation for more information. + /// The repository's owner + /// The repository's name + /// Options for changing the API response + /// + public IObservable GetAll(string owner, string repositoryName, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryHooks(owner, repositoryName), options); } /// diff --git a/Octokit.Reactive/Clients/ObservableTeamsClient.cs b/Octokit.Reactive/Clients/ObservableTeamsClient.cs index c4d44985..31f9b7aa 100644 --- a/Octokit.Reactive/Clients/ObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/ObservableTeamsClient.cs @@ -48,7 +48,23 @@ namespace Octokit.Reactive public IObservable GetAll(string org) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); - return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationTeams(org)); + + return GetAll(org, ApiOptions.None); + } + + /// + /// Returns all s for the current org. + /// + /// Organization to list all teams of. + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// A list of the orgs's teams s. + public IObservable GetAll(string org, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(org, "org"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationTeams(org), options); } /// @@ -58,7 +74,20 @@ namespace Octokit.Reactive /// A list of the user's s. public IObservable GetAllForCurrent() { - return _connection.GetAndFlattenAllPages(ApiUrls.UserTeams()); + return GetAllForCurrent(ApiOptions.None); + } + + /// + /// Returns all s for the current user. + /// + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// A list of the user's s. + public IObservable GetAllForCurrent(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.UserTeams(), options); } /// @@ -72,7 +101,24 @@ namespace Octokit.Reactive /// A list of the team's member s. public IObservable GetAllMembers(int id) { - return _connection.GetAndFlattenAllPages(ApiUrls.TeamMembers(id)); + return GetAllMembers(id, ApiOptions.None); + } + + /// + /// Returns all members of the given team. + /// + /// + /// https://developer.github.com/v3/orgs/teams/#list-team-members + /// + /// The team identifier + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// A list of the team's member s. + public IObservable GetAllMembers(int id, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.TeamMembers(id), options); } /// @@ -82,6 +128,9 @@ namespace Octokit.Reactive /// Newly created public IObservable Create(string org, NewTeam team) { + Ensure.ArgumentNotNullOrEmptyString(org, "org"); + Ensure.ArgumentNotNull(team, "team"); + return _client.Create(org, team).ToObservable(); } @@ -92,6 +141,8 @@ namespace Octokit.Reactive /// Updated public IObservable Update(int id, UpdateTeam team) { + Ensure.ArgumentNotNull(team, "team"); + return _client.Update(id, team).ToObservable(); } @@ -117,6 +168,8 @@ namespace Octokit.Reactive /// A result indicating the membership status public IObservable AddMembership(int id, string login) { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + return _client.AddMembership(id, login).ToObservable(); } @@ -131,20 +184,9 @@ namespace Octokit.Reactive /// if the user was removed from the team; otherwise. public IObservable RemoveMembership(int id, string login) { - return _client.RemoveMembership(id, login).ToObservable(); - } + Ensure.ArgumentNotNullOrEmptyString(login, "login"); - /// - /// Gets whether the user with the given - /// is a member of the team with the given . - /// - /// The team to check. - /// The user to check. - /// if the user is a member of the team; otherwise. - [Obsolete("Use GetMembership(id, login) to detect pending memberships")] - public IObservable IsMember(int id, string login) - { - return _client.IsMember(id, login).ToObservable(); + return _client.RemoveMembership(id, login).ToObservable(); } /// @@ -156,6 +198,8 @@ namespace Octokit.Reactive /// A result indicating the membership status public IObservable GetMembership(int id, string login) { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + return _client.GetMembership(id, login).ToObservable(); } @@ -166,7 +210,21 @@ namespace Octokit.Reactive /// The team's repositories public IObservable GetAllRepositories(int id) { - return _connection.GetAndFlattenAllPages(ApiUrls.TeamRepositories(id)); + return GetAllRepositories(id, ApiOptions.None); + } + + /// + /// Returns all team's repositories. + /// + /// Team Id. + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// The team's repositories + public IObservable GetAllRepositories(int id, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.TeamRepositories(id), options); } /// @@ -182,6 +240,9 @@ namespace Octokit.Reactive /// if the repository was added to the team; otherwise. public IObservable AddRepository(int id, string organization, string repoName) { + Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); + Ensure.ArgumentNotNullOrEmptyString(repoName, "repoName"); + return _client.AddRepository(id, organization, repoName).ToObservable(); } @@ -193,6 +254,9 @@ namespace Octokit.Reactive /// public IObservable RemoveRepository(int id, string organization, string repoName) { + Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); + Ensure.ArgumentNotNullOrEmptyString(repoName, "repoName"); + return _client.RemoveRepository(id, organization, repoName).ToObservable(); } @@ -208,6 +272,8 @@ namespace Octokit.Reactive /// if the repository is managed by the given team; otherwise. public IObservable IsRepositoryManagedByTeam(int id, string owner, string repo) { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repo, "repo"); return _client.IsRepositoryManagedByTeam(id, owner, repo).ToObservable(); } } diff --git a/Octokit.Reactive/Helpers/ConnectionExtensions.cs b/Octokit.Reactive/Helpers/ConnectionExtensions.cs index becbf01c..5f2aec15 100644 --- a/Octokit.Reactive/Helpers/ConnectionExtensions.cs +++ b/Octokit.Reactive/Helpers/ConnectionExtensions.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.Linq; using System.Reactive.Linq; using System.Reactive.Threading.Tasks; @@ -16,11 +15,7 @@ namespace Octokit.Reactive.Internal public static IObservable GetAndFlattenAllPages(this IConnection connection, Uri url, ApiOptions options) { - return GetPagesWithOptions(url, options, (pageUrl, o) => - { - var parameters = Pagination.Setup(new Dictionary(), options); - return connection.Get>(pageUrl, parameters, null).ToObservable(); - }); + return connection.GetAndFlattenAllPages(url, null, options); } public static IObservable GetAndFlattenAllPages(this IConnection connection, Uri url, IDictionary parameters) @@ -28,6 +23,15 @@ namespace Octokit.Reactive.Internal return GetPages(url, parameters, (pageUrl, pageParams) => connection.Get>(pageUrl, pageParams, null).ToObservable()); } + public static IObservable GetAndFlattenAllPages(this IConnection connection, Uri url, IDictionary parameters, ApiOptions options) + { + return GetPagesWithOptions(url, parameters, options, (pageUrl, pageParams, o) => + { + var passingParameters = Pagination.Setup(parameters, options); + return connection.Get>(pageUrl, passingParameters, null).ToObservable(); + }); + } + public static IObservable GetAndFlattenAllPages(this IConnection connection, Uri url, IDictionary parameters, string accepts) { return GetPages(url, parameters, (pageUrl, pageParams) => connection.Get>(pageUrl, pageParams, accepts).ToObservable()); @@ -47,19 +51,16 @@ namespace Octokit.Reactive.Internal .SelectMany(resp => resp.Body); } - static IObservable GetPagesWithOptions(Uri uri, ApiOptions options, - Func>>> getPageFunc) + static IObservable GetPagesWithOptions(Uri uri, IDictionary parameters, ApiOptions options, Func, ApiOptions, IObservable>>> getPageFunc) { - return getPageFunc(uri, options).Expand(resp => + return getPageFunc(uri, parameters, options).Expand(resp => { - var nextPageUri = resp.HttpResponse.ApiInfo.GetNextPageUrl(); + var nextPageUrl = resp.HttpResponse.ApiInfo.GetNextPageUrl(); - var shouldContinue = Pagination.ShouldContinue( - nextPageUri, - options); + var shouldContinue = Pagination.ShouldContinue(nextPageUrl, options); - return shouldContinue - ? Observable.Defer(() => getPageFunc(nextPageUri, null)) + return shouldContinue + ? Observable.Defer(() => getPageFunc(nextPageUrl, null, null)) : Observable.Empty>>(); }) .Where(resp => resp != null) diff --git a/Octokit.Reactive/ObservableGitHubClient.cs b/Octokit.Reactive/ObservableGitHubClient.cs index d938bf1b..16485593 100644 --- a/Octokit.Reactive/ObservableGitHubClient.cs +++ b/Octokit.Reactive/ObservableGitHubClient.cs @@ -34,7 +34,7 @@ namespace Octokit.Reactive Authorization = new ObservableAuthorizationsClient(gitHubClient); Activity = new ObservableActivitiesClient(gitHubClient); Issue = new ObservableIssuesClient(gitHubClient); - Miscellaneous = new ObservableMiscellaneousClient(gitHubClient.Miscellaneous); + Miscellaneous = new ObservableMiscellaneousClient(gitHubClient); Notification = new ObservableNotificationsClient(gitHubClient); Oauth = new ObservableOauthClient(gitHubClient); Organization = new ObservableOrganizationsClient(gitHubClient); diff --git a/Octokit.Tests.Conventions/ClientConstructorTests.cs b/Octokit.Tests.Conventions/ClientConstructorTests.cs new file mode 100644 index 00000000..b5d0e7a5 --- /dev/null +++ b/Octokit.Tests.Conventions/ClientConstructorTests.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Octokit.Tests.Conventions +{ + public class ClientConstructorTests + { + [Theory] + [MemberData("GetTestConstructorClasses")] + public void CheckTestConstructorNames(Type type) + { + const string constructorTestClassName = "TheCtor"; + const string constructorTestMethodName = "EnsuresNonNullArguments"; + + var classes = new HashSet(type.GetNestedTypes().Select(t => t.Name)); + + if (!classes.Contains(constructorTestClassName)) + { + throw new MissingClientConstructorTestClassException(type); + } + + var ctors = type.GetNestedTypes().Where(t => t.Name == constructorTestClassName) + .SelectMany(t => t.GetMethods()) + .Where(info => info.ReturnType == typeof(void) && info.IsPublic) + .Select(info => info.Name); + + var methods = new HashSet(ctors); + if (!methods.Contains(constructorTestMethodName)) + { + throw new MissingClientConstructorTestMethodException(type); + } + } + + public static IEnumerable GetTestConstructorClasses() + { + var tests = typeof(GitHubClientTests) + .Assembly + .ExportedTypes + .Where(type => type.IsClass && type.IsPublic && type.Name.EndsWith("ClientTests")) + .Select(type => new[] { type }); + return tests; + } + } +} \ No newline at end of file diff --git a/Octokit.Tests.Conventions/Exception/MissingClientConstructorTestClassException.cs b/Octokit.Tests.Conventions/Exception/MissingClientConstructorTestClassException.cs new file mode 100644 index 00000000..231929db --- /dev/null +++ b/Octokit.Tests.Conventions/Exception/MissingClientConstructorTestClassException.cs @@ -0,0 +1,16 @@ +using System; + +namespace Octokit.Tests.Conventions +{ + public class MissingClientConstructorTestClassException : Exception + { + public MissingClientConstructorTestClassException(Type modelType) + : base(CreateMessage(modelType)) + { } + + static string CreateMessage(Type ctorTest) + { + return string.Format("Constructor test class is missing {0}.", ctorTest.FullName); + } + } +} \ No newline at end of file diff --git a/Octokit.Tests.Conventions/Exception/MissingClientConstructorTestMethodException.cs b/Octokit.Tests.Conventions/Exception/MissingClientConstructorTestMethodException.cs new file mode 100644 index 00000000..a5908f13 --- /dev/null +++ b/Octokit.Tests.Conventions/Exception/MissingClientConstructorTestMethodException.cs @@ -0,0 +1,16 @@ +using System; + +namespace Octokit.Tests.Conventions +{ + public class MissingClientConstructorTestMethodException : Exception + { + public MissingClientConstructorTestMethodException(Type modelType) + : base(CreateMessage(modelType)) + { } + + static string CreateMessage(Type ctorTest) + { + return string.Format("Constructor test method is missing {0}.", ctorTest.FullName); + } + } +} \ No newline at end of file diff --git a/Octokit.Tests.Conventions/ModelTests.cs b/Octokit.Tests.Conventions/ModelTests.cs index 0cfcb3c8..1d3f5e16 100644 --- a/Octokit.Tests.Conventions/ModelTests.cs +++ b/Octokit.Tests.Conventions/ModelTests.cs @@ -97,7 +97,7 @@ namespace Octokit.Tests.Conventions public static IEnumerable GetClientInterfaces() { - return typeof(IEventsClient) + return typeof(IGitHubClient) .Assembly .ExportedTypes .Where(TypeExtensions.IsClientInterface) @@ -119,7 +119,7 @@ namespace Octokit.Tests.Conventions { var allModelTypes = new HashSet(); - var clientInterfaces = typeof(IEventsClient).Assembly.ExportedTypes + var clientInterfaces = typeof(IGitHubClient).Assembly.ExportedTypes .Where(type => type.IsClientInterface()); foreach (var exportedType in clientInterfaces) diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index c6012156..e06a67b8 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -64,6 +64,8 @@ + + @@ -81,6 +83,7 @@ + diff --git a/Octokit.Tests.Conventions/PaginationTests.cs b/Octokit.Tests.Conventions/PaginationTests.cs index 3c2565e7..2f1c3c88 100644 --- a/Octokit.Tests.Conventions/PaginationTests.cs +++ b/Octokit.Tests.Conventions/PaginationTests.cs @@ -89,7 +89,7 @@ namespace Octokit.Tests.Conventions public static IEnumerable GetClientInterfaces() { - return typeof(IEventsClient).Assembly.ExportedTypes + return typeof(IGitHubClient).Assembly.ExportedTypes .Where(TypeExtensions.IsClientInterface) .Where(type => type != typeof(IStatisticsClient)) .Select(type => new[] { type }); diff --git a/Octokit.Tests.Conventions/SyncObservableClients.cs b/Octokit.Tests.Conventions/SyncObservableClients.cs index 3d005992..02fd3981 100644 --- a/Octokit.Tests.Conventions/SyncObservableClients.cs +++ b/Octokit.Tests.Conventions/SyncObservableClients.cs @@ -120,7 +120,7 @@ namespace Octokit.Tests.Conventions public static IEnumerable GetClientInterfaces() { - return typeof(IEventsClient) + return typeof(IGitHubClient) .Assembly .ExportedTypes .Where(TypeExtensions.IsClientInterface) diff --git a/Octokit.Tests.Conventions/TypeExtensions.cs b/Octokit.Tests.Conventions/TypeExtensions.cs index 7d3ef6d3..95610c51 100644 --- a/Octokit.Tests.Conventions/TypeExtensions.cs +++ b/Octokit.Tests.Conventions/TypeExtensions.cs @@ -70,7 +70,7 @@ namespace Octokit.Tests.Conventions public static bool IsClientInterface(this Type type) { - return type.IsInterface && type.Name.EndsWith(ClientSuffix) && type.Namespace == typeof(IEventsClient).Namespace; + return type.IsInterface && type.Name.EndsWith(ClientSuffix) && type.Namespace == typeof(IGitHubClient).Namespace; } public static Type GetObservableClientInterface(this Type type) diff --git a/Octokit.Tests.Integration/Clients/BranchesClientTests.cs b/Octokit.Tests.Integration/Clients/BranchesClientTests.cs index 70217181..f661518f 100644 --- a/Octokit.Tests.Integration/Clients/BranchesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/BranchesClientTests.cs @@ -40,7 +40,7 @@ public class BranchesClientTests public async Task CreateTheWorld() { // Set master branch to be protected, with some status checks - var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List() { "check1", "check2" }); + var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List { "check1", "check2" }); var update = new BranchUpdate(); update.Protection = new BranchProtection(true, requiredStatusChecks); @@ -52,7 +52,7 @@ public class BranchesClientTests public async Task ProtectsBranch() { // Set master branch to be protected, with some status checks - var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List() { "check1", "check2", "check3" }); + var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List { "check1", "check2", "check3" }); var update = new BranchUpdate(); update.Protection = new BranchProtection(true, requiredStatusChecks); @@ -77,7 +77,7 @@ public class BranchesClientTests await CreateTheWorld(); // Remove status check enforcement - var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Off, new List() { "check1" }); + var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Off, new List { "check1" }); var update = new BranchUpdate(); update.Protection = new BranchProtection(true, requiredStatusChecks); @@ -103,7 +103,7 @@ public class BranchesClientTests // Unprotect branch // Deliberately set Enforcement and Contexts to some values (these should be ignored) - var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List() { "check1" }); + var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List { "check1" }); var update = new BranchUpdate(); update.Protection = new BranchProtection(false, requiredStatusChecks); diff --git a/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs b/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs index af308d6f..8cc015ff 100644 --- a/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs @@ -1,9 +1,10 @@ using System; +using System.Collections.Generic; using System.Threading.Tasks; using Octokit; using Octokit.Tests.Integration; -using Xunit; using Octokit.Tests.Integration.Helpers; +using Xunit; public class DeploymentsClientTests : IDisposable { @@ -40,6 +41,40 @@ public class DeploymentsClientTests : IDisposable _commit = github.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit).Result; } + private IEnumerable CreateCommits(int commitCount) + { + var github = Helper.GetAuthenticatedClient(); + + var list = new List(); + + for (int i = 0; i < commitCount; i++) + { + var blob = new NewBlob + { + Content = string.Format("Hello World {0}!", i), + Encoding = EncodingType.Utf8 + }; + + var blobResult = github.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob).Result; + + var newTree = new NewTree(); + newTree.Tree.Add(new NewTreeItem + { + Type = TreeType.Blob, + Mode = FileMode.File, + Path = "README.md", + Sha = blobResult.Sha + }); + + var treeResult = github.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree).Result; + var newCommit = new NewCommit("test-commit", treeResult.Sha); + var commit = github.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit).Result; + list.Add(commit); + } + + return list; + } + [IntegrationTest] public async Task CanCreateDeployment() { @@ -51,7 +86,7 @@ public class DeploymentsClientTests : IDisposable } [IntegrationTest] - public async Task CanGetDeployments() + public async Task ReturnsDeployments() { var newDeployment = new NewDeployment(_commit.Sha) { AutoMerge = false }; await _deploymentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newDeployment); @@ -61,6 +96,81 @@ public class DeploymentsClientTests : IDisposable Assert.NotEmpty(deployments); } + [IntegrationTest] + public async Task ReturnsCorrectCountOfDeploymentsWithoutStart() + { + var commits = CreateCommits(6); + foreach (var commit in commits) + { + var newDeployment = new NewDeployment(commit.Sha) { AutoMerge = false }; + await _deploymentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newDeployment); + } + + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var releases = await _deploymentsClient.GetAll(_context.RepositoryOwner, _context.RepositoryName, options); + + Assert.Equal(5, releases.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfDeploymentsWithStart() + { + var commits = CreateCommits(6); + foreach (var commit in commits) + { + var newDeployment = new NewDeployment(commit.Sha) { AutoMerge = false }; + await _deploymentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newDeployment); + } + + var options = new ApiOptions + { + PageSize = 3, + PageCount = 1, + StartPage = 2 + }; + + var releases = await _deploymentsClient.GetAll(_context.RepositoryOwner, _context.RepositoryName, options); + + Assert.Equal(3, releases.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var commits = CreateCommits(6); + foreach (var commit in commits) + { + var newDeployment = new NewDeployment(commit.Sha) { AutoMerge = false }; + await _deploymentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newDeployment); + } + + var startOptions = new ApiOptions + { + PageSize = 3, + PageCount = 1 + }; + + var firstPage = await _deploymentsClient.GetAll(_context.RepositoryOwner, _context.RepositoryName, startOptions); + + var skipStartOptions = new ApiOptions + { + PageSize = 3, + PageCount = 1, + StartPage = 2 + }; + + var secondPage = await _deploymentsClient.GetAll(_context.RepositoryOwner, _context.RepositoryName, skipStartOptions); + + Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); + Assert.NotEqual(firstPage[1].Id, secondPage[1].Id); + Assert.NotEqual(firstPage[2].Id, secondPage[2].Id); + } + public void Dispose() { _context.Dispose(); diff --git a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs index 416a8961..b8ae2d64 100644 --- a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs @@ -61,6 +61,24 @@ public class IssuesClientTests : IDisposable } [IntegrationTest] + public async Task CanLockAndUnlockIssue() + { + var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; + var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); + Assert.False(issue.Locked); + + await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + var retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + Assert.NotNull(retrieved); + Assert.True(retrieved.Locked); + + await _issuesClient.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + Assert.NotNull(retrieved); + Assert.False(retrieved.Locked); + } + + [IntegrationTest] public async Task CanListOpenIssuesWithDefaultSort() { var newIssue1 = new NewIssue("A test issue1") { Body = "A new unassigned issue" }; @@ -279,7 +297,7 @@ public class IssuesClientTests : IDisposable var newIssue = new NewIssue("A test issue1") { - Body = "A new unassigned issue", + Body = "A new unassigned issue" }; newIssue.Labels.Add("something"); @@ -302,7 +320,7 @@ public class IssuesClientTests : IDisposable // setup us the issue var newIssue = new NewIssue("A test issue1") { - Body = "A new unassigned issue", + Body = "A new unassigned issue" }; newIssue.Labels.Add("something"); @@ -327,7 +345,7 @@ public class IssuesClientTests : IDisposable // setup us the issue var newIssue = new NewIssue("A test issue1") { - Body = "A new unassigned issue", + Body = "A new unassigned issue" }; newIssue.Labels.Add("something"); newIssue.Labels.Add("another thing"); diff --git a/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs b/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs index b13fd3a9..a6ec1944 100644 --- a/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs +++ b/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs @@ -113,6 +113,11 @@ public class MiscellaneousClientTests var result = await github.Miscellaneous.GetMetadata(); Assert.True(result.VerifiablePasswordAuthentication); + Assert.NotEmpty(result.GitHubServicesSha); + Assert.True(result.Hooks.Count > 0); + Assert.True(result.Git.Count > 0); + Assert.True(result.Pages.Count > 0); + Assert.True(result.Importer.Count > 0); } } } \ No newline at end of file diff --git a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs index f1af40d1..92d38d2f 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs @@ -249,7 +249,7 @@ public class PullRequestReviewCommentsClientTests : IDisposable var data = new PullRequestData { Sha = createdCommitInBranch.Sha, - Number = createdPullRequest.Number, + Number = createdPullRequest.Number }; return data; @@ -273,7 +273,7 @@ public class PullRequestReviewCommentsClientTests : IDisposable Type = TreeType.Blob, Mode = FileMode.File, Path = treePath, - Sha = createdBlob.Sha, + Sha = createdBlob.Sha }); var createdTree = await _github.Git.Tree.Create(Helper.UserName, repoName, newTree); diff --git a/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs b/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs index 7e0a4827..0f15e76c 100644 --- a/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs @@ -2,7 +2,6 @@ using System.Linq; using System.Threading.Tasks; using Octokit; -using Octokit.Tests.Helpers; using Octokit.Tests.Integration; using Xunit; using Octokit.Tests.Integration.Helpers; @@ -37,7 +36,7 @@ public class ReferencesClientTests : IDisposable } [IntegrationTest] - public async Task WhenReferenceDoesNotExistAnExeptionIsThrown() + public async Task WhenReferenceDoesNotExistAnExceptionIsThrown() { await Assert.ThrowsAsync( () => _fixture.Get("octokit", "octokit.net", "heads/foofooblahblah")); diff --git a/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs b/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs index 34892219..fcd28c0c 100644 --- a/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs @@ -12,6 +12,16 @@ using Xunit; public class ReleasesClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ReleasesClient(null)); + } + } + public class TheGetReleasesMethod : IDisposable { private readonly IReleasesClient _releaseClient; @@ -319,9 +329,9 @@ public class ReleasesClientTests using (var zipstream = new MemoryStream((byte[])response.Body)) using (var archive = new ZipArchive(zipstream)) { - var enttry = archive.Entries[0]; - var data = new byte[enttry.Length]; - await enttry.Open().ReadAsync(data, 0, data.Length); + var entry = archive.Entries[0]; + var data = new byte[entry.Length]; + await entry.Open().ReadAsync(data, 0, data.Length); textContent = Encoding.ASCII.GetString(data); } diff --git a/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs index 83401a3e..d6f61a20 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs @@ -20,6 +20,13 @@ public class RepositoryCommitsClientTests _fixture = client.Repository.Commit; } + [IntegrationTest] + public async Task CanGetMergeBaseCommit() + { + var compareResult = await _fixture.Compare("octokit", "octokit.net", "65a22f4d2cff94a286ac3e96440c810c5509196f", "65a22f4d2cff94a286ac3e96440c810c5509196f"); + Assert.NotNull(compareResult.MergeBaseCommit); + } + [IntegrationTest] public async Task CanGetCommit() { @@ -42,6 +49,59 @@ public class RepositoryCommitsClientTests Assert.NotEmpty(list); } + [IntegrationTest] + public async Task CanGetCorrectCountOfCommitsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var commits = await _fixture.GetAll("shiftkey", "ReactiveGit", options); + Assert.Equal(5, commits.Count); + } + + [IntegrationTest] + public async Task CanGetCorrectCountOfCommitsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var commits = await _fixture.GetAll("shiftkey", "ReactiveGit", options); + Assert.Equal(5, commits.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStart() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var firstCommit = await _fixture.GetAll("shiftkey", "ReactiveGit", startOptions); + var secondCommit = await _fixture.GetAll("shiftkey", "ReactiveGit", skipStartOptions); + + Assert.NotEqual(firstCommit[0].Sha, secondCommit[0].Sha); + Assert.NotEqual(firstCommit[1].Sha, secondCommit[1].Sha); + Assert.NotEqual(firstCommit[2].Sha, secondCommit[2].Sha); + Assert.NotEqual(firstCommit[3].Sha, secondCommit[3].Sha); + Assert.NotEqual(firstCommit[4].Sha, secondCommit[4].Sha); + } + [IntegrationTest] public async Task CanGetListOfCommitsBySha() { diff --git a/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs index 998770f5..78487674 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs @@ -24,7 +24,7 @@ public class RepositoryDeployKeysClientTests : IDisposable [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for investigating this failing test")] public async Task CanCreateADeployKey() { - var deployKey = new NewDeployKey() + var deployKey = new NewDeployKey { Key = _key, Title = _keyTitle @@ -42,7 +42,7 @@ public class RepositoryDeployKeysClientTests : IDisposable var deployKeys = await _fixture.GetAll(_context.RepositoryOwner, _context.RepositoryName); Assert.Equal(0, deployKeys.Count); - var deployKey = new NewDeployKey() + var deployKey = new NewDeployKey { Key = _key, Title = _keyTitle @@ -59,7 +59,7 @@ public class RepositoryDeployKeysClientTests : IDisposable [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for the resolution to this failing test")] public async Task CanRetrieveADeployKey() { - var newDeployKey = new NewDeployKey() + var newDeployKey = new NewDeployKey { Key = _key, Title = _keyTitle @@ -76,7 +76,7 @@ public class RepositoryDeployKeysClientTests : IDisposable [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for the resolution to this failing test")] public async Task CanRemoveADeployKey() { - var newDeployKey = new NewDeployKey() + var newDeployKey = new NewDeployKey { Key = _key, Title = _keyTitle diff --git a/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs index 84c849f8..3f7c5af7 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs @@ -1,5 +1,4 @@ -using System; -using System.Linq; +using System.Linq; using System.Threading.Tasks; using Xunit; @@ -41,7 +40,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task ForkCreatedForUserLoggedIn() { - // The fork is created asynchronially by github and therefore it cannot + // The fork is created asynchronously by github and therefore it cannot // be certain that the repo exists when the test ends. It is therefore deleted // before the test starts instead of after. Helper.DeleteRepo(Helper.Credentials.Login, "octokit.net"); @@ -58,7 +57,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task ForkCreatedForOrganization() { - // The fork is created asynchronially by github and therefore it cannot + // The fork is created asynchronously by github and therefore it cannot // be certain that the repo exists when the test ends. It is therefore deleted // before the test starts. Helper.DeleteRepo(Helper.Organization, "octokit.net"); diff --git a/Octokit.Tests.Integration/Clients/RepositoryHooksClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryHooksClientTests.cs index d0fd6c6e..35c1f68d 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryHooksClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryHooksClientTests.cs @@ -25,11 +25,70 @@ namespace Octokit.Tests.Integration.Clients var hooks = await github.Repository.Hooks.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName); - Assert.Single(hooks); - var actualHook = hooks[0]; + Assert.Equal(_fixture.ExpectedHooks.Count, hooks.Count); + var actualHook = hooks[0]; AssertHook(_fixture.ExpectedHook, actualHook); } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfHooksWithoutStart() + { + var github = Helper.GetAuthenticatedClient(); + + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var hooks = await github.Repository.Hooks.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, options); + + Assert.Equal(_fixture.ExpectedHooks.Count, hooks.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfHooksWithStart() + { + var github = Helper.GetAuthenticatedClient(); + + var options = new ApiOptions + { + PageSize = 2, + PageCount = 1, + StartPage = 3 + }; + + var hooks = await github.Repository.Hooks.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, options); + + Assert.Equal(1, hooks.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var github = Helper.GetAuthenticatedClient(); + + var startOptions = new ApiOptions + { + PageSize = 2, + PageCount = 1 + }; + + var firstPage = await github.Repository.Hooks.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, startOptions); + + var skipStartOptions = new ApiOptions + { + PageSize = 2, + PageCount = 1, + StartPage = 2 + }; + + var secondPage = await github.Repository.Hooks.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, skipStartOptions); + + Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); + Assert.NotEqual(firstPage[1].Id, secondPage[1].Id); + } } [Collection(RepositoriesHooksCollection.Name)] diff --git a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs index 1e653c79..a80a6da0 100644 --- a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs @@ -48,7 +48,7 @@ public class TeamsClientTests public class TheGetAllForCurrentMethod { [IntegrationTest] - public async Task GetsIsMemberWhenAuthenticated() + public async Task GetsAllForCurrentWhenAuthenticated() { var github = Helper.GetAuthenticatedClient(); var teams = await github.Organization.Team.GetAllForCurrent(); diff --git a/Octokit.Tests.Integration/Clients/UserAdministrationClientTests.cs b/Octokit.Tests.Integration/Clients/UserAdministrationClientTests.cs index b9c049ab..0a68edd2 100644 --- a/Octokit.Tests.Integration/Clients/UserAdministrationClientTests.cs +++ b/Octokit.Tests.Integration/Clients/UserAdministrationClientTests.cs @@ -91,7 +91,7 @@ namespace Octokit.Tests.Integration.Clients // Create Impersonation token var token = await _github.User.Administration.CreateImpersonationToken( context.UserLogin, - new NewImpersonationToken(new string[] { "public_repo" })); + new NewImpersonationToken(new[] { "public_repo" })); Assert.NotNull(token); Assert.True( diff --git a/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs b/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs index 95de0794..8f982e43 100644 --- a/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs +++ b/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs @@ -1,14 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Threading.Tasks; namespace Octokit.Tests.Integration.Helpers { internal static class GithubClientExtensions { - internal async static Task CreateRepositoryContext(this IGitHubClient client, string repositoryName) + internal static async Task CreateRepositoryContext(this IGitHubClient client, string repositoryName) { var repoName = Helper.MakeNameWithTimestamp(repositoryName); var repo = await client.Repository.Create(new NewRepository(repoName) { AutoInit = true }); @@ -16,35 +12,35 @@ namespace Octokit.Tests.Integration.Helpers return new RepositoryContext(repo); } - internal async static Task CreateRepositoryContext(this IGitHubClient client, string organizationLogin, NewRepository newRepository) + internal static async Task CreateRepositoryContext(this IGitHubClient client, string organizationLogin, NewRepository newRepository) { var repo = await client.Repository.Create(organizationLogin, newRepository); return new RepositoryContext(repo); } - internal async static Task CreateRepositoryContext(this IGitHubClient client, NewRepository newRepository) + internal static async Task CreateRepositoryContext(this IGitHubClient client, NewRepository newRepository) { var repo = await client.Repository.Create(newRepository); return new RepositoryContext(repo); } - internal async static Task CreateEnterpriseTeamContext(this IGitHubClient client, string organization, NewTeam newTeam) + internal static async Task CreateEnterpriseTeamContext(this IGitHubClient client, string organization, NewTeam newTeam) { var team = await client.Organization.Team.Create(organization, newTeam); return new EnterpriseTeamContext(team); } - internal async static Task CreateEnterpriseUserContext(this IGitHubClient client, NewUser newUser) + internal static async Task CreateEnterpriseUserContext(this IGitHubClient client, NewUser newUser) { var user = await client.User.Administration.Create(newUser); return new EnterpriseUserContext(user); } - internal async static Task CreatePublicKeyContext(this IGitHubClient client) + internal static async Task CreatePublicKeyContext(this IGitHubClient client) { // Create a key string keyTitle = "title"; diff --git a/Octokit.Tests.Integration/Helpers/ObservableGithubClientExtensions.cs b/Octokit.Tests.Integration/Helpers/ObservableGithubClientExtensions.cs index 8ef1fbbc..f455608a 100644 --- a/Octokit.Tests.Integration/Helpers/ObservableGithubClientExtensions.cs +++ b/Octokit.Tests.Integration/Helpers/ObservableGithubClientExtensions.cs @@ -6,7 +6,7 @@ namespace Octokit.Tests.Integration.Helpers { internal static class ObservableGithubClientExtensions { - internal async static Task CreateRepositoryContext(this IObservableGitHubClient client, string repositoryName) + internal static async Task CreateRepositoryContext(this IObservableGitHubClient client, string repositoryName) { var repoName = Helper.MakeNameWithTimestamp(repositoryName); var repo = await client.Repository.Create(new NewRepository(repoName) { AutoInit = true }); @@ -14,35 +14,35 @@ namespace Octokit.Tests.Integration.Helpers return new RepositoryContext(repo); } - internal async static Task CreateRepositoryContext(this IObservableGitHubClient client, string organizationLogin, NewRepository newRepository) + internal static async Task CreateRepositoryContext(this IObservableGitHubClient client, string organizationLogin, NewRepository newRepository) { var repo = await client.Repository.Create(organizationLogin, newRepository); return new RepositoryContext(repo); } - internal async static Task CreateRepositoryContext(this IObservableGitHubClient client, NewRepository newRepository) + internal static async Task CreateRepositoryContext(this IObservableGitHubClient client, NewRepository newRepository) { var repo = await client.Repository.Create(newRepository); return new RepositoryContext(repo); } - internal async static Task CreateEnterpriseTeamContext(this IObservableGitHubClient client, string organization, NewTeam newTeam) + internal static async Task CreateEnterpriseTeamContext(this IObservableGitHubClient client, string organization, NewTeam newTeam) { var team = await client.Organization.Team.Create(organization, newTeam); return new EnterpriseTeamContext(team); } - internal async static Task CreateEnterpriseUserContext(this IObservableGitHubClient client, NewUser newUser) + internal static async Task CreateEnterpriseUserContext(this IObservableGitHubClient client, NewUser newUser) { var user = await client.User.Administration.Create(newUser); return new EnterpriseUserContext(user); } - internal async static Task CreatePublicKeyContext(this IObservableGitHubClient client) + internal static async Task CreatePublicKeyContext(this IObservableGitHubClient client) { // Create a key string keyTitle = "title"; diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 4181ab35..d790c35a 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -137,10 +137,17 @@ + + + + + + + @@ -148,7 +155,8 @@ - + + diff --git a/Octokit.Tests.Integration/Reactive/ObservableCommitStatusClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableCommitStatusClientTests.cs new file mode 100644 index 00000000..f903f896 --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableCommitStatusClientTests.cs @@ -0,0 +1,85 @@ +using System.Reactive.Linq; +using System.Threading.Tasks; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Integration.Reactive +{ + public class ObservableCommitStatusClientTests + { + public class TheGetAllMethod + { + readonly ObservableCommitStatusClient _commitStatusClient; + const string owner = "octokit"; + const string name = "octokit.net"; + const string reference = "1335f37"; + + public TheGetAllMethod() + { + var github = Helper.GetAuthenticatedClient(); + _commitStatusClient = new ObservableCommitStatusClient(github); + } + + [IntegrationTest] + public async Task ReturnCommitStatus() + { + var commitStatus = await _commitStatusClient.GetAll(owner, name, reference).ToList(); + + Assert.NotEmpty(commitStatus); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfCommitStatusWithoutStart() + { + var options = new ApiOptions + { + PageSize = 2, + PageCount = 1 + }; + + var commitStatus = await _commitStatusClient.GetAll(owner, name ,reference , options).ToList(); + + Assert.Equal(2, commitStatus.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfCommitStatusWithStart() + { + var options = new ApiOptions + { + PageSize = 2, + PageCount = 1, + StartPage = 1 + }; + + var commitStatus = await _commitStatusClient.GetAll(owner, name, reference, options).ToList(); + + Assert.Equal(2, commitStatus.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 2, + PageCount = 1 + }; + + var firstPage = await _commitStatusClient.GetAll(owner, name, reference, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 2, + PageCount = 1, + StartPage = 2 + }; + + var secondPage = await _commitStatusClient.GetAll(owner, name, reference,skipStartOptions).ToList(); + + Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); + Assert.NotEqual(firstPage[1].Id, secondPage[1].Id); + } + } + } +} diff --git a/Octokit.Tests.Integration/Reactive/ObservableEventsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableEventsClientTests.cs new file mode 100644 index 00000000..3308120c --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableEventsClientTests.cs @@ -0,0 +1,699 @@ +using System.Linq; +using System.Reactive.Linq; +using System.Threading.Tasks; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Integration.Reactive +{ + public class ObservableEventsClientTests + { + public class TheGetAllMethod + { + readonly ObservableEventsClient _eventsClient; + + public TheGetAllMethod() + { + _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient()); + } + [IntegrationTest] + public async Task ReturnsEvents() + { + var events = await _eventsClient.GetAll().ToList(); + + Assert.NotEmpty(events); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfEventsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var events = await _eventsClient.GetAll(options).ToList(); + + Assert.Equal(5, events.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfEventsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var events = await _eventsClient.GetAll(options).ToList(); + + Assert.Equal(5, events.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctEventsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstEventsPage = await _eventsClient.GetAll(startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondEventsPage = await _eventsClient.GetAll(skipStartOptions).ToList(); + + Assert.NotEqual(firstEventsPage[0].Id, secondEventsPage[0].Id); + Assert.NotEqual(firstEventsPage[1].Id, secondEventsPage[1].Id); + Assert.NotEqual(firstEventsPage[2].Id, secondEventsPage[2].Id); + Assert.NotEqual(firstEventsPage[3].Id, secondEventsPage[3].Id); + Assert.NotEqual(firstEventsPage[4].Id, secondEventsPage[4].Id); + } + + } + + public class TheGetAllForRepositoryMethod + { + + readonly ObservableEventsClient _eventsClient; + const string owner = "octokit"; + const string name = "octokit.net"; + + public TheGetAllForRepositoryMethod() + { + _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient()); + } + [IntegrationTest] + public async Task ReturnsRepositoryEvents() + { + var repositoryEvents = await _eventsClient.GetAllForRepository(owner, name).ToList(); + + Assert.NotEmpty(repositoryEvents); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfRepositoryEventsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var repositoryEvents = await _eventsClient.GetAllForRepository(owner, name, options).ToList(); + + Assert.Equal(5, repositoryEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfRepositoryEventsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var repositoryEvents = await _eventsClient.GetAllForRepository(owner, name, options).ToList(); + + Assert.Equal(5, repositoryEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctRepositoryEventsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstRepositoryEventsPage = await _eventsClient.GetAllForRepository(owner, name, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondRepositoryEventsPage = await _eventsClient.GetAllForRepository(owner, name, skipStartOptions).ToList(); + + Assert.NotEqual(firstRepositoryEventsPage[0].Id, secondRepositoryEventsPage[0].Id); + Assert.NotEqual(firstRepositoryEventsPage[1].Id, secondRepositoryEventsPage[1].Id); + Assert.NotEqual(firstRepositoryEventsPage[2].Id, secondRepositoryEventsPage[2].Id); + Assert.NotEqual(firstRepositoryEventsPage[3].Id, secondRepositoryEventsPage[3].Id); + Assert.NotEqual(firstRepositoryEventsPage[4].Id, secondRepositoryEventsPage[4].Id); + } + + } + + public class TheGetAllForRepositoryNetworkMethod + { + readonly ObservableEventsClient _eventsClient; + const string owner = "octokit"; + const string name = "octokit.net"; + + public TheGetAllForRepositoryNetworkMethod() + { + _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient()); + } + [IntegrationTest] + public async Task ReturnsRepositoryNetworkEvents() + { + var repositoryNetworkEvents = await _eventsClient.GetAllForRepositoryNetwork(owner, name).ToList(); + + Assert.NotEmpty(repositoryNetworkEvents); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfRepositoryNetworkEventsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var repositoryNetworkEvents = await _eventsClient.GetAllForRepositoryNetwork(owner, name, options).ToList(); + + Assert.Equal(5, repositoryNetworkEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfRepositoryNetworkEventsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var repositoryNetworkEvents = await _eventsClient.GetAllForRepositoryNetwork(owner, name, options).ToList(); + + Assert.Equal(5, repositoryNetworkEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctRepositoryNetworkEventsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstRepositoryNetworkEventsPage = await _eventsClient.GetAllForRepositoryNetwork(owner, name, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondRepositoryNetworkEventsPage = await _eventsClient.GetAllForRepositoryNetwork(owner, name, skipStartOptions).ToList(); + + Assert.NotEqual(firstRepositoryNetworkEventsPage[0].Id, secondRepositoryNetworkEventsPage[0].Id); + Assert.NotEqual(firstRepositoryNetworkEventsPage[1].Id, secondRepositoryNetworkEventsPage[1].Id); + Assert.NotEqual(firstRepositoryNetworkEventsPage[2].Id, secondRepositoryNetworkEventsPage[2].Id); + Assert.NotEqual(firstRepositoryNetworkEventsPage[3].Id, secondRepositoryNetworkEventsPage[3].Id); + Assert.NotEqual(firstRepositoryNetworkEventsPage[4].Id, secondRepositoryNetworkEventsPage[4].Id); + } + + } + + public class TheGetAllForOrganizationMethod + { + + readonly ObservableEventsClient _eventsClient; + const string organization = "octokit"; + + public TheGetAllForOrganizationMethod() + { + _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient()); + } + + [IntegrationTest] + public async Task ReturnsOrganizationEvents() + { + var organizationEvents = await _eventsClient.GetAllForOrganization(organization).ToList(); + + Assert.NotEmpty(organizationEvents); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfOrganizationEventsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var organizationEvents = await _eventsClient.GetAllForOrganization(organization, options).ToList(); + + Assert.Equal(5, organizationEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfOrganizationEventsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var organizationEvents = await _eventsClient.GetAllForOrganization(organization, options).ToList(); + + Assert.Equal(5, organizationEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctOrganizationEventsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstOrganizationEventsPage = await _eventsClient.GetAllForOrganization(organization, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondOrganizationEventsPage = await _eventsClient.GetAllForOrganization(organization, skipStartOptions).ToList(); + + Assert.NotEqual(firstOrganizationEventsPage[0].Id, secondOrganizationEventsPage[0].Id); + Assert.NotEqual(firstOrganizationEventsPage[1].Id, secondOrganizationEventsPage[1].Id); + Assert.NotEqual(firstOrganizationEventsPage[2].Id, secondOrganizationEventsPage[2].Id); + Assert.NotEqual(firstOrganizationEventsPage[3].Id, secondOrganizationEventsPage[3].Id); + Assert.NotEqual(firstOrganizationEventsPage[4].Id, secondOrganizationEventsPage[4].Id); + } + + } + + public class TheGetAllUserReceivedMethod + { + readonly ObservableEventsClient _eventsClient; + const string user = "shiftkey"; + + public TheGetAllUserReceivedMethod() + { + _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient()); + } + + [IntegrationTest] + public async Task ReturnsUserReceivedEvents() + { + var userReceivedEvents = await _eventsClient.GetAllUserReceived(user).ToList(); + + Assert.NotEmpty(userReceivedEvents); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserReceivedEventsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var userReceivedEvents = await _eventsClient.GetAllUserReceived(user, options).ToList(); + + Assert.Equal(5, userReceivedEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserReceivedEventsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var userReceivedEvents = await _eventsClient.GetAllUserReceived(user, options).ToList(); + + Assert.Equal(5, userReceivedEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctUserReceivedEventsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstUserReceivedEventsPage = await _eventsClient.GetAllUserReceived(user, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondUserReceivedEventsPage = await _eventsClient.GetAllUserReceived(user, skipStartOptions).ToList(); + + Assert.NotEqual(firstUserReceivedEventsPage[0].Id, secondUserReceivedEventsPage[0].Id); + Assert.NotEqual(firstUserReceivedEventsPage[1].Id, secondUserReceivedEventsPage[1].Id); + Assert.NotEqual(firstUserReceivedEventsPage[2].Id, secondUserReceivedEventsPage[2].Id); + Assert.NotEqual(firstUserReceivedEventsPage[3].Id, secondUserReceivedEventsPage[3].Id); + Assert.NotEqual(firstUserReceivedEventsPage[4].Id, secondUserReceivedEventsPage[4].Id); + } + } + + public class TheGetAllUserReceivedPublicMethod + { + + readonly ObservableEventsClient _eventsClient; + const string user = "shiftkey"; + + public TheGetAllUserReceivedPublicMethod() + { + _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient()); + } + + [IntegrationTest] + public async Task ReturnsUserReceivedPublicEvents() + { + var userReceivedPublicEvents = await _eventsClient.GetAllUserReceivedPublic(user).ToList(); + + Assert.NotEmpty(userReceivedPublicEvents); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserReceivedPublicEventsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var userReceivedPublicEvents = await _eventsClient.GetAllUserReceivedPublic(user, options).ToList(); + + Assert.Equal(5, userReceivedPublicEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserReceivedPublicEventsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var userReceivedPublicEvents = await _eventsClient.GetAllUserReceivedPublic(user, options).ToList(); + + Assert.Equal(5, userReceivedPublicEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctUserReceivedPublicEventsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstUserReceivedPublicEventsPage = await _eventsClient.GetAllUserReceivedPublic(user, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondUserReceivedPublicEventsPage = await _eventsClient.GetAllUserReceivedPublic(user, skipStartOptions).ToList(); + + Assert.NotEqual(firstUserReceivedPublicEventsPage[0].Id, secondUserReceivedPublicEventsPage[0].Id); + Assert.NotEqual(firstUserReceivedPublicEventsPage[1].Id, secondUserReceivedPublicEventsPage[1].Id); + Assert.NotEqual(firstUserReceivedPublicEventsPage[2].Id, secondUserReceivedPublicEventsPage[2].Id); + Assert.NotEqual(firstUserReceivedPublicEventsPage[3].Id, secondUserReceivedPublicEventsPage[3].Id); + Assert.NotEqual(firstUserReceivedPublicEventsPage[4].Id, secondUserReceivedPublicEventsPage[4].Id); + } + + } + + public class TheGetAllUserPerformedMethod + { + readonly ObservableEventsClient _eventsClient; + const string user = "shiftkey"; + + public TheGetAllUserPerformedMethod() + { + _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient()); + } + + [IntegrationTest] + public async Task ReturnsUserPerformedEvents() + { + var userPerformedEvents = await _eventsClient.GetAllUserPerformed(user).ToList(); + + Assert.NotEmpty(userPerformedEvents); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserPerformedEventsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var userPerformedEvents = await _eventsClient.GetAllUserPerformed(user, options).ToList(); + + Assert.Equal(5, userPerformedEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserPerformedEventsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var userPerformedEvents = await _eventsClient.GetAllUserPerformed(user, options).ToList(); + + Assert.Equal(5, userPerformedEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctUserPerformedEventsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstUserPerformedEventsPage = await _eventsClient.GetAllUserPerformed(user, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondUserPerformedEventsPage = await _eventsClient.GetAllUserPerformed(user, skipStartOptions).ToList(); + + Assert.NotEqual(firstUserPerformedEventsPage[0].Id, secondUserPerformedEventsPage[0].Id); + Assert.NotEqual(firstUserPerformedEventsPage[1].Id, secondUserPerformedEventsPage[1].Id); + Assert.NotEqual(firstUserPerformedEventsPage[2].Id, secondUserPerformedEventsPage[2].Id); + Assert.NotEqual(firstUserPerformedEventsPage[3].Id, secondUserPerformedEventsPage[3].Id); + Assert.NotEqual(firstUserPerformedEventsPage[4].Id, secondUserPerformedEventsPage[4].Id); + } + + } + + public class TheGetAllUserPerformedPublicMethod + { + readonly ObservableEventsClient _eventsClient; + const string user = "shiftkey"; + + public TheGetAllUserPerformedPublicMethod() + { + _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient()); + } + + [IntegrationTest] + public async Task ReturnsUserPerformedPublicEvents() + { + var userPerformedPublicEvents = await _eventsClient.GetAllUserPerformedPublic(user).ToList(); + + Assert.NotEmpty(userPerformedPublicEvents); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserPerformedPublicEventsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var userPerformedPublicEvents = await _eventsClient.GetAllUserPerformedPublic(user, options).ToList(); + + Assert.Equal(5, userPerformedPublicEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserPerformedPublicEventsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var userPerformedPublicEvents = await _eventsClient.GetAllUserPerformedPublic(user, options).ToList(); + + Assert.Equal(5, userPerformedPublicEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctUserPerformedPublicEventsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstUserPerformedPublicEventsPage = await _eventsClient.GetAllUserPerformedPublic(user, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondUserPerformedPublicEventsPage = await _eventsClient.GetAllUserPerformedPublic(user, skipStartOptions).ToList(); + + Assert.NotEqual(firstUserPerformedPublicEventsPage[0].Id, secondUserPerformedPublicEventsPage[0].Id); + Assert.NotEqual(firstUserPerformedPublicEventsPage[1].Id, secondUserPerformedPublicEventsPage[1].Id); + Assert.NotEqual(firstUserPerformedPublicEventsPage[2].Id, secondUserPerformedPublicEventsPage[2].Id); + Assert.NotEqual(firstUserPerformedPublicEventsPage[3].Id, secondUserPerformedPublicEventsPage[3].Id); + Assert.NotEqual(firstUserPerformedPublicEventsPage[4].Id, secondUserPerformedPublicEventsPage[4].Id); + } + + } + + public class TheGetAllForAnOrganizationMethod + { + readonly ObservableEventsClient _eventsClient; + readonly string _organization; + readonly string _user; + + public TheGetAllForAnOrganizationMethod() + { + var github = Helper.GetAuthenticatedClient(); + _eventsClient = new ObservableEventsClient(github); + _user = Helper.UserName; + _organization = Helper.Organization; + } + + [IntegrationTest] + public async Task ReturnsUserOrganizationEvents() + { + var userOrganizationEvents = await _eventsClient.GetAllForAnOrganization(_user,_organization).ToList(); + + Assert.NotEmpty(userOrganizationEvents); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserOrganizationEventsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var userOrganizationEvents = await _eventsClient.GetAllForAnOrganization(_user, _organization, options).ToList(); + + Assert.Equal(5, userOrganizationEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserOrganizationEventsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var userOrganizationEvents = await _eventsClient.GetAllForAnOrganization(_user, _organization, options).ToList(); + + Assert.Equal(5, userOrganizationEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctUserOrganizationEventsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstUserOrganizationEventsPage = await _eventsClient.GetAllForAnOrganization(_user, _organization, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondUserOrganizationEventsPage = await _eventsClient.GetAllForAnOrganization(_user, _organization, skipStartOptions).ToList(); + + Assert.NotEqual(firstUserOrganizationEventsPage[0].Id, secondUserOrganizationEventsPage[0].Id); + Assert.NotEqual(firstUserOrganizationEventsPage[1].Id, secondUserOrganizationEventsPage[1].Id); + Assert.NotEqual(firstUserOrganizationEventsPage[2].Id, secondUserOrganizationEventsPage[2].Id); + Assert.NotEqual(firstUserOrganizationEventsPage[3].Id, secondUserOrganizationEventsPage[3].Id); + Assert.NotEqual(firstUserOrganizationEventsPage[4].Id, secondUserOrganizationEventsPage[4].Id); + } + + } + } +} diff --git a/Octokit.Tests.Integration/Reactive/ObservableFollowersClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableFollowersClientTests.cs new file mode 100644 index 00000000..6b3e61dc --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableFollowersClientTests.cs @@ -0,0 +1,305 @@ +using System.Reactive.Linq; +using System.Threading.Tasks; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Integration.Reactive +{ + public class ObservableFollowersClientTests + { + public class TheGetAllForCurrentMethod + { + readonly ObservableFollowersClient _followersClient; + + public TheGetAllForCurrentMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _followersClient = new ObservableFollowersClient(github); + } + + [IntegrationTest] + public async Task ReturnsFollowers() + { + var followers = await _followersClient.GetAllForCurrent().ToList(); + + Assert.NotEmpty(followers); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfFollowersWithoutStart() + { + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1 + }; + + var followers = await _followersClient.GetAllForCurrent(options).ToList(); + + Assert.Equal(1, followers.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfFollowersWithStart() + { + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + var followers = await _followersClient.GetAllForCurrent(options).ToList(); + + Assert.Equal(1, followers.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 1, + PageCount = 1 + }; + + var firstFollowersPage = await _followersClient.GetAllForCurrent(startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 2 + }; + + var secondFollowersPage = await _followersClient.GetAllForCurrent(skipStartOptions).ToList(); + + Assert.NotEqual(firstFollowersPage[0].Id, secondFollowersPage[0].Id); + } + } + + public class TheGetAllMethod + { + readonly ObservableFollowersClient _followersClient; + const string login = "samthedev"; + + public TheGetAllMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _followersClient = new ObservableFollowersClient(github); + } + + [IntegrationTest] + public async Task ReturnsFollowers() + { + var followers = await _followersClient.GetAll(login).ToList(); + + Assert.NotEmpty(followers); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfFollowersWithoutStart() + { + var options = new ApiOptions + { + PageSize = 3, + PageCount = 1 + }; + + var followers = await _followersClient.GetAll(login, options).ToList(); + + Assert.Equal(3, followers.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfFollowersWithStart() + { + var options = new ApiOptions + { + PageSize = 2, + PageCount = 1, + StartPage = 1 + }; + + var followers = await _followersClient.GetAll(login, options).ToList(); + + Assert.Equal(2, followers.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 2, + PageCount = 1 + }; + + var firstFollowersPage = await _followersClient.GetAll(login, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 2, + PageCount = 1, + StartPage = 2 + }; + + var secondFollowersPage = await _followersClient.GetAll(login, skipStartOptions).ToList(); + + Assert.NotEqual(firstFollowersPage[0].Id, secondFollowersPage[0].Id); + Assert.NotEqual(firstFollowersPage[1].Id, secondFollowersPage[1].Id); + } + } + + public class TheGetAllFollowingForCurrentMethod + { + readonly ObservableFollowersClient _followersClient; + + public TheGetAllFollowingForCurrentMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _followersClient = new ObservableFollowersClient(github); + } + + [IntegrationTest] + public async Task ReturnsFollowing() + { + var following = await _followersClient.GetAllFollowingForCurrent().ToList(); + + Assert.NotEmpty(following); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfFollowingWithoutStart() + { + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1 + }; + + var following = await _followersClient.GetAllFollowingForCurrent(options).ToList(); + + Assert.Equal(1, following.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfFollowingWithStart() + { + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + var following = await _followersClient.GetAllFollowingForCurrent(options).ToList(); + + Assert.Equal(1, following.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 1, + PageCount = 1 + }; + + var firstFollowingPage = await _followersClient.GetAllFollowingForCurrent(startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 2 + }; + + var secondFollowingPage = await _followersClient.GetAllFollowingForCurrent(skipStartOptions).ToList(); + + Assert.NotEqual(firstFollowingPage[0].Id, secondFollowingPage[0].Id); + } + } + + public class TheGetAllFollowingMethod + { + readonly ObservableFollowersClient _followersClient; + const string login = "samthedev"; + + public TheGetAllFollowingMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _followersClient = new ObservableFollowersClient(github); + } + + [IntegrationTest] + public async Task ReturnsFollowing() + { + var following = await _followersClient.GetAllFollowing(login).ToList(); + + Assert.NotEmpty(following); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfFollowingWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var following = await _followersClient.GetAllFollowing(login, options).ToList(); + + Assert.Equal(5, following.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfFollowingWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 1 + }; + + var following = await _followersClient.GetAllFollowing(login, options).ToList(); + + Assert.Equal(5, following.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstFollowingPage = await _followersClient.GetAllFollowing(login, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondFollowingPage = await _followersClient.GetAllFollowing(login, skipStartOptions).ToList(); + + Assert.NotEqual(firstFollowingPage[0].Id, secondFollowingPage[0].Id); + Assert.NotEqual(firstFollowingPage[1].Id, secondFollowingPage[1].Id); + Assert.NotEqual(firstFollowingPage[2].Id, secondFollowingPage[2].Id); + Assert.NotEqual(firstFollowingPage[3].Id, secondFollowingPage[3].Id); + Assert.NotEqual(firstFollowingPage[4].Id, secondFollowingPage[4].Id); + } + } + } +} diff --git a/Octokit.Tests.Integration/Reactive/ObservableGistClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableGistClientTests.cs new file mode 100644 index 00000000..0dbd1975 --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableGistClientTests.cs @@ -0,0 +1,720 @@ +using System; +using System.Reactive.Linq; +using System.Threading.Tasks; +using Octokit; +using Octokit.Reactive; +using Octokit.Tests.Integration; +using Xunit; + +public class ObservableGistClientTests +{ + public class TheGetAllMethod + { + readonly ObservableGistsClient _gistsClient; + + public TheGetAllMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _gistsClient = new ObservableGistsClient(github); + } + + [IntegrationTest] + public async Task ReturnsGists() + { + var gists = await _gistsClient.GetAll().ToList(); + + Assert.NotEmpty(gists); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfGistsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var gists = await _gistsClient.GetAll(options).ToList(); + + Assert.Equal(5, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfGistsWithStart() + { + var options = new ApiOptions + { + PageSize = 4, + PageCount = 1, + StartPage = 2 + }; + + var gists = await _gistsClient.GetAll(options).ToList(); + + Assert.Equal(4, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 4, + PageCount = 1 + }; + + var firstGistsPage = await _gistsClient.GetAll(startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 4, + PageCount = 1, + StartPage = 2 + }; + + var secondGistsPage = await _gistsClient.GetAll(skipStartOptions).ToList(); + + Assert.NotEqual(firstGistsPage[0].Id, secondGistsPage[0].Id); + Assert.NotEqual(firstGistsPage[1].Id, secondGistsPage[1].Id); + Assert.NotEqual(firstGistsPage[2].Id, secondGistsPage[2].Id); + Assert.NotEqual(firstGistsPage[3].Id, secondGistsPage[3].Id); + } + + [IntegrationTest] + public async Task ReturnsGistsSince() + { + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAll(since).ToList(); + + Assert.NotEmpty(gists); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfGistsSinceWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAll(since, options).ToList(); + + Assert.Equal(5, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfGistsSinceWithStart() + { + var options = new ApiOptions + { + PageSize = 4, + PageCount = 1, + StartPage = 2 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAll(since, options).ToList(); + + Assert.Equal(4, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctGistsSinceBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 4, + PageCount = 1 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var firstGistsPage = await _gistsClient.GetAll(since, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 4, + PageCount = 1, + StartPage = 2 + }; + + var secondGistsPage = await _gistsClient.GetAll(since, skipStartOptions).ToList(); + + Assert.NotEqual(firstGistsPage[0].Id, secondGistsPage[0].Id); + Assert.NotEqual(firstGistsPage[1].Id, secondGistsPage[1].Id); + Assert.NotEqual(firstGistsPage[2].Id, secondGistsPage[2].Id); + Assert.NotEqual(firstGistsPage[3].Id, secondGistsPage[3].Id); + } + } + + public class TheGetAllPublicMethod + { + readonly ObservableGistsClient _gistsClient; + + public TheGetAllPublicMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _gistsClient = new ObservableGistsClient(github); + } + + [IntegrationTest] + public async Task ReturnsPublicGists() + { + var gists = await _gistsClient.GetAllPublic().ToList(); + + Assert.NotEmpty(gists); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfPublicGistsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var gists = await _gistsClient.GetAllPublic(options).ToList(); + + Assert.Equal(5, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfPublicGistsWithStart() + { + var options = new ApiOptions + { + PageSize = 4, + PageCount = 1, + StartPage = 2 + }; + + var gists = await _gistsClient.GetAllPublic(options).ToList(); + + Assert.Equal(4, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 4, + PageCount = 1 + }; + + var firstPublicGistsPage = await _gistsClient.GetAllPublic(startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 4, + PageCount = 1, + StartPage = 2 + }; + + var secondPublicGistsPage = await _gistsClient.GetAllPublic(skipStartOptions).ToList(); + + Assert.NotEqual(firstPublicGistsPage[0].Id, secondPublicGistsPage[0].Id); + Assert.NotEqual(firstPublicGistsPage[1].Id, secondPublicGistsPage[1].Id); + Assert.NotEqual(firstPublicGistsPage[2].Id, secondPublicGistsPage[2].Id); + Assert.NotEqual(firstPublicGistsPage[3].Id, secondPublicGistsPage[3].Id); + } + + [IntegrationTest] + public async Task ReturnsPublicGistsSince() + { + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAllPublic(since).ToList(); + + Assert.NotEmpty(gists); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfPublicGistsSinceWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAllPublic(since, options).ToList(); + + Assert.Equal(5, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfPublicGistsSinceWithStart() + { + var options = new ApiOptions + { + PageSize = 4, + PageCount = 1, + StartPage = 2 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAllPublic(since, options).ToList(); + + Assert.Equal(4, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctPublicGistsSinceBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 4, + PageCount = 1 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var firstPublicGistsPage = await _gistsClient.GetAllPublic(since, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 4, + PageCount = 1, + StartPage = 2 + }; + + var secondPublicGistsPage = await _gistsClient.GetAllPublic(since, skipStartOptions).ToList(); + + Assert.NotEqual(firstPublicGistsPage[0].Id, secondPublicGistsPage[0].Id); + Assert.NotEqual(firstPublicGistsPage[1].Id, secondPublicGistsPage[1].Id); + Assert.NotEqual(firstPublicGistsPage[2].Id, secondPublicGistsPage[2].Id); + Assert.NotEqual(firstPublicGistsPage[3].Id, secondPublicGistsPage[3].Id); + } + } + + public class TheGetAllStarredMethod + { + readonly ObservableGistsClient _gistsClient; + + public TheGetAllStarredMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _gistsClient = new ObservableGistsClient(github); + } + + [IntegrationTest] + public async Task ReturnsStartedGists() + { + var gists = await _gistsClient.GetAllStarred().ToList(); + + Assert.NotEmpty(gists); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfStartedGistsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var gists = await _gistsClient.GetAllStarred(options).ToList(); + + Assert.Equal(5, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfStartedGistsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var gists = await _gistsClient.GetAllStarred(options).ToList(); + + Assert.Equal(5, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstStartedGistsPage = await _gistsClient.GetAllStarred(startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondStartedGistsPage = await _gistsClient.GetAllStarred(skipStartOptions).ToList(); + + Assert.NotEqual(firstStartedGistsPage[0].Id, secondStartedGistsPage[0].Id); + Assert.NotEqual(firstStartedGistsPage[1].Id, secondStartedGistsPage[1].Id); + Assert.NotEqual(firstStartedGistsPage[2].Id, secondStartedGistsPage[2].Id); + Assert.NotEqual(firstStartedGistsPage[3].Id, secondStartedGistsPage[3].Id); + Assert.NotEqual(firstStartedGistsPage[4].Id, secondStartedGistsPage[4].Id); + } + + [IntegrationTest] + public async Task ReturnsStartedGistsSince() + { + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAllStarred(since).ToList(); + + Assert.NotEmpty(gists); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfStartedGistsSinceWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAllStarred(since, options).ToList(); + + Assert.Equal(5, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfStartedGistsSinceWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAllStarred(since, options).ToList(); + + Assert.Equal(5, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctStartedGistsSinceBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var firstStartedGistsPage = await _gistsClient.GetAllStarred(since, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondStartedGistsPage = await _gistsClient.GetAllStarred(since, skipStartOptions).ToList(); + + Assert.NotEqual(firstStartedGistsPage[0].Id, secondStartedGistsPage[0].Id); + Assert.NotEqual(firstStartedGistsPage[1].Id, secondStartedGistsPage[1].Id); + Assert.NotEqual(firstStartedGistsPage[2].Id, secondStartedGistsPage[2].Id); + Assert.NotEqual(firstStartedGistsPage[3].Id, secondStartedGistsPage[3].Id); + Assert.NotEqual(firstStartedGistsPage[4].Id, secondStartedGistsPage[4].Id); + } + } + + public class TheGetAllForUserMethod + { + readonly ObservableGistsClient _gistsClient; + const string user = "shiftkey"; + + public TheGetAllForUserMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _gistsClient = new ObservableGistsClient(github); + } + + [IntegrationTest] + public async Task ReturnsUserGists() + { + var gists = await _gistsClient.GetAllForUser(user).ToList(); + + Assert.NotEmpty(gists); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserGistsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 3, + PageCount = 1 + }; + + var gists = await _gistsClient.GetAllForUser(user, options).ToList(); + + Assert.Equal(3, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserGistsWithStart() + { + var options = new ApiOptions + { + PageSize = 3, + PageCount = 1, + StartPage = 2 + }; + + var gists = await _gistsClient.GetAllForUser(user, options).ToList(); + + Assert.Equal(3, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 3, + PageCount = 1 + }; + + var firstUsersGistsPage = await _gistsClient.GetAllForUser(user, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 3, + PageCount = 1, + StartPage = 2 + }; + + var secondUsersGistsPage = await _gistsClient.GetAllForUser(user, skipStartOptions).ToList(); + + Assert.NotEqual(firstUsersGistsPage[0].Id, secondUsersGistsPage[0].Id); + Assert.NotEqual(firstUsersGistsPage[1].Id, secondUsersGistsPage[1].Id); + Assert.NotEqual(firstUsersGistsPage[2].Id, secondUsersGistsPage[2].Id); + } + + [IntegrationTest] + public async Task ReturnsUserGistsSince() + { + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAllForUser(user, since).ToList(); + + Assert.NotEmpty(gists); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserGistsSinceWithoutStart() + { + var options = new ApiOptions + { + PageSize = 3, + PageCount = 1 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAllForUser(user, since, options).ToList(); + + Assert.Equal(3, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserGistsSinceWithStart() + { + var options = new ApiOptions + { + PageSize = 3, + PageCount = 1, + StartPage = 2 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAllForUser(user, since, options).ToList(); + + Assert.Equal(3, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctUserGistsSinceBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 3, + PageCount = 1 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var firstUserGistsPage = await _gistsClient.GetAllForUser(user, since, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 3, + PageCount = 1, + StartPage = 2 + }; + + var secondUserGistsPage = await _gistsClient.GetAllForUser(user, since, skipStartOptions).ToList(); + + Assert.NotEqual(firstUserGistsPage[0].Id, secondUserGistsPage[0].Id); + Assert.NotEqual(firstUserGistsPage[1].Id, secondUserGistsPage[1].Id); + Assert.NotEqual(firstUserGistsPage[2].Id, secondUserGistsPage[2].Id); + } + } + + public class TheGetAllCommitsMethod + { + readonly ObservableGistsClient _gistsClient; + const string gistId = "670c22f3966e662d2f83"; + + public TheGetAllCommitsMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _gistsClient = new ObservableGistsClient(github); + } + + [IntegrationTest] + public async Task ReturnsGistCommits() + { + var gistCommits = await _gistsClient.GetAllCommits(gistId).ToList(); + + Assert.NotEmpty(gistCommits); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfGistCommisWithoutStart() + { + var options = new ApiOptions + { + PageSize = 3, + PageCount = 1 + }; + + var gistCommits = await _gistsClient.GetAllCommits(gistId, options).ToList(); + + Assert.Equal(3, gistCommits.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountGistCommitsWithStart() + { + var options = new ApiOptions + { + PageSize = 3, + PageCount = 1, + StartPage = 2 + }; + + var gistCommits = await _gistsClient.GetAllCommits(gistId, options).ToList(); + + Assert.Equal(3, gistCommits.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 3, + PageCount = 1 + }; + + var firstGistCommitsPage = await _gistsClient.GetAllCommits(gistId, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 3, + PageCount = 1, + StartPage = 2 + }; + + var secondGistCommitsPage = await _gistsClient.GetAllCommits(gistId, skipStartOptions).ToList(); + + Assert.NotEqual(firstGistCommitsPage[0].Url, secondGistCommitsPage[0].Url); + Assert.NotEqual(firstGistCommitsPage[1].Url, secondGistCommitsPage[1].Url); + Assert.NotEqual(firstGistCommitsPage[2].Url, secondGistCommitsPage[2].Url); + } + } + + public class TheGetAllForksMethod + { + readonly ObservableGistsClient _gistsClient; + const string gistId = "670c22f3966e662d2f83"; + + public TheGetAllForksMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _gistsClient = new ObservableGistsClient(github); + } + + [IntegrationTest] + public async Task ReturnsGistCommits() + { + var gistForks = await _gistsClient.GetAllForks(gistId).ToList(); + + Assert.NotEmpty(gistForks); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfGistForksWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var gistForks = await _gistsClient.GetAllForks(gistId, options).ToList(); + + Assert.Equal(5, gistForks.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountGistForksWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var gistForks = await _gistsClient.GetAllForks(gistId, options).ToList(); + + Assert.Equal(5, gistForks.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstGistForksPage = await _gistsClient.GetAllForks(gistId, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondGistForksPage = await _gistsClient.GetAllForks(gistId, skipStartOptions).ToList(); + + Assert.NotEqual(firstGistForksPage[0].Url, secondGistForksPage[0].Url); + Assert.NotEqual(firstGistForksPage[1].Url, secondGistForksPage[1].Url); + Assert.NotEqual(firstGistForksPage[2].Url, secondGistForksPage[2].Url); + Assert.NotEqual(firstGistForksPage[3].Url, secondGistForksPage[3].Url); + Assert.NotEqual(firstGistForksPage[4].Url, secondGistForksPage[4].Url); + } + } +} + diff --git a/Octokit.Tests.Integration/Reactive/ObservableGistCommentsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableGistCommentsClientTests.cs new file mode 100644 index 00000000..1f350dbe --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableGistCommentsClientTests.cs @@ -0,0 +1,86 @@ +using System.Reactive.Linq; +using System.Threading.Tasks; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Integration.Reactive +{ + public class ObservableGistCommentsClientTests + { + public class TheGetAllForGistMethod + { + readonly ObservableGistCommentsClient _gistCommentsClient; + const string gistId = "7783a2c14a15a2e3c93b"; + + public TheGetAllForGistMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _gistCommentsClient = new ObservableGistCommentsClient(github); + } + + [IntegrationTest] + public async Task ReturnsGistComments() + { + var comments = await _gistCommentsClient.GetAllForGist(gistId).ToList(); + + Assert.NotEmpty(comments); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfGistCommentsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var comments = await _gistCommentsClient.GetAllForGist(gistId, options).ToList(); + + Assert.Equal(5, comments.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfGistCommentsWithStart() + { + var options = new ApiOptions + { + PageSize = 4, + PageCount = 1, + StartPage = 2 + }; + + var comments = await _gistCommentsClient.GetAllForGist(gistId, options).ToList(); + + Assert.Equal(4, comments.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 4, + PageCount = 1 + }; + + var firstCommentsPage = await _gistCommentsClient.GetAllForGist(gistId, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 4, + PageCount = 1, + StartPage = 2 + }; + + var secondCommentsPage = await _gistCommentsClient.GetAllForGist(gistId, skipStartOptions).ToList(); + + Assert.NotEqual(firstCommentsPage[0].Id, secondCommentsPage[0].Id); + Assert.NotEqual(firstCommentsPage[1].Id, secondCommentsPage[1].Id); + Assert.NotEqual(firstCommentsPage[2].Id, secondCommentsPage[2].Id); + Assert.NotEqual(firstCommentsPage[3].Id, secondCommentsPage[3].Id); + } + } + } +} diff --git a/Octokit.Tests.Integration/Reactive/ObservableIssueCommentsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableIssueCommentsClientTests.cs new file mode 100644 index 00000000..d838866d --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableIssueCommentsClientTests.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reactive.Linq; +using System.Text; +using System.Threading.Tasks; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Integration.Reactive +{ + public class ObservableIssueCommentsClientTests + { + public class TheGetAllForRepositoryMethod + { + readonly ObservableIssueCommentsClient _issueCommentsClient; + const string owner = "octokit"; + const string name = "octokit.net"; + + public TheGetAllForRepositoryMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _issueCommentsClient = new ObservableIssueCommentsClient(github); + } + + [IntegrationTest] + public async Task ReturnsIssueComments() + { + var issueComments = await _issueCommentsClient.GetAllForRepository(owner, name).ToList(); + + Assert.NotEmpty(issueComments); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfIssueCommentsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var issueComments = await _issueCommentsClient.GetAllForRepository(owner, name, options).ToList(); + + Assert.Equal(5, issueComments.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfIssueCommentsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var issueComments = await _issueCommentsClient.GetAllForRepository(owner, name, options).ToList(); + + Assert.Equal(5, issueComments.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstPageIssueComments = await _issueCommentsClient.GetAllForRepository(owner, name, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondPageIssueComments = await _issueCommentsClient.GetAllForRepository(owner, name, skipStartOptions).ToList(); + + Assert.NotEqual(firstPageIssueComments[0].Id, secondPageIssueComments[0].Id); + Assert.NotEqual(firstPageIssueComments[1].Id, secondPageIssueComments[1].Id); + Assert.NotEqual(firstPageIssueComments[2].Id, secondPageIssueComments[2].Id); + Assert.NotEqual(firstPageIssueComments[3].Id, secondPageIssueComments[3].Id); + Assert.NotEqual(firstPageIssueComments[4].Id, secondPageIssueComments[4].Id); + } + } + } +} diff --git a/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs index 5eb94af7..9c6acf98 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs @@ -72,6 +72,23 @@ public class ObservableIssuesClientTests : IDisposable Assert.Equal("Modified integration test issue", updateResult.Title); } + [IntegrationTest] + public async Task CanLockAndUnlockIssues() + { + var newIssue = new NewIssue("Integration Test Issue"); + + var createResult = await _client.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); + Assert.False(createResult.Locked); + + await _client.Lock(_context.RepositoryOwner, _context.RepositoryName, createResult.Number); + var lockResult = await _client.Get(_context.RepositoryOwner, _context.RepositoryName, createResult.Number); + Assert.True(lockResult.Locked); + + await _client.Unlock(_context.RepositoryOwner, _context.RepositoryName, createResult.Number); + var unlockIssueResult = await _client.Get(_context.RepositoryOwner, _context.RepositoryName, createResult.Number); + Assert.False(unlockIssueResult.Locked); + } + public void Dispose() { _context.Dispose(); diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositoryCommitsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryCommitsClientTests.cs new file mode 100644 index 00000000..48b6a75f --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryCommitsClientTests.cs @@ -0,0 +1,75 @@ +using System.Linq; +using System.Threading.Tasks; +using Octokit.Reactive; +using System.Reactive.Linq; +using Xunit; + +namespace Octokit.Tests.Integration.Reactive +{ + public class ObservableRepositoryCommitsClientTests + { + public class TheGetAllMethod + { + readonly ObservableRepositoryCommitsClient _repositoryCommitsClient; + + public TheGetAllMethod() + { + var client = Helper.GetAuthenticatedClient(); + _repositoryCommitsClient = new ObservableRepositoryCommitsClient(client); + } + + [IntegrationTest] + public async Task CanGetCorrectCountOfCommitsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var commits = await _repositoryCommitsClient.GetAll("shiftkey", "ReactiveGit", options).ToList(); + Assert.Equal(5, commits.Count); + } + + [IntegrationTest] + public async Task CanGetCorrectCountOfCommitsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var commits = await _repositoryCommitsClient.GetAll("shiftkey", "ReactiveGit", options).ToList(); + Assert.Equal(5, commits.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStart() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var firstCommit = await _repositoryCommitsClient.GetAll("shiftkey", "ReactiveGit", startOptions).ToList(); + var secondCommit = await _repositoryCommitsClient.GetAll("shiftkey", "ReactiveGit", skipStartOptions).ToList(); + + Assert.NotEqual(firstCommit[0].Sha, secondCommit[0].Sha); + Assert.NotEqual(firstCommit[1].Sha, secondCommit[1].Sha); + Assert.NotEqual(firstCommit[2].Sha, secondCommit[2].Sha); + Assert.NotEqual(firstCommit[3].Sha, secondCommit[3].Sha); + Assert.NotEqual(firstCommit[4].Sha, secondCommit[4].Sha); + } + } + } +} diff --git a/Octokit.Tests.Integration/Reactive/ObservableRespositoryDeployKeysClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryDeployKeysClientTests.cs similarity index 95% rename from Octokit.Tests.Integration/Reactive/ObservableRespositoryDeployKeysClientTests.cs rename to Octokit.Tests.Integration/Reactive/ObservableRepositoryDeployKeysClientTests.cs index 19fe4a83..41b14256 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableRespositoryDeployKeysClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryDeployKeysClientTests.cs @@ -28,7 +28,7 @@ public class ObservableRespositoryDeployKeysClientTests : IDisposable [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for investigating this failing test")] public async Task CanCreateADeployKey() { - var deployKey = new NewDeployKey() + var deployKey = new NewDeployKey { Key = _key, Title = _keyTitle @@ -48,7 +48,7 @@ public class ObservableRespositoryDeployKeysClientTests : IDisposable var deployKeys = await _client.GetAll(_owner, _repository.Name).ToList(); Assert.Empty(deployKeys); - var deployKey = new NewDeployKey() + var deployKey = new NewDeployKey { Key = _key, Title = _keyTitle @@ -64,7 +64,7 @@ public class ObservableRespositoryDeployKeysClientTests : IDisposable [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for investigating this failing test")] public async Task CanRetrieveADeployKey() { - var newDeployKey = new NewDeployKey() + var newDeployKey = new NewDeployKey { Key = _key, Title = _keyTitle @@ -82,7 +82,7 @@ public class ObservableRespositoryDeployKeysClientTests : IDisposable [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for investigating this failing test")] public async Task CanRemoveADeployKey() { - var newDeployKey = new NewDeployKey() + var newDeployKey = new NewDeployKey { Key = _key, Title = _keyTitle diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositoryHooksClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryHooksClientTests.cs new file mode 100644 index 00000000..76d62db1 --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryHooksClientTests.cs @@ -0,0 +1,115 @@ +using System.Reactive.Linq; +using System.Threading.Tasks; +using Octokit.Reactive; +using Octokit.Tests.Integration.fixtures; +using Xunit; + +namespace Octokit.Tests.Integration.Reactive +{ + public class ObservableRepositoryHooksClientTests + { + [Collection(RepositoriesHooksCollection.Name)] + public class TheGetAllMethod + { + readonly RepositoriesHooksFixture _fixture; + + public TheGetAllMethod(RepositoriesHooksFixture fixture) + { + _fixture = fixture; + } + + [IntegrationTest] + public async Task ReturnsAllHooksFromRepository() + { + var github = Helper.GetAuthenticatedClient(); + + var client = new ObservableRepositoryHooksClient(github); + + var hooks = await client.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName).ToList(); + + Assert.Equal(_fixture.ExpectedHooks.Count, hooks.Count); + + var actualHook = hooks[0]; + AssertHook(_fixture.ExpectedHook, actualHook); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfHooksWithoutStart() + { + var github = Helper.GetAuthenticatedClient(); + + var client = new ObservableRepositoryHooksClient(github); + + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var hooks = await client.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, options).ToList(); + + Assert.Equal(_fixture.ExpectedHooks.Count, hooks.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfHooksWithStart() + { + var github = Helper.GetAuthenticatedClient(); + + var client = new ObservableRepositoryHooksClient(github); + + var options = new ApiOptions + { + PageSize = 2, + PageCount = 1, + StartPage = 3 + }; + + var hooks = await client.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, options).ToList(); + + Assert.Equal(1, hooks.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var github = Helper.GetAuthenticatedClient(); + + var client = new ObservableRepositoryHooksClient(github); + + var startOptions = new ApiOptions + { + PageSize = 2, + PageCount = 1 + }; + + var firstPage = await client.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 2, + PageCount = 1, + StartPage = 2 + }; + + var secondPage = await client.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, skipStartOptions).ToList(); + + Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); + Assert.NotEqual(firstPage[1].Id, secondPage[1].Id); + } + + static void AssertHook(RepositoryHook expectedHook, RepositoryHook actualHook) + { + Assert.Equal(expectedHook.Id, actualHook.Id); + Assert.Equal(expectedHook.Active, actualHook.Active); + Assert.Equal(expectedHook.Config, actualHook.Config); + Assert.Equal(expectedHook.CreatedAt, actualHook.CreatedAt); + Assert.Equal(expectedHook.Name, actualHook.Name); + Assert.Equal(expectedHook.PingUrl, actualHook.PingUrl); + Assert.Equal(expectedHook.TestUrl, actualHook.TestUrl); + Assert.Equal(expectedHook.UpdatedAt, actualHook.UpdatedAt); + Assert.Equal(expectedHook.Url, actualHook.Url); + } + } + } +} diff --git a/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs index bf8dc203..d6743e8c 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs @@ -10,13 +10,13 @@ public class ObservableTeamsClientTests { public class TheGetMembersMethod { - readonly Team team; + readonly Team _team; public TheGetMembersMethod() { var github = Helper.GetAuthenticatedClient(); - team = github.Organization.Team.GetAll(Helper.Organization).Result.First(); + _team = github.Organization.Team.GetAll(Helper.Organization).Result.First(); } [OrganizationTest] @@ -26,7 +26,7 @@ public class ObservableTeamsClientTests var client = new ObservableTeamsClient(github); - var member = await client.GetAllMembers(team.Id); + var member = await client.GetAllMembers(_team.Id, ApiOptions.None); Assert.Equal(Helper.UserName, member.Login); } diff --git a/Octokit.Tests.Integration/Reactive/ObservableUserAdministrationClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableUserAdministrationClientTests.cs index efaea9a0..ad15c402 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableUserAdministrationClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableUserAdministrationClientTests.cs @@ -94,7 +94,7 @@ namespace Octokit.Tests.Integration.Clients // Create Impersonation token var observable = _github.User.Administration.CreateImpersonationToken( context.UserLogin, - new NewImpersonationToken(new string[] { "public_repo" })); + new NewImpersonationToken(new[] { "public_repo" })); var token = await observable; Assert.NotNull(token); @@ -174,7 +174,7 @@ namespace Octokit.Tests.Integration.Clients // Get public keys var observable = _github.User.Administration.ListAllPublicKeys(); - var keys = await (observable.ToList()); + var keys = await observable.ToList(); Assert.NotNull(keys); Assert.True(keys.Count > 0); diff --git a/Octokit.Tests.Integration/Reactive/ObservableUserKeysClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableUserKeysClientTests.cs index 4e48c55f..56a04f1d 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableUserKeysClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableUserKeysClientTests.cs @@ -22,7 +22,7 @@ namespace Octokit.Tests.Integration.Clients using (var context = await _github.CreatePublicKeyContext()) { var observable = _github.User.Keys.GetAllForCurrent(); - var keys = await (observable.ToList()); + var keys = await observable.ToList(); Assert.NotEmpty(keys); @@ -38,7 +38,7 @@ namespace Octokit.Tests.Integration.Clients public async Task CanGetAllForGivenUser() { var observable = _github.User.Keys.GetAll("shiftkey"); - var keys = await (observable.ToList()); + var keys = await observable.ToList(); Assert.NotEmpty(keys); @@ -80,7 +80,7 @@ namespace Octokit.Tests.Integration.Clients await _github.User.Keys.Delete(key.Id); // Verify key no longer exists - var keys = await (_github.User.Keys.GetAllForCurrent().ToList()); + var keys = await _github.User.Keys.GetAllForCurrent().ToList(); Assert.False(keys.Any(k => k.Title == keyTitle && k.Key == keyData)); } } diff --git a/Octokit.Tests.Integration/fixtures/RepositoriesHooksFixture.cs b/Octokit.Tests.Integration/fixtures/RepositoriesHooksFixture.cs index cda77a8a..09b47c1c 100644 --- a/Octokit.Tests.Integration/fixtures/RepositoriesHooksFixture.cs +++ b/Octokit.Tests.Integration/fixtures/RepositoriesHooksFixture.cs @@ -8,12 +8,21 @@ namespace Octokit.Tests.Integration.fixtures readonly IGitHubClient _github; readonly Repository _repository; readonly RepositoryHook _hook; + readonly IList _hooks; public RepositoriesHooksFixture() { _github = Helper.GetAuthenticatedClient(); _repository = CreateRepository(_github); - _hook = CreateHook(_github, _repository); + _hooks = new List(5) + { + CreateHook(_github, _repository, "awscodedeploy", "deployment"), + CreateHook(_github, _repository, "awsopsworks", "push"), + CreateHook(_github, _repository, "activecollab", "push"), + CreateHook(_github, _repository, "acunote", "push"), + CreateHook(_github, _repository, "agilebench", "push") + }; + _hook = _hooks[0]; } public string RepositoryOwner { get { return _repository.Owner.Login; } } @@ -22,6 +31,8 @@ namespace Octokit.Tests.Integration.fixtures public RepositoryHook ExpectedHook { get { return _hook; } } + public IList ExpectedHooks { get { return _hooks; } } + public void Dispose() { _github.Repository.Delete(_repository.Owner.Login, _repository.Name); @@ -35,12 +46,12 @@ namespace Octokit.Tests.Integration.fixtures return repository.Result; } - static RepositoryHook CreateHook(IGitHubClient github, Repository repository) + static RepositoryHook CreateHook(IGitHubClient github, Repository repository, string hookName, string eventName) { var config = new Dictionary { { "content_type", "json" }, { "url", "http://test.com/example" } }; - var parameters = new NewRepositoryHook("apropos", config) + var parameters = new NewRepositoryHook(hookName, config) { - Events = new[] { "commit_comment" }, + Events = new[] { eventName }, Active = false }; var createdHook = github.Repository.Hooks.Create(Helper.UserName, repository.Name, parameters); diff --git a/Octokit.Tests/Clients/AssigneesClientTests.cs b/Octokit.Tests/Clients/AssigneesClientTests.cs index e5c56018..cf03eedc 100644 --- a/Octokit.Tests/Clients/AssigneesClientTests.cs +++ b/Octokit.Tests/Clients/AssigneesClientTests.cs @@ -115,7 +115,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new AssigneesClient(null)); } diff --git a/Octokit.Tests/Clients/AuthorizationsClientTests.cs b/Octokit.Tests/Clients/AuthorizationsClientTests.cs index 0724d76b..91887a6e 100644 --- a/Octokit.Tests/Clients/AuthorizationsClientTests.cs +++ b/Octokit.Tests/Clients/AuthorizationsClientTests.cs @@ -14,10 +14,10 @@ namespace Octokit.Tests.Clients /// public class AuthorizationsClientTests { - public class TheConstructor + public class TheCtor { [Fact] - public void ThrowsForBadArgs() + public void EnsuresNonNullArguments() { Assert.Throws(() => new AuthorizationsClient(null)); } @@ -335,7 +335,7 @@ namespace Octokit.Tests.Clients public class TheRevokeApplicationAuthenticationMethod { [Fact] - public async Task RevokesApplicatonAuthenticationAtCorrectUrl() + public async Task RevokesApplicationAuthenticationAtCorrectUrl() { var client = Substitute.For(); var authEndpoint = new AuthorizationsClient(client); diff --git a/Octokit.Tests/Clients/BlobClientTests.cs b/Octokit.Tests/Clients/BlobClientTests.cs index d480473e..c40a380f 100644 --- a/Octokit.Tests/Clients/BlobClientTests.cs +++ b/Octokit.Tests/Clients/BlobClientTests.cs @@ -4,13 +4,21 @@ using System.Net; using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients { public class BlobClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new BlobsClient(null)); + } + } + public class TheGetMethod { [Fact] diff --git a/Octokit.Tests/Clients/CommitStatusClientTests.cs b/Octokit.Tests/Clients/CommitStatusClientTests.cs index c7658c83..94c2a907 100644 --- a/Octokit.Tests/Clients/CommitStatusClientTests.cs +++ b/Octokit.Tests/Clients/CommitStatusClientTests.cs @@ -20,8 +20,27 @@ namespace Octokit.Tests.Clients client.GetAll("fake", "repo", "sha"); connection.Received() - .GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/commits/sha/statuses")); + .GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/commits/sha/statuses"), Arg.Any()); } + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new CommitStatusClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAll("fake", "repo", "sha", options); + + connection.Received() + .GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/commits/sha/statuses"), Args.ApiOptions); + } + [Fact] public async Task EnsuresNonNullArguments() @@ -114,7 +133,7 @@ namespace Octokit.Tests.Clients } } - public class TheConstructor + public class TheCtor { [Fact] public void EnsuresNonNullArguments() diff --git a/Octokit.Tests/Clients/CommitsClientTests.cs b/Octokit.Tests/Clients/CommitsClientTests.cs index 66bebed9..6c1c4201 100644 --- a/Octokit.Tests/Clients/CommitsClientTests.cs +++ b/Octokit.Tests/Clients/CommitsClientTests.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Threading.Tasks; using NSubstitute; using Octokit; -using Octokit.Tests.Helpers; using Xunit; public class CommitsClientTests @@ -71,7 +70,7 @@ public class CommitsClientTests public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new CommitsClient(null)); } diff --git a/Octokit.Tests/Clients/DeploymentStatusClientTests.cs b/Octokit.Tests/Clients/DeploymentStatusClientTests.cs index bbf306d4..e88080c0 100644 --- a/Octokit.Tests/Clients/DeploymentStatusClientTests.cs +++ b/Octokit.Tests/Clients/DeploymentStatusClientTests.cs @@ -105,7 +105,7 @@ public class DeploymentStatusClientTests public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new DeploymentStatusClient(null)); } diff --git a/Octokit.Tests/Clients/DeploymentsClientTests.cs b/Octokit.Tests/Clients/DeploymentsClientTests.cs index 3eb59569..a29e555a 100644 --- a/Octokit.Tests/Clients/DeploymentsClientTests.cs +++ b/Octokit.Tests/Clients/DeploymentsClientTests.cs @@ -2,19 +2,24 @@ using System.Threading.Tasks; using NSubstitute; using Octokit; +using Octokit.Tests; using Xunit; public class DeploymentsClientTests { public class TheGetAllMethod { + private const string name = "name"; + private const string owner = "owner"; + [Fact] public async Task EnsuresNonNullArguments() { var client = new DeploymentsClient(Substitute.For()); - await Assert.ThrowsAsync(() => client.GetAll(null, "name")); - await Assert.ThrowsAsync(() => client.GetAll("owner", null)); + await Assert.ThrowsAsync(() => client.GetAll(null, name)); + await Assert.ThrowsAsync(() => client.GetAll(owner, null)); + await Assert.ThrowsAsync(() => client.GetAll(owner, name, null)); } [Fact] @@ -22,8 +27,8 @@ public class DeploymentsClientTests { var client = new DeploymentsClient(Substitute.For()); - await Assert.ThrowsAsync(() => client.GetAll("", "name")); - await Assert.ThrowsAsync(() => client.GetAll("owner", "")); + await Assert.ThrowsAsync(() => client.GetAll("", name)); + await Assert.ThrowsAsync(() => client.GetAll(owner, "")); } [Theory] @@ -36,8 +41,8 @@ public class DeploymentsClientTests { var client = new DeploymentsClient(Substitute.For()); - await Assert.ThrowsAsync(() => client.GetAll(whitespace, "name")); - await Assert.ThrowsAsync(() => client.GetAll("owner", whitespace)); + await Assert.ThrowsAsync(() => client.GetAll(whitespace, name)); + await Assert.ThrowsAsync(() => client.GetAll(owner, whitespace)); } [Fact] @@ -45,16 +50,36 @@ public class DeploymentsClientTests { var connection = Substitute.For(); var client = new DeploymentsClient(connection); - var expectedUrl = "repos/owner/name/deployments"; + var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name); - client.GetAll("owner", "name"); - connection.Received(1).GetAll(Arg.Is(u => u.ToString() == expectedUrl)); + client.GetAll(owner, name); + connection.Received(1) + .GetAll(Arg.Is(u => u.ToString() == expectedUrl), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new DeploymentsClient(connection); + var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAll(owner, name, options); + connection.Received(1) + .GetAll(Arg.Is(u => u.ToString() == expectedUrl), options); } } public class TheCreateMethod { - readonly NewDeployment newDeployment = new NewDeployment("aRef"); + private readonly NewDeployment newDeployment = new NewDeployment("aRef"); [Fact] public async Task EnsuresNonNullArguments() @@ -118,7 +143,7 @@ public class DeploymentsClientTests public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new DeploymentsClient(null)); } diff --git a/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs index 1fe3bfa9..2fd61426 100644 --- a/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs +++ b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs @@ -159,5 +159,15 @@ namespace Octokit.Tests.Clients connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); } } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new EnterpriseAdminStatsClient(null)); + } + } } } \ No newline at end of file diff --git a/Octokit.Tests/Clients/Enterprise/EnterpriseLdapClientTests.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseLdapClientTests.cs index d5ea1c4d..ace67720 100644 --- a/Octokit.Tests/Clients/Enterprise/EnterpriseLdapClientTests.cs +++ b/Octokit.Tests/Clients/Enterprise/EnterpriseLdapClientTests.cs @@ -130,5 +130,15 @@ namespace Octokit.Tests.Clients Arg.Is(u => u.ToString() == expectedUri)); } } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new EnterpriseLdapClient(null)); + } + } } } diff --git a/Octokit.Tests/Clients/Enterprise/EnterpriseLicenseClientTests.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseLicenseClientTests.cs index 947fa4a2..2a9e0042 100644 --- a/Octokit.Tests/Clients/Enterprise/EnterpriseLicenseClientTests.cs +++ b/Octokit.Tests/Clients/Enterprise/EnterpriseLicenseClientTests.cs @@ -19,5 +19,15 @@ namespace Octokit.Tests.Clients connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); } } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new EnterpriseLicenseClient(null)); + } + } } } diff --git a/Octokit.Tests/Clients/Enterprise/EnterpriseOrganizationClientTests.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseOrganizationClientTests.cs index b3c815b5..0d34f6c2 100644 --- a/Octokit.Tests/Clients/Enterprise/EnterpriseOrganizationClientTests.cs +++ b/Octokit.Tests/Clients/Enterprise/EnterpriseOrganizationClientTests.cs @@ -46,5 +46,15 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.Create(null)); } } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new EnterpriseOrganizationClient(null)); + } + } } } diff --git a/Octokit.Tests/Clients/Enterprise/EnterpriseSearchIndexingClientTests.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseSearchIndexingClientTests.cs index e347c005..c4b247d8 100644 --- a/Octokit.Tests/Clients/Enterprise/EnterpriseSearchIndexingClientTests.cs +++ b/Octokit.Tests/Clients/Enterprise/EnterpriseSearchIndexingClientTests.cs @@ -7,6 +7,16 @@ namespace Octokit.Tests.Clients { public class EnterpriseSearchIndexingClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new EnterpriseSearchIndexingClient(null)); + } + } + public class TheQueueMethod { [Fact] diff --git a/Octokit.Tests/Clients/EventsClientTests.cs b/Octokit.Tests/Clients/EventsClientTests.cs index 57437d82..124533e9 100644 --- a/Octokit.Tests/Clients/EventsClientTests.cs +++ b/Octokit.Tests/Clients/EventsClientTests.cs @@ -6,14 +6,22 @@ using System.Threading; using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; -using Octokit; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients { public class EventsClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new EventsClient(null)); + } + } + public class TheGetAllMethod { [Fact] @@ -24,7 +32,33 @@ namespace Octokit.Tests.Clients client.GetAll(); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "events")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "events"), Args.ApiOptions); + } + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new EventsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAll(options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "events"), options); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new EventsClient(connection); + + await Assert.ThrowsAsync(() => client.GetAll(null)); } } @@ -38,7 +72,25 @@ namespace Octokit.Tests.Clients client.GetAllForRepository("fake", "repo"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/events")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/events"), Args.ApiOptions); + } + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new EventsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + + client.GetAllForRepository("fake", "repo", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/events"), options); } [Fact] @@ -51,6 +103,9 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name")); await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null)); await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "")); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name",null)); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "",ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name", ApiOptions.None)); } } @@ -64,7 +119,25 @@ namespace Octokit.Tests.Clients client.GetAllForRepositoryNetwork("fake", "repo"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "networks/fake/repo/events")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "networks/fake/repo/events"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new EventsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAllForRepositoryNetwork("fake", "repo", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "networks/fake/repo/events"), options); } [Fact] @@ -77,6 +150,9 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAllForRepositoryNetwork("", "name")); await Assert.ThrowsAsync(() => client.GetAllForRepositoryNetwork("owner", null)); await Assert.ThrowsAsync(() => client.GetAllForRepositoryNetwork("owner", "")); + await Assert.ThrowsAsync(() => client.GetAllForRepositoryNetwork("owner", "name", null)); + await Assert.ThrowsAsync(() => client.GetAllForRepositoryNetwork("owner", "", ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAllForRepositoryNetwork("", "name", ApiOptions.None)); } } @@ -90,7 +166,25 @@ namespace Octokit.Tests.Clients client.GetAllForOrganization("fake"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/fake/events")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/fake/events"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new EventsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAllForOrganization("fake", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/fake/events"), options); } [Fact] @@ -101,6 +195,8 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAllForOrganization(null)); await Assert.ThrowsAsync(() => client.GetAllForOrganization("")); + await Assert.ThrowsAsync(() => client.GetAllForOrganization("fake", null)); + await Assert.ThrowsAsync(() => client.GetAllForOrganization("", ApiOptions.None)); } } @@ -114,7 +210,25 @@ namespace Octokit.Tests.Clients client.GetAllUserReceived("fake"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/received_events")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/received_events"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new EventsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAllUserReceived("fake", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/received_events"), options); } [Fact] @@ -125,6 +239,8 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAllUserReceived(null)); await Assert.ThrowsAsync(() => client.GetAllUserReceived("")); + await Assert.ThrowsAsync(() => client.GetAllUserReceived("fake", null)); + await Assert.ThrowsAsync(() => client.GetAllUserReceived("", ApiOptions.None)); } } @@ -138,7 +254,25 @@ namespace Octokit.Tests.Clients client.GetAllUserReceivedPublic("fake"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/received_events/public")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/received_events/public"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new EventsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAllUserReceivedPublic("fake", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/received_events/public"), options); } [Fact] @@ -149,6 +283,8 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAllUserReceivedPublic(null)); await Assert.ThrowsAsync(() => client.GetAllUserReceivedPublic("")); + await Assert.ThrowsAsync(() => client.GetAllUserReceivedPublic("fake", null)); + await Assert.ThrowsAsync(() => client.GetAllUserReceivedPublic("", ApiOptions.None)); } } @@ -162,7 +298,25 @@ namespace Octokit.Tests.Clients client.GetAllUserPerformed("fake"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/events")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/events"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new EventsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAllUserPerformed("fake", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/events"), options); } [Fact] @@ -173,6 +327,8 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAllUserPerformed(null)); await Assert.ThrowsAsync(() => client.GetAllUserPerformed("")); + await Assert.ThrowsAsync(() => client.GetAllUserPerformed("fake", null)); + await Assert.ThrowsAsync(() => client.GetAllUserPerformed("", ApiOptions.None)); } } @@ -186,7 +342,25 @@ namespace Octokit.Tests.Clients client.GetAllUserPerformedPublic("fake"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/events/public")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/events/public"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new EventsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAllUserPerformedPublic("fake", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/events/public"), options); } [Fact] @@ -197,6 +371,8 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAllUserPerformedPublic(null)); await Assert.ThrowsAsync(() => client.GetAllUserPerformedPublic("")); + await Assert.ThrowsAsync(() => client.GetAllUserPerformedPublic("fake",null)); + await Assert.ThrowsAsync(() => client.GetAllUserPerformedPublic("",ApiOptions.None)); } } @@ -210,7 +386,25 @@ namespace Octokit.Tests.Clients client.GetAllForAnOrganization("fake", "org"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/events/orgs/org")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/events/orgs/org"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new EventsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAllForAnOrganization("fake", "org", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/events/orgs/org"), options); } [Fact] @@ -223,6 +417,9 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAllForAnOrganization("", "org")); await Assert.ThrowsAsync(() => client.GetAllForAnOrganization("fake", null)); await Assert.ThrowsAsync(() => client.GetAllForAnOrganization("fake", "")); + await Assert.ThrowsAsync(() => client.GetAllForAnOrganization("fake", "org", null)); + await Assert.ThrowsAsync(() => client.GetAllForAnOrganization("fake", "", ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAllForAnOrganization("", "org", ApiOptions.None)); } } diff --git a/Octokit.Tests/Clients/FeedsClientTests.cs b/Octokit.Tests/Clients/FeedsClientTests.cs index 603e96a7..e532d134 100644 --- a/Octokit.Tests/Clients/FeedsClientTests.cs +++ b/Octokit.Tests/Clients/FeedsClientTests.cs @@ -1,7 +1,5 @@ using System; -using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -12,7 +10,7 @@ namespace Octokit.Tests.Clients /// public class FeedsClientTests { - public class TheConstructor + public class TheCtor { [Fact] public void EnsuresNonNullArguments() diff --git a/Octokit.Tests/Clients/FollowersClientTests.cs b/Octokit.Tests/Clients/FollowersClientTests.cs index f9201f6d..29314bbd 100644 --- a/Octokit.Tests/Clients/FollowersClientTests.cs +++ b/Octokit.Tests/Clients/FollowersClientTests.cs @@ -4,10 +4,7 @@ using System.Net; using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; -using Octokit.Tests; -using Octokit.Tests.Helpers; using Xunit; -using Xunit.Extensions; namespace Octokit.Tests.Clients { @@ -17,7 +14,7 @@ namespace Octokit.Tests.Clients /// public class FollowersClientTests { - public class TheConstructor + public class TheCtor { [Fact] public void EnsuresNonNullArguments() @@ -37,7 +34,35 @@ namespace Octokit.Tests.Clients client.GetAllForCurrent(); connection.Received().GetAll( - Arg.Is(u => u.ToString() == "user/followers")); + Arg.Is(u => u.ToString() == "user/followers"),Args.ApiOptions); + } + + [Fact] + public void RequestsTheCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new FollowersClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAllForCurrent(options); + + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "user/followers"),options); + } + + [Fact] + public async Task EnsureNonNullArguments() + { + var connection = Substitute.For(); + var client = new FollowersClient(connection); + + await Assert.ThrowsAsync(() => client.GetAllForCurrent(null)); } } @@ -52,7 +77,26 @@ namespace Octokit.Tests.Clients client.GetAll("alfhenrik"); connection.Received().GetAll( - Arg.Is(u => u.ToString() == "users/alfhenrik/followers")); + Arg.Is(u => u.ToString() == "users/alfhenrik/followers"), Args.ApiOptions); + } + + [Fact] + public void RequestsTheCorrectUrlWithOptions() + { + var connection = Substitute.For(); + var client = new FollowersClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAll("alfhenrik",options); + + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "users/alfhenrik/followers"), options); } [Fact] @@ -63,10 +107,12 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAll(null)); await Assert.ThrowsAsync(() => client.GetAll("")); + await Assert.ThrowsAsync(() => client.GetAll("fake",null)); + await Assert.ThrowsAsync(() => client.GetAll("",ApiOptions.None)); } } - public class TheGetFollowingForCurrentMethod + public class TheGetAllFollowingForCurrentMethod { [Fact] public void RequestsTheCorrectUrl() @@ -76,11 +122,38 @@ namespace Octokit.Tests.Clients client.GetAllFollowingForCurrent(); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "user/following")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "user/following"), Args.ApiOptions); + } + + [Fact] + public void RequestsTheCorrectUrlWithOptions() + { + var connection = Substitute.For(); + var client = new FollowersClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAllFollowingForCurrent(options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "user/following"), options); + } + + [Fact] + public async Task EnsureNonNullArguments() + { + var connection = Substitute.For(); + var client = new FollowersClient(connection); + + await Assert.ThrowsAsync(() => client.GetAllFollowingForCurrent(null)); } } - public class TheGetFollowingMethod + public class TheGetAllFollowingMethod { [Fact] public void RequestsTheCorrectUrl() @@ -90,7 +163,25 @@ namespace Octokit.Tests.Clients client.GetAllFollowing("alfhenrik"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/alfhenrik/following")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/alfhenrik/following"), Args.ApiOptions); + } + + [Fact] + public void RequestsTheCorrectUrlWithOptions() + { + var connection = Substitute.For(); + var client = new FollowersClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAllFollowing("alfhenrik", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/alfhenrik/following"), options); } [Fact] @@ -101,6 +192,8 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAllFollowing(null)); await Assert.ThrowsAsync(() => client.GetAllFollowing("")); + await Assert.ThrowsAsync(() => client.GetAllFollowing("fake", null)); + await Assert.ThrowsAsync(() => client.GetAllFollowing("", ApiOptions.None)); } } diff --git a/Octokit.Tests/Clients/GistCommentsClientTests.cs b/Octokit.Tests/Clients/GistCommentsClientTests.cs index 7689dcc4..6b9cf86e 100644 --- a/Octokit.Tests/Clients/GistCommentsClientTests.cs +++ b/Octokit.Tests/Clients/GistCommentsClientTests.cs @@ -1,108 +1,140 @@ using System; using System.Threading.Tasks; using NSubstitute; -using Octokit; -using Octokit.Tests.Helpers; using Xunit; -public class GistCommentsClientTests +namespace Octokit.Tests.Clients { - public class TheCtor + public class GistCommentsClientTests { - [Fact] - public void EnsuresArgument() + public class TheCtor { - Assert.Throws(() => new GistCommentsClient(null)); - } - } - - public class TheGetMethod - { - [Fact] - public async Task RequestsCorrectUrl() - { - var connection = Substitute.For(); - var client = new GistCommentsClient(connection); - - await client.Get("24", 1337); - - connection.Received().Get(Arg.Is(u => u.ToString() == "gists/24/comments/1337")); - } - } - - public class TheGetForGistMethod - { - [Fact] - public async Task RequestsCorrectUrl() - { - var connection = Substitute.For(); - var client = new GistCommentsClient(connection); - - await client.GetAllForGist("24"); - - connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/24/comments")); - } - } - - public class TheCreateMethod - { - [Fact] - public async Task EnsuresNonNullArguments() - { - var client = new GistCommentsClient(Substitute.For()); - - await Assert.ThrowsAsync(() => client.Create("24", null)); - await Assert.ThrowsAsync(() => client.Create("24", "")); + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new GistCommentsClient(null)); + } } - [Fact] - public async Task PostsToCorrectUrl() + public class TheGetMethod { - var comment = "This is a comment."; - var connection = Substitute.For(); - var client = new GistCommentsClient(connection); + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new GistCommentsClient(connection); - await client.Create("24", comment); + await client.Get("24", 1337); - connection.Received().Post(Arg.Is(u => u.ToString() == "gists/24/comments"), Arg.Is(x => x.Body == comment)); - } - } - - public class TheUpdateMethod - { - [Fact] - public async Task EnsuresNonNullArguments() - { - var client = new GistCommentsClient(Substitute.For()); - - await Assert.ThrowsAsync(() => client.Update("24", 1337, null)); - await Assert.ThrowsAsync(() => client.Update("24", 1337, "")); + connection.Received().Get(Arg.Is(u => u.ToString() == "gists/24/comments/1337")); + } } - [Fact] - public async Task PostsToCorrectUrl() + public class TheGetAllForGistMethod { - var comment = "This is a comment."; - var connection = Substitute.For(); - var client = new GistCommentsClient(connection); + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new GistCommentsClient(connection); - await client.Update("24", 1337, comment); + await client.GetAllForGist("24"); - connection.Received().Patch(Arg.Is(u => u.ToString() == "gists/24/comments/1337"), Arg.Is(x => x.Body == comment)); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/24/comments"), Args.ApiOptions); + } + + [Fact] + public async Task RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new GistCommentsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + await client.GetAllForGist("24", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/24/comments"), options); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new GistCommentsClient(connection); + + await Assert.ThrowsAsync(() => client.GetAllForGist(null)); + await Assert.ThrowsAsync(() => client.GetAllForGist("")); + await Assert.ThrowsAsync(() => client.GetAllForGist("24", null)); + await Assert.ThrowsAsync(() => client.GetAllForGist("", ApiOptions.None)); + + } } - } - public class TheDeleteMethod - { - [Fact] - public async Task PostsToCorrectUrl() + public class TheCreateMethod { - var connection = Substitute.For(); - var client = new GistCommentsClient(connection); + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new GistCommentsClient(Substitute.For()); - await client.Delete("24", 1337); + await Assert.ThrowsAsync(() => client.Create("24", null)); + await Assert.ThrowsAsync(() => client.Create("24", "")); + } - connection.Received().Delete(Arg.Is(u => u.ToString() == "gists/24/comments/1337")); + [Fact] + public async Task PostsToCorrectUrl() + { + var comment = "This is a comment."; + var connection = Substitute.For(); + var client = new GistCommentsClient(connection); + + await client.Create("24", comment); + + connection.Received().Post(Arg.Is(u => u.ToString() == "gists/24/comments"), Arg.Is(x => x.Body == comment)); + } + } + + public class TheUpdateMethod + { + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new GistCommentsClient(Substitute.For()); + + await Assert.ThrowsAsync(() => client.Update("24", 1337, null)); + await Assert.ThrowsAsync(() => client.Update("24", 1337, "")); + } + + [Fact] + public async Task PostsToCorrectUrl() + { + var comment = "This is a comment."; + var connection = Substitute.For(); + var client = new GistCommentsClient(connection); + + await client.Update("24", 1337, comment); + + connection.Received().Patch(Arg.Is(u => u.ToString() == "gists/24/comments/1337"), Arg.Is(x => x.Body == comment)); + } + } + + public class TheDeleteMethod + { + [Fact] + public async Task PostsToCorrectUrl() + { + var connection = Substitute.For(); + var client = new GistCommentsClient(connection); + + await client.Delete("24", 1337); + + connection.Received().Delete(Arg.Is(u => u.ToString() == "gists/24/comments/1337")); + } } } } \ No newline at end of file diff --git a/Octokit.Tests/Clients/GistsClientTests.cs b/Octokit.Tests/Clients/GistsClientTests.cs index 56c31186..536d7619 100644 --- a/Octokit.Tests/Clients/GistsClientTests.cs +++ b/Octokit.Tests/Clients/GistsClientTests.cs @@ -1,14 +1,37 @@ using NSubstitute; -using Octokit; using Octokit.Internal; using System; using System.Collections.Generic; using System.Net; using System.Threading.Tasks; +using Octokit; +using Octokit.Tests; using Xunit; public class GistsClientTests { + public static Dictionary DictionaryWithSince + { + get { return Arg.Is>(d => d.ContainsKey("since")); } + } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new GistsClient(null)); + } + + [Fact] + public void SetCommentsClient() + { + var apiConnection = Substitute.For(); + var client = new GistsClient(apiConnection); + Assert.NotNull(client.Comment); + } + } + public class TheGetMethod { [Fact] @@ -32,8 +55,26 @@ public class GistsClientTests var client = new GistsClient(connection); client.GetAll(); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectGetAllUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAll(options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists"), options); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists")); } [Fact] @@ -46,9 +87,42 @@ public class GistsClientTests client.GetAll(since); connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists"), - Arg.Is>(x => x.ContainsKey("since"))); + DictionaryWithSince, Args.ApiOptions); } + [Fact] + public void RequestsCorrectGetAllWithSinceUrlAndApiOptions() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + DateTimeOffset since = DateTimeOffset.Now; + client.GetAll(since, options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists"), + DictionaryWithSince, options); + + } + + [Fact] + public async Task EnsureNonNullArguments() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + await Assert.ThrowsAsync(() => client.GetAll(null)); + await Assert.ThrowsAsync(() => client.GetAll(DateTimeOffset.Now, null)); + } + } + + public class TheGetAllPublicMethod + { [Fact] public void RequestsCorrectGetAllPublicUrl() { @@ -57,7 +131,25 @@ public class GistsClientTests client.GetAllPublic(); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/public")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/public"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectGetAllPublicUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAllPublic(options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/public"), options); + } [Fact] @@ -70,9 +162,43 @@ public class GistsClientTests client.GetAllPublic(since); connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/public"), - Arg.Is>(x => x.ContainsKey("since"))); + DictionaryWithSince, Args.ApiOptions); } + [Fact] + public void RequestsCorrectGetAllPublicWithSinceUrlAndApiOptions() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + DateTimeOffset since = DateTimeOffset.Now; + client.GetAllPublic(since, options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/public"), + DictionaryWithSince, options); + } + + [Fact] + public async Task EnsureNonNullArguments() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + await Assert.ThrowsAsync(() => client.GetAllPublic(null)); + await Assert.ThrowsAsync(() => client.GetAllPublic(DateTimeOffset.Now, null)); + + } + + } + + public class TheGetAllStarredMethod + { [Fact] public void RequestsCorrectGetAllStarredUrl() { @@ -81,7 +207,25 @@ public class GistsClientTests client.GetAllStarred(); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/starred")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/starred"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectGetAllStarredUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAllStarred(options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/starred"), options); + } [Fact] @@ -94,9 +238,41 @@ public class GistsClientTests client.GetAllStarred(since); connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/starred"), - Arg.Is>(x => x.ContainsKey("since"))); + DictionaryWithSince, Args.ApiOptions); } + [Fact] + public void RequestsCorrectGetAllStarredWithSinceUrlAndApiOptions() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + DateTimeOffset since = DateTimeOffset.Now; + client.GetAllStarred(since, options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/starred"), + DictionaryWithSince, options); + } + [Fact] + public async Task EnsureNonNullArguments() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + await Assert.ThrowsAsync(() => client.GetAllStarred(null)); + await Assert.ThrowsAsync(() => client.GetAllStarred(DateTimeOffset.Now, null)); + + } + } + + public class TheGetAllForUserMethod + { [Fact] public void RequestsCorrectGetGistsForAUserUrl() { @@ -105,7 +281,25 @@ public class GistsClientTests client.GetAllForUser("octokit"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/octokit/gists")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/octokit/gists"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectGetGistsForAUserUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAllForUser("octokit", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/octokit/gists"), options); + } [Fact] @@ -118,25 +312,47 @@ public class GistsClientTests client.GetAllForUser("octokit", since); connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/octokit/gists"), - Arg.Is>(x => x.ContainsKey("since"))); - } - } + DictionaryWithSince, Args.ApiOptions); + + } + + [Fact] + public void RequestsCorrectGetGistsForAUserWithSinceUrlAndApiOptions() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + DateTimeOffset since = DateTimeOffset.Now; + client.GetAllForUser("octokit", since, options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/octokit/gists"), + DictionaryWithSince, options); + } + - public class TheGetChildrenMethods - { [Fact] public async Task EnsureNonNullArguments() { var connection = Substitute.For(); var client = new GistsClient(connection); - await Assert.ThrowsAsync(() => client.GetAllCommits(null)); - await Assert.ThrowsAsync(() => client.GetAllCommits("")); - - await Assert.ThrowsAsync(() => client.GetAllForks(null)); - await Assert.ThrowsAsync(() => client.GetAllForks("")); + await Assert.ThrowsAsync(() => client.GetAllForUser(null)); + await Assert.ThrowsAsync(() => client.GetAllForUser("")); + await Assert.ThrowsAsync(() => client.GetAllForUser("", DateTimeOffset.Now)); + await Assert.ThrowsAsync(() => client.GetAllForUser("", DateTimeOffset.Now, ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAllForUser("user", DateTimeOffset.Now, null)); } + } + + public class TheGetAllCommitsMethod + { [Fact] public void RequestsCorrectGetCommitsUrl() { @@ -145,9 +361,42 @@ public class GistsClientTests client.GetAllCommits("9257657"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/9257657/commits")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/9257657/commits"), Args.ApiOptions); } + [Fact] + public void RequestsCorrectGetCommitsUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAllCommits("9257657", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/9257657/commits"), options); + } + + [Fact] + public async Task EnsureNonNullArguments() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + await Assert.ThrowsAsync(() => client.GetAllCommits(null)); + await Assert.ThrowsAsync(() => client.GetAllCommits("")); + await Assert.ThrowsAsync(() => client.GetAllCommits("id", null)); + await Assert.ThrowsAsync(() => client.GetAllCommits("", ApiOptions.None)); + } + + } + + public class TheGetAllForksMethod + { [Fact] public void RequestsCorrectGetForksUrl() { @@ -156,7 +405,36 @@ public class GistsClientTests client.GetAllForks("9257657"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/9257657/forks")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/9257657/forks"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectGetForksUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAllForks("9257657", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/9257657/forks"), options); + } + + [Fact] + public async Task EnsureNonNullArguments() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + await Assert.ThrowsAsync(() => client.GetAllForks(null)); + await Assert.ThrowsAsync(() => client.GetAllForks("")); + await Assert.ThrowsAsync(() => client.GetAllForks("id", null)); + await Assert.ThrowsAsync(() => client.GetAllForks("", ApiOptions.None)); } } @@ -274,7 +552,8 @@ public class GistsClientTests client.Fork("1"); connection.Received().Post(Arg.Is(u => u.ToString() == "gists/1/forks"), - Arg.Any()); + Arg.Any()); + } } @@ -301,21 +580,4 @@ public class GistsClientTests connection.Received().Patch(Arg.Is(u => u.ToString() == "gists/1"), Arg.Any()); } } - - public class TheCtor - { - [Fact] - public void EnsuresArgument() - { - Assert.Throws(() => new GistsClient(null)); - } - - [Fact] - public void SetCommentsClient() - { - var apiConnection = Substitute.For(); - var client = new GistsClient(apiConnection); - Assert.NotNull(client.Comment); - } - } -} +} \ No newline at end of file diff --git a/Octokit.Tests/Clients/GitDatabaseClientTests.cs b/Octokit.Tests/Clients/GitDatabaseClientTests.cs index d66c5ffe..159b44a9 100644 --- a/Octokit.Tests/Clients/GitDatabaseClientTests.cs +++ b/Octokit.Tests/Clients/GitDatabaseClientTests.cs @@ -8,7 +8,7 @@ public class GitDatabaseClientTests public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new GitDatabaseClient(null)); } diff --git a/Octokit.Tests/Clients/IssueCommentsClientTests.cs b/Octokit.Tests/Clients/IssueCommentsClientTests.cs index 4b0eb139..7584eeb9 100644 --- a/Octokit.Tests/Clients/IssueCommentsClientTests.cs +++ b/Octokit.Tests/Clients/IssueCommentsClientTests.cs @@ -3,211 +3,252 @@ using System.Collections.Generic; using System.Net; using System.Threading.Tasks; using NSubstitute; -using Octokit; using Octokit.Internal; -using Octokit.Tests.Helpers; using Xunit; -public class IssueCommentsClientTests +namespace Octokit.Tests.Clients { - public class TheGetMethod + public class IssueCommentsClientTests { - [Fact] - public void RequestsCorrectUrl() + public class TheGetMethod { - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); - client.Get("fake", "repo", 42); + client.Get("fake", "repo", 42); - connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/42")); + connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/42")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new IssueCommentsClient(Substitute.For()); + + await Assert.ThrowsAsync(() => client.Get(null, "name", 1)); + await Assert.ThrowsAsync(() => client.Get("", "name", 1)); + await Assert.ThrowsAsync(() => client.Get("owner", null, 1)); + await Assert.ThrowsAsync(() => client.Get("owner", "", 1)); + } } - [Fact] - public async Task EnsuresNonNullArguments() + public class TheGetForRepositoryMethod { - var client = new IssueCommentsClient(Substitute.For()); + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); - await Assert.ThrowsAsync(() => client.Get(null, "name", 1)); - await Assert.ThrowsAsync(() => client.Get("", "name", 1)); - await Assert.ThrowsAsync(() => client.Get("owner", null, 1)); - await Assert.ThrowsAsync(() => client.Get("owner", "", 1)); - } - } + client.GetAllForRepository("fake", "repo"); - public class TheGetForRepositoryMethod - { - [Fact] - public void RequestsCorrectUrl() - { - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments"), Args.ApiOptions); + } - client.GetAllForRepository("fake", "repo"); + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments")); + var options = new ApiOptions + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + client.GetAllForRepository("fake", "repo", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments"), options); + } + + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); + + await Assert.ThrowsAsync(() => client.GetAllForRepository(null, "name")); + await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name")); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null)); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "")); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name", null)); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "", ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name", ApiOptions.None)); + } } - [Fact] - public async Task EnsuresArgumentsNotNull() + public class TheGetForIssueMethod { - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); - await Assert.ThrowsAsync(() => client.GetAllForRepository(null, "name")); - await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name")); - await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null)); - await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "")); - } - } + client.GetAllForIssue("fake", "repo", 3); - public class TheGetForIssueMethod - { - [Fact] - public void RequestsCorrectUrl() - { - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/3/comments"), Args.ApiOptions); + } - client.GetAllForIssue("fake", "repo", 3); + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/3/comments")); + var options = new ApiOptions + { + StartPage = 1, + PageSize = 1, + PageCount = 1 + }; + client.GetAllForIssue("fake", "repo", 3, options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/3/comments"), options); + } + + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); + + await Assert.ThrowsAsync(() => client.GetAllForIssue(null, "name", 1)); + await Assert.ThrowsAsync(() => client.GetAllForIssue("", "name", 1)); + await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", null, 1)); + await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "", 1)); + await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "name", 1, null)); + await Assert.ThrowsAsync(() => client.GetAllForIssue("", "name", 1, ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "", 1, ApiOptions.None)); + } } - [Fact] - public async Task EnsuresArgumentsNotNull() + public class TheCreateMethod { - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); + [Fact] + public void PostsToCorrectUrl() + { + const string newComment = "some title"; + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); - await Assert.ThrowsAsync(() => client.GetAllForIssue(null, "name", 1)); - await Assert.ThrowsAsync(() => client.GetAllForIssue("", "name", 1)); - await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", null, 1)); - await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "", 1)); - } - } + client.Create("fake", "repo", 1, newComment); - public class TheCreateMethod - { - [Fact] - public void PostsToCorrectUrl() - { - const string newComment = "some title"; - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); + connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/1/comments"), Arg.Any()); + } - client.Create("fake", "repo", 1, newComment); + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); - connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/1/comments"), Arg.Any()); + await Assert.ThrowsAsync(() => client.Create(null, "name", 1, "title")); + await Assert.ThrowsAsync(() => client.Create("", "name", 1, "x")); + await Assert.ThrowsAsync(() => client.Create("owner", null, 1, "x")); + await Assert.ThrowsAsync(() => client.Create("owner", "", 1, "x")); + await Assert.ThrowsAsync(() => client.Create("owner", "name", 1, null)); + } } - [Fact] - public async Task EnsuresArgumentsNotNull() + public class TheUpdateMethod { - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); + [Fact] + public void PostsToCorrectUrl() + { + const string issueCommentUpdate = "Worthwhile update"; + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); - await Assert.ThrowsAsync(() => client.Create(null, "name", 1, "title")); - await Assert.ThrowsAsync(() => client.Create("", "name", 1, "x")); - await Assert.ThrowsAsync(() => client.Create("owner", null, 1, "x")); - await Assert.ThrowsAsync(() => client.Create("owner", "", 1, "x")); - await Assert.ThrowsAsync(() => client.Create("owner", "name", 1, null)); - } - } + client.Update("fake", "repo", 42, issueCommentUpdate); - public class TheUpdateMethod - { - [Fact] - public void PostsToCorrectUrl() - { - const string issueCommentUpdate = "Worthwhile update"; - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); + connection.Received().Patch(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/42"), Arg.Any()); + } - client.Update("fake", "repo", 42, issueCommentUpdate); + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); - connection.Received().Patch(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/42"), Arg.Any()); + await Assert.ThrowsAsync(() => client.Update(null, "name", 42, "title")); + await Assert.ThrowsAsync(() => client.Update("", "name", 42, "x")); + await Assert.ThrowsAsync(() => client.Update("owner", null, 42, "x")); + await Assert.ThrowsAsync(() => client.Update("owner", "", 42, "x")); + await Assert.ThrowsAsync(() => client.Update("owner", "name", 42, null)); + } } - [Fact] - public async Task EnsuresArgumentsNotNull() + public class TheDeleteMethod { - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); + [Fact] + public void DeletesCorrectUrl() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); - await Assert.ThrowsAsync(() => client.Update(null, "name", 42, "title")); - await Assert.ThrowsAsync(() => client.Update("", "name", 42, "x")); - await Assert.ThrowsAsync(() => client.Update("owner", null, 42, "x")); - await Assert.ThrowsAsync(() => client.Update("owner", "", 42, "x")); - await Assert.ThrowsAsync(() => client.Update("owner", "name", 42, null)); + client.Delete("fake", "repo", 42); + + connection.Received().Delete(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/42")); + } + + [Fact] + public async Task EnsuresArgumentsNotNullOrEmpty() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); + + await Assert.ThrowsAsync(() => client.Delete(null, "name", 42)); + await Assert.ThrowsAsync(() => client.Delete("", "name", 42)); + await Assert.ThrowsAsync(() => client.Delete("owner", null, 42)); + await Assert.ThrowsAsync(() => client.Delete("owner", "", 42)); + } } - } - - public class TheDeleteMethod - { - [Fact] - public void DeletesCorrectUrl() - { - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); - - client.Delete("fake", "repo", 42); - - connection.Received().Delete(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/42")); - } - - [Fact] - public async Task EnsuresArgumentsNotNullOrEmpty() - { - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); - - await Assert.ThrowsAsync(() => client.Delete(null, "name", 42)); - await Assert.ThrowsAsync(() => client.Delete("", "name", 42)); - await Assert.ThrowsAsync(() => client.Delete("owner", null, 42)); - await Assert.ThrowsAsync(() => client.Delete("owner", "", 42)); - } - } public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new IssueCommentsClient(null)); } } - [Fact] - public void CanDeserializeIssueComment() - { - const string issueResponseJson = - "{\"id\": 1," + - "\"url\": \"https://api.github.com/repos/octocat/Hello-World/issues/comments/1\"," + - "\"html_url\": \"https://github.com/octocat/Hello-World/issues/1347#issuecomment-1\"," + - "\"body\": \"Me too\"," + - "\"user\": {" + - "\"login\": \"octocat\"," + - "\"id\": 1," + - "\"avatar_url\": \"https://github.com/images/error/octocat_happy.gif\"," + - "\"gravatar_id\": \"somehexcode\"," + - "\"url\": \"https://api.github.com/users/octocat\"" + - "}," + - "\"created_at\": \"2011-04-14T16:00:49Z\"," + - "\"updated_at\": \"2011-04-14T16:00:49Z\"" + - "}"; - var httpResponse = new Response( - HttpStatusCode.OK, - issueResponseJson, - new Dictionary(), - "application/json"); + [Fact] + public void CanDeserializeIssueComment() + { + const string issueResponseJson = + "{\"id\": 1," + + "\"url\": \"https://api.github.com/repos/octocat/Hello-World/issues/comments/1\"," + + "\"html_url\": \"https://github.com/octocat/Hello-World/issues/1347#issuecomment-1\"," + + "\"body\": \"Me too\"," + + "\"user\": {" + + "\"login\": \"octocat\"," + + "\"id\": 1," + + "\"avatar_url\": \"https://github.com/images/error/octocat_happy.gif\"," + + "\"gravatar_id\": \"somehexcode\"," + + "\"url\": \"https://api.github.com/users/octocat\"" + + "}," + + "\"created_at\": \"2011-04-14T16:00:49Z\"," + + "\"updated_at\": \"2011-04-14T16:00:49Z\"" + + "}"; + var httpResponse = new Response( + HttpStatusCode.OK, + issueResponseJson, + new Dictionary(), + "application/json"); - var jsonPipeline = new JsonHttpPipeline(); + var jsonPipeline = new JsonHttpPipeline(); - var response = jsonPipeline.DeserializeResponse(httpResponse); + var response = jsonPipeline.DeserializeResponse(httpResponse); - Assert.NotNull(response.Body); - Assert.Equal(issueResponseJson, response.HttpResponse.Body); - Assert.Equal(1, response.Body.Id); + Assert.NotNull(response.Body); + Assert.Equal(issueResponseJson, response.HttpResponse.Body); + Assert.Equal(1, response.Body.Id); + } } } diff --git a/Octokit.Tests/Clients/IssuesClientTests.cs b/Octokit.Tests/Clients/IssuesClientTests.cs index 2f3b759b..9dbe0436 100644 --- a/Octokit.Tests/Clients/IssuesClientTests.cs +++ b/Octokit.Tests/Clients/IssuesClientTests.cs @@ -4,7 +4,6 @@ using System.Net; using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -185,10 +184,62 @@ namespace Octokit.Tests.Clients } } + public class TheLockMethod + { + [Fact] + public void PostsToCorrectUrl() + { + var connection = Substitute.For(); + var client = new IssuesClient(connection); + + client.Lock("fake", "repo", 42); + + connection.Received().Put(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/lock"), Arg.Any(), Arg.Any(), Arg.Is(u => u.ToString() == "application/vnd.github.the-key-preview+json")); + } + + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var connection = Substitute.For(); + var client = new IssuesClient(connection); + + await Assert.ThrowsAsync(() => client.Lock(null, "name", 1)); + await Assert.ThrowsAsync(() => client.Lock("", "name", 1)); + await Assert.ThrowsAsync(() => client.Lock("owner", null, 1)); + await Assert.ThrowsAsync(() => client.Lock("owner", "", 1)); + } + } + + public class TheUnlockMethod + { + [Fact] + public void PostsToCorrectUrl() + { + var connection = Substitute.For(); + var client = new IssuesClient(connection); + + client.Unlock("fake", "repo", 42); + + connection.Received().Delete(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/lock"), Arg.Any(), Arg.Is(u => u.ToString() == "application/vnd.github.the-key-preview+json")); + } + + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var connection = Substitute.For(); + var client = new IssuesClient(connection); + + await Assert.ThrowsAsync(() => client.Unlock(null, "name", 1)); + await Assert.ThrowsAsync(() => client.Unlock("", "name", 1)); + await Assert.ThrowsAsync(() => client.Unlock("owner", null, 1)); + await Assert.ThrowsAsync(() => client.Unlock("owner", "", 1)); + } + } + public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new IssuesClient(null)); } diff --git a/Octokit.Tests/Clients/IssuesEventsClientTests.cs b/Octokit.Tests/Clients/IssuesEventsClientTests.cs index 4249ea52..98f20170 100644 --- a/Octokit.Tests/Clients/IssuesEventsClientTests.cs +++ b/Octokit.Tests/Clients/IssuesEventsClientTests.cs @@ -1,13 +1,22 @@ using System; using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients { public class IssuesEventsClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new IssuesEventsClient(null)); + } + } + public class TheGetForIssueMethod { [Fact] diff --git a/Octokit.Tests/Clients/IssuesLabelsClientTests.cs b/Octokit.Tests/Clients/IssuesLabelsClientTests.cs index 737296b3..d614af4c 100644 --- a/Octokit.Tests/Clients/IssuesLabelsClientTests.cs +++ b/Octokit.Tests/Clients/IssuesLabelsClientTests.cs @@ -1,7 +1,6 @@ using System; using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; using System.Collections.Generic; @@ -9,6 +8,16 @@ namespace Octokit.Tests.Clients { public class IssuesLabelsClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new IssuesLabelsClient(null)); + } + } + public class TheGetForIssueMethod { [Fact] diff --git a/Octokit.Tests/Clients/MergingClientTests.cs b/Octokit.Tests/Clients/MergingClientTests.cs index 7d5751ec..fa384c94 100644 --- a/Octokit.Tests/Clients/MergingClientTests.cs +++ b/Octokit.Tests/Clients/MergingClientTests.cs @@ -1,7 +1,6 @@ using System; using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -46,7 +45,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new CommitsClient(null)); } diff --git a/Octokit.Tests/Clients/MilestonesClientTests.cs b/Octokit.Tests/Clients/MilestonesClientTests.cs index 22931232..e5807a7c 100644 --- a/Octokit.Tests/Clients/MilestonesClientTests.cs +++ b/Octokit.Tests/Clients/MilestonesClientTests.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -151,7 +150,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new MilestonesClient(null)); } diff --git a/Octokit.Tests/Clients/MiscellaneousClientTests.cs b/Octokit.Tests/Clients/MiscellaneousClientTests.cs index 7b9a0f2b..07e50660 100644 --- a/Octokit.Tests/Clients/MiscellaneousClientTests.cs +++ b/Octokit.Tests/Clients/MiscellaneousClientTests.cs @@ -82,7 +82,7 @@ namespace Octokit.Tests.Clients public class TheGetResourceRateLimitsMethod { [Fact] - public async Task RequestsTheRecourceRateLimitEndpoint() + public async Task RequestsTheResourceRateLimitEndpoint() { IApiResponse response = new ApiResponse ( @@ -136,10 +136,46 @@ namespace Octokit.Tests.Clients } } + public class TheGetMetadataMethod + { + [Fact] + public async Task RequestsTheMetadataEndpoint() + { + IApiResponse response = new ApiResponse + ( + new Response(), + new Meta( + false, + "12345ABCDE", + new[] { "1.1.1.1/24", "1.1.1.2/24" }, + new[] { "1.1.2.1/24", "1.1.2.2/24" }, + new[] { "1.1.3.1/24", "1.1.3.2/24" }, + new[] { "1.1.4.1", "1.1.4.2" } + ) + ); + var connection = Substitute.For(); + connection.Get(Args.Uri, null, null) + .Returns(Task.FromResult(response)); + var client = new MiscellaneousClient(connection); + + var result = await client.GetMetadata(); + + Assert.Equal(result.VerifiablePasswordAuthentication, false); + Assert.Equal(result.GitHubServicesSha, "12345ABCDE"); + Assert.Equal(result.Hooks, new[] { "1.1.1.1/24", "1.1.1.2/24" }); + Assert.Equal(result.Git, new[] { "1.1.2.1/24", "1.1.2.2/24" }); + Assert.Equal(result.Pages, new[] { "1.1.3.1/24", "1.1.3.2/24" }); + Assert.Equal(result.Importer, new[] { "1.1.4.1", "1.1.4.2" }); + + connection.Received() + .Get(Arg.Is(u => u.ToString() == "meta"), null, null); + } + } + public class TheCtor { [Fact] - public void EnsuresArgumentsNotNull() + public void EnsuresNonNullArguments() { Assert.Throws(() => new MiscellaneousClient(null)); } diff --git a/Octokit.Tests/Clients/NotificationsClientTests.cs b/Octokit.Tests/Clients/NotificationsClientTests.cs index f75eff4d..97a8dd13 100644 --- a/Octokit.Tests/Clients/NotificationsClientTests.cs +++ b/Octokit.Tests/Clients/NotificationsClientTests.cs @@ -6,6 +6,16 @@ namespace Octokit.Tests.Clients { public class NotificationsClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new NotificationsClient(null)); + } + } + public class TheGetAllForCurrentMethod { [Fact] diff --git a/Octokit.Tests/Clients/OauthClientTests.cs b/Octokit.Tests/Clients/OauthClientTests.cs index 8b43e065..7f723b26 100644 --- a/Octokit.Tests/Clients/OauthClientTests.cs +++ b/Octokit.Tests/Clients/OauthClientTests.cs @@ -9,6 +9,16 @@ using Xunit; public class OauthClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => + new OauthClient(null)); + } + } + public class TheGetGitHubLoginUrlMethod { [Theory] diff --git a/Octokit.Tests/Clients/OrganizationMembersClientTests.cs b/Octokit.Tests/Clients/OrganizationMembersClientTests.cs index b35b60f7..4bf1b353 100644 --- a/Octokit.Tests/Clients/OrganizationMembersClientTests.cs +++ b/Octokit.Tests/Clients/OrganizationMembersClientTests.cs @@ -4,7 +4,6 @@ using System.Net; using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -15,10 +14,10 @@ namespace Octokit.Tests.Clients /// public class OrganizationMembersClientTests { - public class TheConstructor + public class TheCtor { [Fact] - public void EnsureNonNullArguments() + public void EnsuresNonNullArguments() { Assert.Throws(() => new OrganizationMembersClient(null)); } diff --git a/Octokit.Tests/Clients/OrganizationsClientTests.cs b/Octokit.Tests/Clients/OrganizationsClientTests.cs index 94bb63e5..518de8cc 100644 --- a/Octokit.Tests/Clients/OrganizationsClientTests.cs +++ b/Octokit.Tests/Clients/OrganizationsClientTests.cs @@ -1,7 +1,6 @@ using System; using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -12,7 +11,7 @@ namespace Octokit.Tests.Clients /// public class OrganizationsClientTests { - public class TheConstructor + public class TheCtor { [Fact] public void EnsuresNonNullArguments() diff --git a/Octokit.Tests/Clients/PullRequestReviewCommentsClientTests.cs b/Octokit.Tests/Clients/PullRequestReviewCommentsClientTests.cs index 83e1e3e1..99ebd227 100644 --- a/Octokit.Tests/Clients/PullRequestReviewCommentsClientTests.cs +++ b/Octokit.Tests/Clients/PullRequestReviewCommentsClientTests.cs @@ -3,13 +3,18 @@ using System.Collections.Generic; using System.Threading.Tasks; using NSubstitute; using Octokit; -using Octokit.Tests.Helpers; using Xunit; public class PullRequestReviewCommentsClientTests { - public class TheModelConstructors + public class TheCtor { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new PullRequestReviewCommentsClient(null)); + } + [Fact] public void PullRequestReviewCommentCreateEnsuresArgumentsValue() { diff --git a/Octokit.Tests/Clients/PullRequestsClientTests.cs b/Octokit.Tests/Clients/PullRequestsClientTests.cs index c1067e66..0c02a124 100644 --- a/Octokit.Tests/Clients/PullRequestsClientTests.cs +++ b/Octokit.Tests/Clients/PullRequestsClientTests.cs @@ -249,7 +249,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new PullRequestsClient(null)); } diff --git a/Octokit.Tests/Clients/ReferencesClientTests.cs b/Octokit.Tests/Clients/ReferencesClientTests.cs index ce8bdd53..5d75b1b3 100644 --- a/Octokit.Tests/Clients/ReferencesClientTests.cs +++ b/Octokit.Tests/Clients/ReferencesClientTests.cs @@ -1,7 +1,6 @@ using System; using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -11,7 +10,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ReferencesClient(null)); } diff --git a/Octokit.Tests/Clients/ReleasesClientTests.cs b/Octokit.Tests/Clients/ReleasesClientTests.cs index 10ce49a8..9e79d47e 100644 --- a/Octokit.Tests/Clients/ReleasesClientTests.cs +++ b/Octokit.Tests/Clients/ReleasesClientTests.cs @@ -8,6 +8,16 @@ namespace Octokit.Tests.Clients { public class ReleasesClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => + new ReleasesClient(null)); + } + } + public class TheGetAllMethod { [Fact] @@ -51,8 +61,12 @@ namespace Octokit.Tests.Clients var releasesClient = new ReleasesClient(Substitute.For()); await Assert.ThrowsAsync(() => releasesClient.GetAll(null, "name")); + await Assert.ThrowsAsync(() => releasesClient.GetAll("", "name")); await Assert.ThrowsAsync(() => releasesClient.GetAll("owner", null)); + await Assert.ThrowsAsync(() => releasesClient.GetAll("owner", "")); await Assert.ThrowsAsync(() => releasesClient.GetAll("owner", "name", null)); + await Assert.ThrowsAsync(() => releasesClient.GetAll("", "name", ApiOptions.None)); + await Assert.ThrowsAsync(() => releasesClient.GetAll("owner", "", ApiOptions.None)); } } diff --git a/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs b/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs index 7c7ddfbc..5fb84fc9 100644 --- a/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs +++ b/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; using System.Net; using Octokit.Internal; @@ -15,10 +14,10 @@ namespace Octokit.Tests.Clients /// public class RepoCollaboratorsClientTests { - public class TheConstructor + public class TheCtor { [Fact] - public void ThrowsForBadArgs() + public void EnsuresNonNullArguments() { Assert.Throws(() => new RepoCollaboratorsClient(null)); } diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index 4e8bd182..833045aa 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Net; using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -14,7 +13,7 @@ namespace Octokit.Tests.Clients /// public class RepositoriesClientTests { - public class TheConstructor + public class TheCtor { [Fact] public void EnsuresNonNullArguments() @@ -119,7 +118,7 @@ namespace Octokit.Tests.Clients } [Fact] - public async Task UsesTheOrganizatinosReposUrl() + public async Task UsesTheOrganizationsReposUrl() { var connection = Substitute.For(); var client = new RepositoriesClient(connection); @@ -741,7 +740,7 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAll("owner", null)); await Assert.ThrowsAsync(() => client.GetAll("owner", "")); - await Assert.ThrowsAsync(() => client.GetAll("owner", "repo", null)); + await Assert.ThrowsAsync(() => client.GetAll("owner", "repo", null, ApiOptions.None)); } [Fact] @@ -753,8 +752,7 @@ namespace Octokit.Tests.Clients client.GetAll("owner", "name"); connection.Received() - .GetAll(Arg.Is(u => u.ToString() == "repos/owner/name/commits"), - Arg.Any>()); + .GetAll(Arg.Is(u => u.ToString() == "repos/owner/name/commits"), Args.EmptyDictionary, Args.ApiOptions); } } diff --git a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs index 09177c95..a4083ed4 100644 --- a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using NSubstitute; using Octokit; using Octokit.Internal; -using Octokit.Tests.Helpers; using Xunit; public class RepositoryCommentsClientTests @@ -177,7 +176,7 @@ public class RepositoryCommentsClientTests public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new RepositoryCommentsClient(null)); } diff --git a/Octokit.Tests/Clients/RepositoryContentsClientTests.cs b/Octokit.Tests/Clients/RepositoryContentsClientTests.cs index 2f700c3b..11648733 100644 --- a/Octokit.Tests/Clients/RepositoryContentsClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryContentsClientTests.cs @@ -9,6 +9,16 @@ namespace Octokit.Tests.Clients { public class RepositoryContentsClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new RepositoryContentsClient(null)); + } + } + public class TheGetReadmeMethod { [Fact] diff --git a/Octokit.Tests/Clients/RepositoryDeployKeysClientTests.cs b/Octokit.Tests/Clients/RepositoryDeployKeysClientTests.cs index 96943c96..2362fef4 100644 --- a/Octokit.Tests/Clients/RepositoryDeployKeysClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryDeployKeysClientTests.cs @@ -11,10 +11,10 @@ namespace Octokit.Tests.Clients /// public class RepositoryDeployKeysClientTests { - public class TheConstructor + public class TheCtor { [Fact] - public void ThrowsForBadArgs() + public void EnsuresNonNullArguments() { Assert.Throws(() => new RepositoryDeployKeysClient(null)); } diff --git a/Octokit.Tests/Clients/RepositoryForksClientTests.cs b/Octokit.Tests/Clients/RepositoryForksClientTests.cs index c5a5bfb2..acc0f47a 100644 --- a/Octokit.Tests/Clients/RepositoryForksClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryForksClientTests.cs @@ -8,6 +8,16 @@ namespace Octokit.Tests.Clients { public class RepositoryForksClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new RepositoryForksClient(null)); + } + } + public class TheGetAllMethod { [Fact] diff --git a/Octokit.Tests/Clients/RepositoryHooksClientTest.cs b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs index 908e0648..5b750bed 100644 --- a/Octokit.Tests/Clients/RepositoryHooksClientTest.cs +++ b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs @@ -1,13 +1,23 @@ -using NSubstitute; -using System; +using System; using System.Collections.Generic; using System.Threading.Tasks; +using NSubstitute; using Xunit; namespace Octokit.Tests.Clients { public class RepositoryHooksClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new RepositoryHooksClient(null)); + } + } + public class TheGetAllMethod { [Fact] @@ -18,7 +28,28 @@ namespace Octokit.Tests.Clients client.Hooks.GetAll("fake", "repo"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks"), + Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + + client.Hooks.GetAll("fake", "repo", options); + + connection.Received(1) + .GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks"), + options); } [Fact] @@ -121,7 +152,7 @@ namespace Octokit.Tests.Clients { var connection = Substitute.For(); var client = new RepositoriesClient(connection); - var editRepositoryHook = new EditRepositoryHook() { Active = false }; + var editRepositoryHook = new EditRepositoryHook { Active = false }; client.Hooks.Edit("owner", "repo", 12345678, editRepositoryHook); diff --git a/Octokit.Tests/Clients/RepositoryPagesClientTests.cs b/Octokit.Tests/Clients/RepositoryPagesClientTests.cs index dbafeb1a..1bc0578b 100644 --- a/Octokit.Tests/Clients/RepositoryPagesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryPagesClientTests.cs @@ -7,6 +7,16 @@ namespace Octokit.Tests.Clients { public class RepositoryPagesClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new RepositoryPagesClient(null)); + } + } + public class TheGetMethod { [Fact] diff --git a/Octokit.Tests/Clients/RespositoryCommitsClientTests.cs b/Octokit.Tests/Clients/RespositoryCommitsClientTests.cs new file mode 100644 index 00000000..a54d8434 --- /dev/null +++ b/Octokit.Tests/Clients/RespositoryCommitsClientTests.cs @@ -0,0 +1,59 @@ +using NSubstitute; +using System; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class RespositoryCommitsClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new RepositoryCommitsClient(null)); + } + } + + public class TheGetAllMethod + { + [Fact] + public void EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new RepositoryCommitsClient(connection); + var options = new ApiOptions(); + var request = new CommitRequest(); + + Assert.ThrowsAsync(() => client.GetAll("", "name", request, options)); + Assert.ThrowsAsync(() => client.GetAll("owner", "", request, options)); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new RepositoryCommitsClient(connection); + var options = new ApiOptions(); + var request = new CommitRequest(); + + Assert.ThrowsAsync(() => client.GetAll(null, "name", request, options)); + Assert.ThrowsAsync(() => client.GetAll("owner", null, request, options)); + Assert.ThrowsAsync(() => client.GetAll("owner", "name", null, options)); + Assert.ThrowsAsync(() => client.GetAll("owner", "name", request, null)); + + } + + [Fact] + public void GetsCorrectUrl() + { + var connection = Substitute.For(); + var client = new RepositoryCommitsClient(connection); + + client.GetAll("fake", "repo", new CommitRequest(), new ApiOptions()); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/commits"), Args.EmptyDictionary, Args.ApiOptions); + } + } + } +} diff --git a/Octokit.Tests/Clients/SearchClientTests.cs b/Octokit.Tests/Clients/SearchClientTests.cs index 16f53852..ce14ea07 100644 --- a/Octokit.Tests/Clients/SearchClientTests.cs +++ b/Octokit.Tests/Clients/SearchClientTests.cs @@ -12,7 +12,7 @@ namespace Octokit.Tests.Clients /// public class SearchClientTests { - public class TheConstructor + public class TheCtor { [Fact] public void EnsuresNonNullArguments() @@ -377,7 +377,7 @@ namespace Octokit.Tests.Clients { var connection = Substitute.For(); var client = new SearchClient(connection); - //get repos whos stargazers are greater than 500 + //get repos who's stargazers are greater than 500 var request = new SearchRepositoriesRequest("github"); request.Stars = Range.GreaterThan(500); client.SearchRepo(request); @@ -391,7 +391,7 @@ namespace Octokit.Tests.Clients { var connection = Substitute.For(); var client = new SearchClient(connection); - //get repos whos stargazers are less than 500 + //get repos who's stargazers are less than 500 var request = new SearchRepositoriesRequest("github"); request.Stars = Range.LessThan(500); client.SearchRepo(request); @@ -405,7 +405,7 @@ namespace Octokit.Tests.Clients { var connection = Substitute.For(); var client = new SearchClient(connection); - //get repos whos stargazers are less than 500 or equal to + //get repos who's stargazers are less than 500 or equal to var request = new SearchRepositoriesRequest("github"); request.Stars = Range.LessThanOrEquals(500); client.SearchRepo(request); @@ -445,7 +445,7 @@ namespace Octokit.Tests.Clients { var connection = Substitute.For(); var client = new SearchClient(connection); - //get repos whos language is Ruby + //get repos who's language is Ruby var request = new SearchRepositoriesRequest("github"); request.Language = Language.Ruby; client.SearchRepo(request); diff --git a/Octokit.Tests/Clients/SshKeysClientTests.cs b/Octokit.Tests/Clients/SshKeysClientTests.cs index a9b833be..0d48820d 100644 --- a/Octokit.Tests/Clients/SshKeysClientTests.cs +++ b/Octokit.Tests/Clients/SshKeysClientTests.cs @@ -1,7 +1,6 @@ using System; using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -12,10 +11,10 @@ namespace Octokit.Tests.Clients /// public class SshKeysClientTests { - public class TheConstructor + public class TheCtor { [Fact] - public void ThrowsForBadArgs() + public void EnsuresNonNullArguments() { Assert.Throws(() => new SshKeysClient(null)); } diff --git a/Octokit.Tests/Clients/StarredClientTests.cs b/Octokit.Tests/Clients/StarredClientTests.cs index 97add0e4..e0543bad 100644 --- a/Octokit.Tests/Clients/StarredClientTests.cs +++ b/Octokit.Tests/Clients/StarredClientTests.cs @@ -10,6 +10,16 @@ namespace Octokit.Tests.Clients { public class StarredClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new StarredClient(null)); + } + } + public class TheGetAllForCurrentMethod { [Fact] diff --git a/Octokit.Tests/Clients/StatisticsClientTests.cs b/Octokit.Tests/Clients/StatisticsClientTests.cs index f9142936..6b2b6ece 100644 --- a/Octokit.Tests/Clients/StatisticsClientTests.cs +++ b/Octokit.Tests/Clients/StatisticsClientTests.cs @@ -10,10 +10,10 @@ namespace Octokit.Tests.Clients { public class StatisticsClientTests { - public class TheConstructor + public class TheCtor { [Fact] - public void DoesThrowOnBadArguments() + public void EnsuresNonNullArguments() { Assert.Throws(() => new StatisticsClient(null)); } diff --git a/Octokit.Tests/Clients/TagsClientTests.cs b/Octokit.Tests/Clients/TagsClientTests.cs index 6d5c1a46..384594c9 100644 --- a/Octokit.Tests/Clients/TagsClientTests.cs +++ b/Octokit.Tests/Clients/TagsClientTests.cs @@ -64,7 +64,7 @@ public class TagsClientTests public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new TagsClient(null)); } diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs index dfa09458..f41c3abe 100644 --- a/Octokit.Tests/Clients/TeamsClientTests.cs +++ b/Octokit.Tests/Clients/TeamsClientTests.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -13,7 +12,7 @@ namespace Octokit.Tests.Clients /// public class TeamsClientTests { - public class TheConstructor + public class TheCtor { [Fact] public void EnsuresNonNullArguments() @@ -25,7 +24,7 @@ namespace Octokit.Tests.Clients public class TheGetMethod { [Fact] - public void RequestsTheCorrectlUrl() + public void RequestsTheCorrectUrl() { var connection = Substitute.For(); var client = new TeamsClient(connection); @@ -46,7 +45,9 @@ namespace Octokit.Tests.Clients client.GetAll("orgName"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/orgName/teams")); + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "orgs/orgName/teams"), + Args.ApiOptions); } [Fact] @@ -55,6 +56,7 @@ namespace Octokit.Tests.Clients var teams = new TeamsClient(Substitute.For()); await Assert.ThrowsAsync(() => teams.GetAll(null)); + await Assert.ThrowsAsync(() => teams.GetAll("orgName", null)); } } @@ -68,7 +70,9 @@ namespace Octokit.Tests.Clients client.GetAllMembers(1); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "teams/1/members")); + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "teams/1/members"), + Args.ApiOptions); } } @@ -189,7 +193,9 @@ namespace Octokit.Tests.Clients client.GetAllForCurrent(); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "user/teams")); + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "user/teams"), + Args.ApiOptions); } } @@ -244,13 +250,12 @@ namespace Octokit.Tests.Clients { var connection = Substitute.For(); var client = new TeamsClient(connection); - client.GetAllRepositories(1); - - connection.Received().GetAll(Arg.Is(u => u.ToString() == "teams/1/repos")); client.GetAllRepositories(1); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "teams/1/repos")); + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "teams/1/repos"), + Args.ApiOptions); } } diff --git a/Octokit.Tests/Clients/TreesClientTests.cs b/Octokit.Tests/Clients/TreesClientTests.cs index 687fe9c4..458f9a14 100644 --- a/Octokit.Tests/Clients/TreesClientTests.cs +++ b/Octokit.Tests/Clients/TreesClientTests.cs @@ -4,7 +4,6 @@ using System.Net; using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests @@ -108,7 +107,7 @@ namespace Octokit.Tests public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new TreesClient(null)); } diff --git a/Octokit.Tests/Clients/UserAdministrationClientTests.cs b/Octokit.Tests/Clients/UserAdministrationClientTests.cs index 5e700df3..11934ea5 100644 --- a/Octokit.Tests/Clients/UserAdministrationClientTests.cs +++ b/Octokit.Tests/Clients/UserAdministrationClientTests.cs @@ -8,6 +8,16 @@ namespace Octokit.Tests.Clients { public class UserAdministrationClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new UserAdministrationClient(null)); + } + } + public class TheCreateMethod { [Fact] diff --git a/Octokit.Tests/Clients/UserEmailsClientTests.cs b/Octokit.Tests/Clients/UserEmailsClientTests.cs index 9ea83029..0ccbb8c7 100644 --- a/Octokit.Tests/Clients/UserEmailsClientTests.cs +++ b/Octokit.Tests/Clients/UserEmailsClientTests.cs @@ -113,7 +113,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void EnsuresArguments() + public void EnsuresNonNullArguments() { Assert.Throws( () => new UserEmailsClient(null)); diff --git a/Octokit.Tests/Clients/UserKeysClientTests.cs b/Octokit.Tests/Clients/UserKeysClientTests.cs index e36369f0..d1a044d8 100644 --- a/Octokit.Tests/Clients/UserKeysClientTests.cs +++ b/Octokit.Tests/Clients/UserKeysClientTests.cs @@ -1,6 +1,5 @@ using NSubstitute; using System; -using System.Collections.Generic; using System.Threading.Tasks; using Xunit; @@ -129,7 +128,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void EnsuresArguments() + public void EnsuresNonNullArguments() { Assert.Throws( () => new UserEmailsClient(null)); diff --git a/Octokit.Tests/Clients/UsersClientTests.cs b/Octokit.Tests/Clients/UsersClientTests.cs index 2b83453e..92b288b8 100644 --- a/Octokit.Tests/Clients/UsersClientTests.cs +++ b/Octokit.Tests/Clients/UsersClientTests.cs @@ -1,12 +1,10 @@ using System; -using System.Collections.Generic; #if NET_45 using System.Collections.ObjectModel; #endif using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -17,10 +15,10 @@ namespace Octokit.Tests.Clients /// public class UsersClientTests { - public class TheConstructor + public class TheCtor { [Fact] - public void ThrowsForBadArgs() + public void EnsuresNonNullArguments() { Assert.Throws(() => new UsersClient(null)); } diff --git a/Octokit.Tests/Clients/WatchedClientTests.cs b/Octokit.Tests/Clients/WatchedClientTests.cs index 0f5f7e80..804b6901 100644 --- a/Octokit.Tests/Clients/WatchedClientTests.cs +++ b/Octokit.Tests/Clients/WatchedClientTests.cs @@ -10,6 +10,16 @@ namespace Octokit.Tests.Clients { public class WatchedClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new WatchedClient(null)); + } + } + public class TheGetAllForCurrentMethod { [Fact] diff --git a/Octokit.Tests/Exceptions/LegalRestrictionExceptionTests.cs b/Octokit.Tests/Exceptions/LegalRestrictionExceptionTests.cs new file mode 100644 index 00000000..c6190cea --- /dev/null +++ b/Octokit.Tests/Exceptions/LegalRestrictionExceptionTests.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using System.Net; +using Octokit.Internal; +using Xunit; + +namespace Octokit.Tests.Exceptions +{ + public class LegalRestrictionExceptionTests + { + [Fact] + public void HasDefaultMessage() + { + var response = new Response((HttpStatusCode)451, null, new Dictionary(), "application/json"); + var legalRestrictionException = new LegalRestrictionException(response); + + Assert.Equal("Resource taken down due to a DMCA notice.", legalRestrictionException.Message); + } + } +} \ No newline at end of file diff --git a/Octokit.Tests/Exceptions/TwoFactorRequiredExceptionTests.cs b/Octokit.Tests/Exceptions/TwoFactorRequiredExceptionTests.cs index 82ee949d..8920c0c9 100644 --- a/Octokit.Tests/Exceptions/TwoFactorRequiredExceptionTests.cs +++ b/Octokit.Tests/Exceptions/TwoFactorRequiredExceptionTests.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Collections.Generic; using System.Net; -using System.Text; -using System.Threading.Tasks; using Octokit.Internal; using Xunit; @@ -11,7 +7,7 @@ namespace Octokit.Tests.Exceptions { public class TwoFactorRequiredExceptionTests { - public class TheConstructor + public class TheCtor { [Fact] public void SetsDefaultMessage() diff --git a/Octokit.Tests/GitHubClientTests.cs b/Octokit.Tests/GitHubClientTests.cs index e8e0827b..82ea3423 100644 --- a/Octokit.Tests/GitHubClientTests.cs +++ b/Octokit.Tests/GitHubClientTests.cs @@ -1,18 +1,44 @@ using System; -using System.Net.Http.Headers; using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; using Xunit; -using Xunit.Extensions; using System.Collections.Generic; namespace Octokit.Tests { public class GitHubClientTests { - public class TheConstructor + public class TheCtor { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new GitHubClient((IConnection)null)); + Assert.Throws(() => new GitHubClient((ProductHeaderValue)null)); + + var productInformation = new ProductHeaderValue("UnitTest"); + var baseAddress = new Uri("http://github.com"); + var credentialStore = Substitute.For(); + + Assert.Throws(() => new GitHubClient(productInformation, (ICredentialStore)null)); + Assert.Throws(() => new GitHubClient(null, credentialStore)); + + Assert.Throws(() => new GitHubClient(productInformation, (Uri)null)); + Assert.Throws(() => new GitHubClient(null, baseAddress)); + + Assert.Throws(() => new GitHubClient(null, (ICredentialStore)null)); + Assert.Throws(() => new GitHubClient(null, (Uri)null)); + + Assert.Throws(() => new GitHubClient(productInformation, null, null)); + Assert.Throws(() => new GitHubClient(null, credentialStore, null)); + Assert.Throws(() => new GitHubClient(null, null, baseAddress)); + + Assert.Throws(() => new GitHubClient(null, credentialStore, baseAddress)); + Assert.Throws(() => new GitHubClient(productInformation, null, baseAddress)); + Assert.Throws(() => new GitHubClient(productInformation, credentialStore, null)); + } + [Fact] public void CreatesAnonymousClientByDefault() { diff --git a/Octokit.Tests/Helpers/Arg.cs b/Octokit.Tests/Helpers/Arg.cs index 5408f72d..bee4238b 100644 --- a/Octokit.Tests/Helpers/Arg.cs +++ b/Octokit.Tests/Helpers/Arg.cs @@ -51,7 +51,7 @@ namespace Octokit.Tests public static Dictionary EmptyDictionary { get { return Arg.Is>(d => d.Count == 0); } - } + } public static OrganizationUpdate OrganizationUpdate { diff --git a/Octokit.Tests/Http/ApiInfoTests.cs b/Octokit.Tests/Http/ApiInfoTests.cs index d9c213c7..8b713ca3 100644 --- a/Octokit.Tests/Http/ApiInfoTests.cs +++ b/Octokit.Tests/Http/ApiInfoTests.cs @@ -36,7 +36,7 @@ namespace Octokit.Tests.Http }, new List { - "user", + "user" }, new List { diff --git a/Octokit.Tests/Http/ConnectionTests.cs b/Octokit.Tests/Http/ConnectionTests.cs index db72cbef..01850ccc 100644 --- a/Octokit.Tests/Http/ConnectionTests.cs +++ b/Octokit.Tests/Http/ConnectionTests.cs @@ -7,9 +7,7 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; using NSubstitute; -using NSubstitute.Core.Arguments; using Octokit.Internal; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Http @@ -44,7 +42,7 @@ namespace Octokit.Tests.Http } [Fact] - public async Task CanMakeMutipleRequestsWithSameConnection() + public async Task CanMakeMultipleRequestsWithSameConnection() { var httpClient = Substitute.For(); IResponse response = new Response(); diff --git a/Octokit.Tests/Http/RedirectHandlerTests.cs b/Octokit.Tests/Http/RedirectHandlerTests.cs index 14e46e96..0d68b0ff 100644 --- a/Octokit.Tests/Http/RedirectHandlerTests.cs +++ b/Octokit.Tests/Http/RedirectHandlerTests.cs @@ -165,7 +165,7 @@ namespace Octokit.Tests.Http static HttpMessageInvoker CreateInvoker(HttpResponseMessage httpResponseMessage1, HttpResponseMessage httpResponseMessage2 = null) { - var redirectHandler = new RedirectHandler() + var redirectHandler = new RedirectHandler { InnerHandler = new MockRedirectHandler(httpResponseMessage1, httpResponseMessage2) }; diff --git a/Octokit.Tests/Models/RequestParametersTests.cs b/Octokit.Tests/Models/RequestParametersTests.cs index 187e8806..e62be643 100644 --- a/Octokit.Tests/Models/RequestParametersTests.cs +++ b/Octokit.Tests/Models/RequestParametersTests.cs @@ -116,7 +116,7 @@ namespace Octokit.Tests.Models [Fact] public void UsesParameterAttributeForKey() { - var model = new WithPropertyNameDifferentFromKey() { LongPropertyName = "verbose" }; + var model = new WithPropertyNameDifferentFromKey { LongPropertyName = "verbose" }; var result = model.ToParametersDictionary(); diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 2bfe4e17..19760748 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -99,6 +99,7 @@ + @@ -136,6 +137,7 @@ + @@ -210,6 +212,7 @@ + @@ -218,8 +221,10 @@ + + diff --git a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs index ec8de495..d11aa682 100644 --- a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs +++ b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs @@ -7,6 +7,16 @@ namespace Octokit.Tests { public class ObservableEnterpriseLDAPClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ObservableEnterpriseLdapClient(null)); + } + } + public class TheUpdateUserMappingMethod { readonly string _distinguishedName = "uid=test-user,ou=users,dc=company,dc=com"; diff --git a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLicenseClientTests.cs b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLicenseClientTests.cs index b3f89bb5..49c3fc2d 100644 --- a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLicenseClientTests.cs +++ b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLicenseClientTests.cs @@ -7,6 +7,16 @@ namespace Octokit.Tests { public class ObservableEnterpriseLicenseClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ObservableEnterpriseLicenseClient(null)); + } + } + public class TheGetMethod { [Fact] diff --git a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseOrganizationClientTests.cs b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseOrganizationClientTests.cs index 5e849d84..05dbe7b7 100644 --- a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseOrganizationClientTests.cs +++ b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseOrganizationClientTests.cs @@ -7,6 +7,16 @@ namespace Octokit.Tests { public class ObservableEnterpriseOrganizationClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ObservableEnterpriseOrganizationClient(null)); + } + } + public class TheCreateMethod { [Fact] diff --git a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseSearchIndexingClientTests.cs b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseSearchIndexingClientTests.cs index 02f29b0c..d6e5607f 100644 --- a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseSearchIndexingClientTests.cs +++ b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseSearchIndexingClientTests.cs @@ -1,4 +1,5 @@ -using NSubstitute; +using System; +using NSubstitute; using Octokit.Reactive; using Xunit; @@ -6,6 +7,16 @@ namespace Octokit.Tests { public class ObservableEnterpriseSearchIndexingClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => + new ObservableEnterpriseSearchIndexingClient(null)); + } + } + public class TheQueueMethod { [Fact] diff --git a/Octokit.Tests/Reactive/ObservableBlobClientTests.cs b/Octokit.Tests/Reactive/ObservableBlobClientTests.cs index b182a818..6db6e1e9 100644 --- a/Octokit.Tests/Reactive/ObservableBlobClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableBlobClientTests.cs @@ -1,10 +1,8 @@ using System; -using System.Reactive.Linq; using System.Reactive.Threading.Tasks; using System.Threading.Tasks; using NSubstitute; using Octokit.Reactive; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Reactive @@ -69,7 +67,7 @@ namespace Octokit.Tests.Reactive public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableBlobClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableCommitsClientTests.cs b/Octokit.Tests/Reactive/ObservableCommitsClientTests.cs index a662a70a..da6bda02 100644 --- a/Octokit.Tests/Reactive/ObservableCommitsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableCommitsClientTests.cs @@ -9,10 +9,10 @@ namespace Octokit.Tests.Reactive { public class ObservableCommitsClientTests { - public class TheCtorMethod + public class TheCtor { [Fact] - public void EnsuresArgumentIsNotNull() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableCommitsClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableDeploymentStatusClientTests.cs b/Octokit.Tests/Reactive/ObservableDeploymentStatusClientTests.cs index 8e0dd99f..0360d467 100644 --- a/Octokit.Tests/Reactive/ObservableDeploymentStatusClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableDeploymentStatusClientTests.cs @@ -121,7 +121,7 @@ namespace Octokit.Tests.Reactive public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws( () => new ObservableDeploymentStatusClient(null)); diff --git a/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs b/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs index 9005cc7e..38328dfc 100644 --- a/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs @@ -13,8 +13,10 @@ namespace Octokit.Tests.Reactive { public class TheGetAllMethod { - readonly IGitHubClient _githubClient; - readonly ObservableDeploymentsClient _client; + private readonly IGitHubClient _githubClient; + private readonly ObservableDeploymentsClient _client; + private const string owner = "owner"; + private const string name = "name"; public TheGetAllMethod() { @@ -25,43 +27,88 @@ namespace Octokit.Tests.Reactive [Fact] public void EnsuresNonNullArguments() { - Assert.Throws(() => _client.GetAll(null, "repo")); - Assert.Throws(() => _client.GetAll("owner", null)); + Assert.Throws(() => _client.GetAll(null, name)); + Assert.Throws(() => _client.GetAll(owner, null)); + Assert.Throws(() => _client.GetAll(owner, name, null)); } [Fact] public void EnsuresNonEmptyArguments() { - Assert.Throws(() => _client.GetAll("", "repo")); - Assert.Throws(() => _client.GetAll("owner", "")); + Assert.Throws(() => _client.GetAll("", name)); + Assert.Throws(() => _client.GetAll(owner, "")); } [Fact] public async Task EnsuresNonWhitespaceArguments() { await AssertEx.ThrowsWhenGivenWhitespaceArgument( - async whitespace => await _client.GetAll(whitespace, "repo")); + async whitespace => await _client.GetAll(whitespace, name)); await AssertEx.ThrowsWhenGivenWhitespaceArgument( - async whitespace => await _client.GetAll("owner", whitespace)); + async whitespace => await _client.GetAll(owner, whitespace)); } [Fact] - public void CallsDeploymentsUrl() + public void RequestsCorrectUrl() { - var expectedUri = ApiUrls.Deployments("owner", "repo"); + var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name); - _client.GetAll("owner", "repo"); - _githubClient.Connection - .Received(1) - .Get>(Arg.Is(expectedUri), - Arg.Any>(), Arg.Any()); + _client.GetAll(owner, name); + _githubClient.Connection.Received(1) + .Get>(Arg.Is(u => u.ToString() == expectedUrl), + Arg.Is>(dictionary => dictionary.Count == 0), + Arg.Any()); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name); + + // all properties are setted => only 2 options (StartPage, PageSize) in dictionary + var options = new ApiOptions + { + StartPage = 1, + PageCount = 1, + PageSize = 1 + }; + + _client.GetAll(owner, name, options); + _githubClient.Connection.Received(1) + .Get>(Arg.Is(u => u.ToString() == expectedUrl), + Arg.Is>(dictionary => dictionary.Count == 2), + null); + + // StartPage is setted => only 1 option (StartPage) in dictionary + options = new ApiOptions + { + StartPage = 1 + }; + + _client.GetAll(owner, name, options); + _githubClient.Connection.Received(1) + .Get>(Arg.Is(u => u.ToString() == expectedUrl), + Arg.Is>(dictionary => dictionary.Count == 1), + null); + + // PageCount is setted => none of options in dictionary + options = new ApiOptions + { + PageCount = 1 + }; + + _client.GetAll(owner, name, options); + _githubClient.Connection.Received(1) + .Get>(Arg.Is(u => u.ToString() == expectedUrl), + Arg.Is>(dictionary => dictionary.Count == 0), + null); } } public class TheCreateMethod { - IGitHubClient _githubClient; - ObservableDeploymentsClient _client; + private readonly IGitHubClient _githubClient; + private ObservableDeploymentsClient _client; public TheCreateMethod() { @@ -117,19 +164,20 @@ namespace Octokit.Tests.Reactive var newDeployment = new NewDeployment("ref"); _client.Create("owner", "repo", newDeployment); + _githubClient.Repository.Deployment.Received(1).Create(Arg.Is("owner"), - Arg.Is("repo"), - Arg.Is(newDeployment)); + Arg.Is("repo"), + Arg.Is(newDeployment)); } } public class TheCtor { [Fact] - public void EnsuresArguments() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableDeploymentsClient(null)); } } } -} \ No newline at end of file +} diff --git a/Octokit.Tests/Reactive/ObservableEventsClientTests.cs b/Octokit.Tests/Reactive/ObservableEventsClientTests.cs index 0c8d7e64..78c721d7 100644 --- a/Octokit.Tests/Reactive/ObservableEventsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableEventsClientTests.cs @@ -1,17 +1,25 @@ using System; using System.Collections.Generic; -using System.Reactive.Linq; using System.Reactive.Threading.Tasks; using System.Threading.Tasks; using NSubstitute; using Octokit.Reactive; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Reactive { public class ObservableEventsClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ObservableEventsClient(null)); + } + } + public class TheGetAllMethod { [Fact] @@ -22,7 +30,7 @@ namespace Octokit.Tests.Reactive client.GetAll(); - gitHubClient.Connection.Received(1).Get>(new Uri("events", UriKind.Relative), null, null); + gitHubClient.Connection.Received(1).Get>(new Uri("events", UriKind.Relative), Args.EmptyDictionary, null); } } @@ -36,7 +44,7 @@ namespace Octokit.Tests.Reactive client.GetAllForRepository("fake", "repo"); - gitHubClient.Connection.Received(1).Get>(new Uri("repos/fake/repo/issues/events", UriKind.Relative), null, null); + gitHubClient.Connection.Received(1).Get>(new Uri("repos/fake/repo/issues/events", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] @@ -62,7 +70,7 @@ namespace Octokit.Tests.Reactive client.GetAllForRepositoryNetwork("fake", "repo"); - gitHubClient.Connection.Received(1).Get>(new Uri("networks/fake/repo/events", UriKind.Relative), null, null); + gitHubClient.Connection.Received(1).Get>(new Uri("networks/fake/repo/events", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] @@ -88,7 +96,7 @@ namespace Octokit.Tests.Reactive client.GetAllForOrganization("fake"); - gitHubClient.Connection.Received(1).Get>(new Uri("orgs/fake/events", UriKind.Relative), null, null); + gitHubClient.Connection.Received(1).Get>(new Uri("orgs/fake/events", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] @@ -112,7 +120,7 @@ namespace Octokit.Tests.Reactive client.GetAllUserReceived("fake"); - gitHubClient.Connection.Received(1).Get>(new Uri("users/fake/received_events", UriKind.Relative), null, null); + gitHubClient.Connection.Received(1).Get>(new Uri("users/fake/received_events", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] @@ -136,7 +144,7 @@ namespace Octokit.Tests.Reactive client.GetAllUserReceivedPublic("fake"); - gitHubClient.Connection.Received(1).Get>(new Uri("users/fake/received_events/public", UriKind.Relative), null, null); + gitHubClient.Connection.Received(1).Get>(new Uri("users/fake/received_events/public", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] @@ -160,7 +168,7 @@ namespace Octokit.Tests.Reactive client.GetAllUserPerformed("fake"); - gitHubClient.Connection.Received(1).Get>(new Uri("users/fake/events", UriKind.Relative), null, null); + gitHubClient.Connection.Received(1).Get>(new Uri("users/fake/events", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] @@ -184,7 +192,7 @@ namespace Octokit.Tests.Reactive client.GetAllUserPerformedPublic("fake"); - gitHubClient.Connection.Received(1).Get>(new Uri("users/fake/events/public", UriKind.Relative), null, null); + gitHubClient.Connection.Received(1).Get>(new Uri("users/fake/events/public", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] @@ -208,7 +216,7 @@ namespace Octokit.Tests.Reactive client.GetAllForAnOrganization("fake", "org"); - gitHubClient.Connection.Received(1).Get>(new Uri("users/fake/events/orgs/org", UriKind.Relative), null, null); + gitHubClient.Connection.Received(1).Get>(new Uri("users/fake/events/orgs/org", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableFeedsClientTests.cs b/Octokit.Tests/Reactive/ObservableFeedsClientTests.cs index 6ec7d0e1..0b3e30e6 100644 --- a/Octokit.Tests/Reactive/ObservableFeedsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableFeedsClientTests.cs @@ -1,16 +1,22 @@ -using NSubstitute; +using System; +using NSubstitute; using Octokit.Reactive; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Xunit; namespace Octokit.Tests.Reactive { public class ObservableFeedsClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ObservableFeedsClient(null)); + } + } + public class TheGetFeedsMethod { [Fact] diff --git a/Octokit.Tests/Reactive/ObservableFollowersTest.cs b/Octokit.Tests/Reactive/ObservableFollowersTest.cs index b7bd269d..b44807e6 100644 --- a/Octokit.Tests/Reactive/ObservableFollowersTest.cs +++ b/Octokit.Tests/Reactive/ObservableFollowersTest.cs @@ -25,7 +25,7 @@ namespace Octokit.Tests.Reactive client.GetAllForCurrent(); githubClient.Connection.Received(1).Get>( - new Uri("user/followers", UriKind.Relative), null, null); + new Uri("user/followers", UriKind.Relative), Args.EmptyDictionary, null); } } @@ -40,7 +40,7 @@ namespace Octokit.Tests.Reactive client.GetAll("alfhenrik"); githubClient.Connection.Received(1).Get>( - new Uri("users/alfhenrik/followers", UriKind.Relative), null, null); + new Uri("users/alfhenrik/followers", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] @@ -64,7 +64,7 @@ namespace Octokit.Tests.Reactive client.GetAllFollowingForCurrent(); githubClient.Connection.Received(1).Get>( - new Uri("user/following", UriKind.Relative), null, null); + new Uri("user/following", UriKind.Relative), Args.EmptyDictionary, null); } } @@ -79,7 +79,7 @@ namespace Octokit.Tests.Reactive client.GetAllFollowing("alfhenrik"); githubClient.Connection.Received(1).Get>( - new Uri("users/alfhenrik/following", UriKind.Relative), null, null); + new Uri("users/alfhenrik/following", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableGistsTests.cs b/Octokit.Tests/Reactive/ObservableGistsTests.cs index 0f6b7bab..6f7e7348 100644 --- a/Octokit.Tests/Reactive/ObservableGistsTests.cs +++ b/Octokit.Tests/Reactive/ObservableGistsTests.cs @@ -1,57 +1,418 @@ using System; using System.Collections.Generic; -using System.Reactive.Linq; -using System.Reactive.Threading.Tasks; -using System.Threading.Tasks; using NSubstitute; -using Octokit; -using Octokit.Internal; using Octokit.Reactive; -using Octokit.Reactive.Internal; -using Octokit.Tests.Helpers; using Xunit; -using Xunit.Extensions; + namespace Octokit.Tests.Reactive { public class ObservableGistsTests { - public class TheGetChildrenMethods + public static Dictionary DictionaryWithSince + { + get { return Arg.Is>(d => d.ContainsKey("since")); } + } + public static Dictionary DictionaryWithApiOptions + { + get { return Arg.Is>(d => d.ContainsKey("per_page") && d.ContainsKey("page")); } + } + + public static Dictionary DictionaryWithApiOptionsAndSince + { + get { return Arg.Is>(d => d.ContainsKey("per_page") && d.ContainsKey("page") && d.ContainsKey("since")); } + } + + public class TheCtorMethod { [Fact] - public async Task EnsureNonNullArguments() + public void EnsuresNonNullArguments() { - var client = new ObservableGistsClient(Substitute.For()); + Assert.Throws(() => new ObservableGistsClient(null)); + } + } - await Assert.ThrowsAsync(() => client.GetAllCommits(null).ToTask()); - await Assert.ThrowsAsync(() => client.GetAllCommits("").ToTask()); + public class TheGetAllMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); - await Assert.ThrowsAsync(() => client.GetAllForks(null).ToTask()); - await Assert.ThrowsAsync(() => client.GetAllForks("").ToTask()); + client.GetAll(); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists"), Args.EmptyDictionary, null); } [Fact] - public void RequestsCorrectGetCommitsUrl() + public void RequestsTheCorrectUrlWithApiOptions() { - var github = Substitute.For(); - var client = new ObservableGistsClient(github); - var expected = new Uri("gists/9257657/commits", UriKind.Relative); + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); - client.GetAllCommits("9257657"); + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAll(options); - github.Connection.Received(1).Get>(expected, Arg.Any>(), null); + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists"), + DictionaryWithApiOptions, null); } [Fact] - public void RequestsCorrectGetForksUrl() + public void RequestsTheCorrectUrlWithSince() { - var github = Substitute.For(); - var client = new ObservableGistsClient(github); - var expected = new Uri("gists/9257657/forks", UriKind.Relative); + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); - client.GetAllForks("9257657"); + var since = DateTimeOffset.Now; + client.GetAll(since); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists"), DictionaryWithSince, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithSinceAndApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + var since = DateTimeOffset.Now; + client.GetAll(since, options); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists"), + DictionaryWithApiOptionsAndSince, null); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var gitsClient = new ObservableGistsClient(Substitute.For()); + + Assert.Throws(() => gitsClient.GetAll(null)); + Assert.Throws(() => gitsClient.GetAll(DateTimeOffset.Now, null)); + } + } + + public class TheGetAllPublicMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + client.GetAllPublic(); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists/public"), Args.EmptyDictionary, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAllPublic(options); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists/public"), + DictionaryWithApiOptions, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithSince() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var since = DateTimeOffset.Now; + client.GetAllPublic(since); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists/public"), DictionaryWithSince, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithSinceAndApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + var since = DateTimeOffset.Now; + client.GetAllPublic(since, options); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists/public"), + DictionaryWithApiOptionsAndSince, null); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var gitsClient = new ObservableGistsClient(Substitute.For()); + + Assert.Throws(() => gitsClient.GetAllPublic(null)); + Assert.Throws(() => gitsClient.GetAllPublic(DateTimeOffset.Now, null)); + } + } + + public class TheGetAllStarredMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + client.GetAllStarred(); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists/starred"), Args.EmptyDictionary, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAllStarred(options); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists/starred"), + DictionaryWithApiOptions, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithSince() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var since = DateTimeOffset.Now; + client.GetAllStarred(since); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists/starred"), DictionaryWithSince, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithSinceAndApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + var since = DateTimeOffset.Now; + client.GetAllStarred(since, options); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists/starred"), + DictionaryWithApiOptionsAndSince, null); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var gitsClient = new ObservableGistsClient(Substitute.For()); + + Assert.Throws(() => gitsClient.GetAllStarred(null)); + Assert.Throws(() => gitsClient.GetAllStarred(DateTimeOffset.Now, null)); + } + } + + public class TheGetAllForUserMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + client.GetAllForUser("samthedev"); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "users/samthedev/gists"), Args.EmptyDictionary, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAllForUser("samthedev", options); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "users/samthedev/gists"), + DictionaryWithApiOptions, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithSince() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var since = DateTimeOffset.Now; + var user = "samthedev"; + client.GetAllForUser(user, since); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "users/samthedev/gists"), DictionaryWithSince, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithSinceAndApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + var since = DateTimeOffset.Now; + var user = "samthedev"; + client.GetAllForUser(user, since, options); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "users/samthedev/gists"), + DictionaryWithApiOptionsAndSince, null); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var gitsClient = new ObservableGistsClient(Substitute.For()); + + Assert.Throws(() => gitsClient.GetAllForUser(null)); + Assert.Throws(() => gitsClient.GetAllForUser("")); + Assert.Throws(() => gitsClient.GetAllForUser(null, DateTimeOffset.Now)); + Assert.Throws(() => gitsClient.GetAllForUser("", DateTimeOffset.Now)); + Assert.Throws(() => gitsClient.GetAllForUser("samthedev",DateTimeOffset.Now, null)); + Assert.Throws(() => gitsClient.GetAllForUser("",DateTimeOffset.Now, ApiOptions.None)); + } + } + + public class TheGetAllCommitsMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + client.GetAllCommits("id"); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists/id/commits"), Args.EmptyDictionary, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAllCommits("id", options); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists/id/commits"), + DictionaryWithApiOptions, null); + } + + + [Fact] + public void EnsuresNonNullArguments() + { + var gitsClient = new ObservableGistsClient(Substitute.For()); + + Assert.Throws(() => gitsClient.GetAllCommits(null)); + Assert.Throws(() => gitsClient.GetAllCommits("")); + Assert.Throws(() => gitsClient.GetAllCommits("id", null)); + Assert.Throws(() => gitsClient.GetAllCommits("", ApiOptions.None)); + + } + } + + public class TheGetAllForksMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + client.GetAllForks("id"); + + gitHubClient.Connection.Received(1).Get>(new Uri("gists/id/forks", UriKind.Relative), Args.EmptyDictionary, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAllForks("id", options); + + gitHubClient.Connection.Received(1).Get>(new Uri("gists/id/forks", UriKind.Relative), + DictionaryWithApiOptions, null); + } + + + [Fact] + public void EnsuresNonNullArguments() + { + var gitsClient = new ObservableGistsClient(Substitute.For()); + + Assert.Throws(() => gitsClient.GetAllForks(null)); + Assert.Throws(() => gitsClient.GetAllForks("")); + Assert.Throws(() => gitsClient.GetAllForks("id", null)); + Assert.Throws(() => gitsClient.GetAllForks("", ApiOptions.None)); - github.Connection.Received(1).Get>(expected, Arg.Any>(), null); } } } diff --git a/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs b/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs index 96552397..7efeb88a 100644 --- a/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs @@ -1,11 +1,9 @@ using System; using System.Collections.Generic; -using System.Reactive.Linq; using System.Reactive.Threading.Tasks; using System.Threading.Tasks; using NSubstitute; using Octokit.Reactive; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Reactive @@ -48,7 +46,25 @@ namespace Octokit.Tests.Reactive client.GetAllForRepository("fake", "repo"); gitHubClient.Connection.Received(1).Get>( - new Uri("repos/fake/repo/issues/comments", UriKind.Relative), null, null); + new Uri("repos/fake/repo/issues/comments", UriKind.Relative), Args.EmptyDictionary, null); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableIssueCommentsClient(gitHubClient); + + var options=new ApiOptions + { + StartPage = 1, + PageSize = 1, + PageCount = 1 + }; + client.GetAllForRepository("fake", "repo", options); + + gitHubClient.Connection.Received(1).Get>( + new Uri("repos/fake/repo/issues/comments", UriKind.Relative), Arg.Any>(), null); } [Fact] @@ -61,6 +77,9 @@ namespace Octokit.Tests.Reactive await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name").ToTask()); await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null).ToTask()); await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "").ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name", null).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name", ApiOptions.None).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "", ApiOptions.None).ToTask()); } } @@ -75,7 +94,25 @@ namespace Octokit.Tests.Reactive client.GetAllForIssue("fake", "repo", 3); gitHubClient.Connection.Received(1).Get>( - new Uri("repos/fake/repo/issues/3/comments", UriKind.Relative), null, null); + new Uri("repos/fake/repo/issues/3/comments", UriKind.Relative), Args.EmptyDictionary, null); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableIssueCommentsClient(gitHubClient); + + var options=new ApiOptions + { + StartPage = 1, + PageSize = 1, + PageCount = 1 + }; + client.GetAllForIssue("fake", "repo", 3, options); + + gitHubClient.Connection.Received(1).Get>( + new Uri("repos/fake/repo/issues/3/comments", UriKind.Relative), Arg.Any>(), null); } [Fact] @@ -88,6 +125,9 @@ namespace Octokit.Tests.Reactive await Assert.ThrowsAsync(() => client.GetAllForIssue("", "name", 1).ToTask()); await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", null, 1).ToTask()); await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "", 1).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "name", 1, null).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForIssue("", "name", 1, ApiOptions.None).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "", 1, ApiOptions.None).ToTask()); } } @@ -150,7 +190,7 @@ namespace Octokit.Tests.Reactive public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableIssueCommentsClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs index b09a498a..c063e5d4 100644 --- a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs @@ -2,7 +2,6 @@ using Octokit; using Octokit.Internal; using Octokit.Reactive; -using Octokit.Tests.Helpers; using System; using System.Collections.Generic; using System.Reactive.Linq; @@ -337,10 +336,60 @@ public class ObservableIssuesClientTests } } + public class TheLockMethod + { + [Fact] + public void LocksIssue() + { + var gitHubClient = Substitute.For(); + var client = new ObservableIssuesClient(gitHubClient); + + client.Lock("fake", "repo", 42); + gitHubClient.Issue.Received().Lock("fake", "repo", 42); + } + + [Fact] + public void EnsuresArgumentsNotNull() + { + var gitHubClient = Substitute.For(); + var client = new ObservableIssuesClient(gitHubClient); + + Assert.Throws(() => client.Lock(null, "name", 42)); + Assert.Throws(() => client.Lock("", "name", 42)); + Assert.Throws(() => client.Lock("owner", null, 42)); + Assert.Throws(() => client.Lock("owner", "", 42)); + } + } + + public class TheUnlockMethod + { + [Fact] + public void UnlocksIssue() + { + var gitHubClient = Substitute.For(); + var client = new ObservableIssuesClient(gitHubClient); + + client.Unlock("fake", "repo", 42); + gitHubClient.Issue.Received().Unlock("fake", "repo", 42); + } + + [Fact] + public void EnsuresArgumentsNotNull() + { + var gitHubClient = Substitute.For(); + var client = new ObservableIssuesClient(gitHubClient); + + Assert.Throws(() => client.Unlock(null, "name", 42)); + Assert.Throws(() => client.Unlock("", "name", 42)); + Assert.Throws(() => client.Unlock("owner", null, 42)); + Assert.Throws(() => client.Unlock("owner", "", 42)); + } + } + public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new IssuesClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableMilestonesClientTests.cs b/Octokit.Tests/Reactive/ObservableMilestonesClientTests.cs index 1c9b2690..beade987 100644 --- a/Octokit.Tests/Reactive/ObservableMilestonesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableMilestonesClientTests.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; using Octokit.Reactive; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Reactive @@ -236,7 +235,7 @@ namespace Octokit.Tests.Reactive public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new MilestonesClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableMiscellaneousClientTests.cs b/Octokit.Tests/Reactive/ObservableMiscellaneousClientTests.cs new file mode 100644 index 00000000..b069c08b --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableMiscellaneousClientTests.cs @@ -0,0 +1,145 @@ +using System; +using NSubstitute; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableMiscellaneousClientTests + { + public class TheGetAllEmojisMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For(); + var client = new ObservableMiscellaneousClient(gitHubClient); + + client.GetAllEmojis(); + + gitHubClient.Miscellaneous.Received(1).GetAllEmojis(); + } + } + + public class TheRenderArbitraryMarkdownMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For(); + var client = new ObservableMiscellaneousClient(gitHubClient); + + client.RenderArbitraryMarkdown(new NewArbitraryMarkdown("# test")); + + gitHubClient.Miscellaneous.Received(1).RenderArbitraryMarkdown(Arg.Is(a => a.Text == "# test")); + } + } + + public class TheRenderRawMarkdownMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For(); + var client = new ObservableMiscellaneousClient(gitHubClient); + + client.RenderRawMarkdown("# test"); + + gitHubClient.Miscellaneous.Received(1).RenderRawMarkdown("# test"); + } + } + + public class TheGetAllGitIgnoreTemplatesMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For(); + var client = new ObservableMiscellaneousClient(gitHubClient); + + client.GetAllGitIgnoreTemplates(); + + gitHubClient.Miscellaneous.Received(1).GetAllGitIgnoreTemplates(); + } + } + + public class TheGetGitIgnoreTemplate + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For(); + var client = new ObservableMiscellaneousClient(gitHubClient); + + client.GetGitIgnoreTemplate("template"); + + gitHubClient.Miscellaneous.Received(1).GetGitIgnoreTemplate("template"); + } + } + + public class TheGetAllLicensesMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For(); + var client = new ObservableMiscellaneousClient(gitHubClient); + + client.GetAllLicenses(); + + gitHubClient.Miscellaneous.Received(1).GetAllLicenses(); + } + } + + public class TheGetLicenseMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For(); + var client = new ObservableMiscellaneousClient(gitHubClient); + + client.GetLicense("key"); + + gitHubClient.Miscellaneous.Received(1).GetLicense("key"); + } + } + + public class TheGetRateLimitsMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For(); + var client = new ObservableMiscellaneousClient(gitHubClient); + + client.GetRateLimits(); + + gitHubClient.Miscellaneous.Received(1).GetRateLimits(); + } + } + + public class TheGetMetadataMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For(); + var client = new ObservableMiscellaneousClient(gitHubClient); + + client.GetMetadata(); + + gitHubClient.Miscellaneous.Received(1).GetMetadata(); + } + } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new ObservableMiscellaneousClient((IGitHubClient)null)); + } + } + } +} diff --git a/Octokit.Tests/Reactive/ObservableOrganizationMembersClientTests.cs b/Octokit.Tests/Reactive/ObservableOrganizationMembersClientTests.cs index 76244f74..92941de0 100644 --- a/Octokit.Tests/Reactive/ObservableOrganizationMembersClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableOrganizationMembersClientTests.cs @@ -1,11 +1,7 @@ using NSubstitute; -using Octokit; -using Octokit.Internal; using Octokit.Reactive; -using Octokit.Tests.Helpers; using System; using System.Collections.Generic; -using System.Reactive.Linq; using System.Reactive.Threading.Tasks; using System.Threading.Tasks; using Xunit; @@ -14,6 +10,16 @@ namespace Octokit.Tests.Reactive { public class ObservableOrganizationMembersClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ObservableOrganizationMembersClient(null)); + } + } + public class TheGetAllMethod { [Fact] diff --git a/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentsClientTests.cs b/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentsClientTests.cs index 5312fcb4..06522564 100644 --- a/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentsClientTests.cs @@ -6,13 +6,22 @@ using NSubstitute; using Octokit.Internal; using Octokit.Reactive; using System.Reactive.Threading.Tasks; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Reactive { public class ObservablePullRequestReviewCommentsClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ObservablePullRequestReviewCommentsClient(null)); + } + } + static IResponse CreateResponseWithApiInfo(IDictionary links) { var response = Substitute.For(); diff --git a/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs b/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs index f9d7eec1..3d8ad7b9 100644 --- a/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs @@ -7,7 +7,6 @@ using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; using Octokit.Reactive; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Reactive @@ -352,10 +351,11 @@ namespace Octokit.Tests.Reactive await Assert.ThrowsAsync(() => client.Files("owner", "", 1)); } } + public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new PullRequestsClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs b/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs index fd8f94bb..ca163f6d 100644 --- a/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs @@ -9,10 +9,10 @@ namespace Octokit.Tests.Reactive { public class ObservableReleasesClientTests { - public class TheCtorMethod + public class TheCtor { [Fact] - public void EnsuresArgumentIsNotNull() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableReleasesClient(null)); } @@ -29,7 +29,7 @@ namespace Octokit.Tests.Reactive client.GetAll("fake", "repo"); gitHubClient.Connection.Received(1).Get>( - new Uri("repos/fake/repo/releases", UriKind.Relative), null, null); + new Uri("repos/fake/repo/releases", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs index a2f0e31f..fa359b0d 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs @@ -11,6 +11,16 @@ namespace Octokit.Tests.Reactive { public class ObservableRepositoriesClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ObservableRepositoriesClient(null)); + } + } + public class TheGetMethod { // This isn't really a test specific to this method. This is just as good a place as any to test @@ -269,13 +279,13 @@ namespace Octokit.Tests.Reactive public class TheGetAllCommitsMethod { [Fact] - public void EnsuresArguments() + public void EnsuresNonNullArguments() { var client = new ObservableRepositoriesClient(Substitute.For()); Assert.Throws(() => client.Commit.GetAll(null, "repo")); Assert.Throws(() => client.Commit.GetAll("owner", null)); - Assert.Throws(() => client.Commit.GetAll("owner", "repo", null)); + Assert.Throws(() => client.Commit.GetAll("owner", "repo", null, ApiOptions.None)); Assert.Throws(() => client.Commit.GetAll("", "repo")); Assert.Throws(() => client.Commit.GetAll("owner", "")); } diff --git a/Octokit.Tests/Reactive/ObservableRepositoryCommitsClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryCommitsClientTests.cs index bcd91f37..9891b046 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryCommitsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryCommitsClientTests.cs @@ -12,12 +12,54 @@ namespace Octokit.Tests.Reactive public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableRepositoryCommitsClient(null)); } } + public class TheGetAllMethod + { + [Fact] + public void EnsuresNonEmptyArguments() + { + var githubClient = Substitute.For(); + var client = new ObservableRepositoryCommitsClient(githubClient); + var options = new ApiOptions(); + var request = new CommitRequest(); + + Assert.ThrowsAsync(() => client.GetAll("", "name", request, options).ToTask()); + Assert.ThrowsAsync(() => client.GetAll("owner", "", request, options).ToTask()); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var githubClient = Substitute.For(); + var client = new ObservableRepositoryCommitsClient(githubClient); + var options = new ApiOptions(); + var request = new CommitRequest(); + + Assert.ThrowsAsync(() => client.GetAll(null, "name", request, options).ToTask()); + Assert.ThrowsAsync(() => client.GetAll("owner", null, request, options).ToTask()); + Assert.ThrowsAsync(() => client.GetAll("owner", "name", null, options).ToTask()); + Assert.ThrowsAsync(() => client.GetAll("owner", "name", request, null).ToTask()); + + } + + [Fact] + public void GetsCorrectUrl() + { + var githubClient = Substitute.For(); + var client = new ObservableRepositoryCommitsClient(githubClient); + var options = new ApiOptions(); + var request = new CommitRequest(); + + client.GetAll("fake", "repo", request, options); + githubClient.Received().Repository.Commit.GetAll("fake", "repo", request, options); + } + } + public class TheGetSha1Method { [Fact] diff --git a/Octokit.Tests/Reactive/ObservableRepositoryDeployKeysClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryDeployKeysClientTests.cs index 171e7761..81a4f439 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryDeployKeysClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryDeployKeysClientTests.cs @@ -1,10 +1,6 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using NSubstitute; -using NSubstitute.Core; using Octokit.Reactive; using Xunit; @@ -12,10 +8,10 @@ namespace Octokit.Tests.Reactive { public class ObservableRepositoryDeployKeysClientTests { - public class TheConstructor + public class TheCtor { [Fact] - public void ThrowsForBadArgs() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableRepositoryDeployKeysClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableRepositoryHooksClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryHooksClientTests.cs new file mode 100644 index 00000000..f3c7961c --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableRepositoryHooksClientTests.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using NSubstitute; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableRepositoryHooksClientTests + { + public class ObservableAuthorizationsClientTests + { + const string owner = "owner"; + const string repositoryName = "name"; + + public class TheGetAllMethod + { + [Fact] + public void GetsCorrectUrl() + { + var client = Substitute.For(); + var authEndpoint = new ObservableRepositoryHooksClient(client); + var expectedUrl = string.Format("repos/{0}/{1}/hooks", owner, repositoryName); + + authEndpoint.GetAll(owner, repositoryName); + + client.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == expectedUrl), + Arg.Is>(dictionary => dictionary.Count == 0), null); + } + + [Fact] + public void GetsCorrectUrlWithApiOption() + { + var gitHubClient = Substitute.For(); + var hooksClient = new ObservableRepositoryHooksClient(gitHubClient); + var expectedUrl = string.Format("repos/{0}/{1}/hooks", owner, repositoryName); + + // all properties are setted => only 2 options (StartPage, PageSize) in dictionary + var options = new ApiOptions + { + StartPage = 1, + PageCount = 1, + PageSize = 1 + }; + + hooksClient.GetAll(owner, repositoryName, options); + gitHubClient.Connection.Received(1) + .Get>(Arg.Is(u => u.ToString() == expectedUrl), + Arg.Is>(dictionary => dictionary.Count == 2), + null); + + // StartPage is setted => only 1 option (StartPage) in dictionary + options = new ApiOptions + { + StartPage = 1 + }; + + hooksClient.GetAll(owner, repositoryName, options); + gitHubClient.Connection.Received(1) + .Get>(Arg.Is(u => u.ToString() == expectedUrl), + Arg.Is>(dictionary => dictionary.Count == 1), + null); + + // PageCount is setted => none of options in dictionary + options = new ApiOptions + { + PageCount = 1 + }; + + hooksClient.GetAll(owner, repositoryName, options); + gitHubClient.Connection.Received(1) + .Get>(Arg.Is(u => u.ToString() == expectedUrl), + Arg.Is>(dictionary => dictionary.Count == 0), + null); + } + } + } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ObservableRepositoryHooksClient(null)); + } + } + } +} \ No newline at end of file diff --git a/Octokit.Tests/Reactive/ObservableStarredClientTests.cs b/Octokit.Tests/Reactive/ObservableStarredClientTests.cs index bad0644f..c6924dd6 100644 --- a/Octokit.Tests/Reactive/ObservableStarredClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableStarredClientTests.cs @@ -1,21 +1,24 @@ using System; using System.Collections.Generic; -using System.Reactive.Linq; using System.Reactive.Threading.Tasks; using System.Threading.Tasks; using NSubstitute; -using Octokit; -using Octokit.Internal; using Octokit.Reactive; -using Octokit.Reactive.Internal; -using Octokit.Tests.Helpers; using Xunit; -using Xunit.Extensions; namespace Octokit.Tests.Reactive { public class ObservableStarredClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new ObservableStarredClient(null)); + } + } + public class TheGetAllStargazersMethod { [Fact] diff --git a/Octokit.Tests/Reactive/ObservableStatisticsClientTests.cs b/Octokit.Tests/Reactive/ObservableStatisticsClientTests.cs index 94d94791..25141dab 100644 --- a/Octokit.Tests/Reactive/ObservableStatisticsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableStatisticsClientTests.cs @@ -1,16 +1,23 @@ using System; -using System.Reactive.Linq; using System.Reactive.Threading.Tasks; using System.Threading.Tasks; using NSubstitute; using Octokit.Reactive; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Reactive { public class ObservableStatisticsClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new ObservableStatisticsClient(null)); + } + } + public class TheGetMethod { [Fact] diff --git a/Octokit.Tests/Reactive/ObservableTeamsClientTests.cs b/Octokit.Tests/Reactive/ObservableTeamsClientTests.cs new file mode 100644 index 00000000..5fc8bd39 --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableTeamsClientTests.cs @@ -0,0 +1,46 @@ +using System; +using System.Reactive.Threading.Tasks; +using NSubstitute; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableTeamsClientTests + { + public class TheCreateMethod + { + [Fact] + public void PostsToCorrectUrl() + { + var team = new NewTeam("avengers"); + var github = Substitute.For(); + var client = new ObservableTeamsClient(github); + + client.Create("shield", team); + + github.Organization.Team.Received().Create("shield", team); + } + + [Fact] + public void EnsuresNotNullAndNonEmptyArguments() + { + var github = Substitute.For(); + var client = new ObservableTeamsClient(github); + + Assert.ThrowsAsync(() => client.Create("shield", null).ToTask()); + Assert.ThrowsAsync(() => client.Create(null, new NewTeam("avengers")).ToTask()); + Assert.ThrowsAsync(() => client.Create("", new NewTeam("avengers")).ToTask()); + } + } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new ObservableTeamsClient(null)); + } + } + } +} \ No newline at end of file diff --git a/Octokit.Tests/Reactive/ObservableTreesClientTests.cs b/Octokit.Tests/Reactive/ObservableTreesClientTests.cs index 68156e42..d2e0920c 100644 --- a/Octokit.Tests/Reactive/ObservableTreesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableTreesClientTests.cs @@ -1,16 +1,23 @@ using System; -using System.Reactive.Linq; using System.Reactive.Threading.Tasks; using System.Threading.Tasks; using NSubstitute; using Octokit.Reactive; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests { public class ObservableTreesClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new ObservableTreesClient(null)); + } + } + public class TheGetMethod { [Fact] diff --git a/Octokit.Tests/Reactive/ObservableUserAdministrationClientTests.cs b/Octokit.Tests/Reactive/ObservableUserAdministrationClientTests.cs index d6a1fab9..5290511a 100644 --- a/Octokit.Tests/Reactive/ObservableUserAdministrationClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableUserAdministrationClientTests.cs @@ -180,7 +180,7 @@ namespace Octokit.Tests.Reactive public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableUserAdministrationClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableUserKeysClientTests.cs b/Octokit.Tests/Reactive/ObservableUserKeysClientTests.cs index 3a569e27..385a5a1f 100644 --- a/Octokit.Tests/Reactive/ObservableUserKeysClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableUserKeysClientTests.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using NSubstitute; using Octokit.Reactive; using Xunit; @@ -84,7 +83,7 @@ namespace Octokit.Tests.Reactive public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableUserKeysClient(null)); } diff --git a/Octokit/Clients/AssigneesClient.cs b/Octokit/Clients/AssigneesClient.cs index 58ca8666..0cd692c7 100644 --- a/Octokit/Clients/AssigneesClient.cs +++ b/Octokit/Clients/AssigneesClient.cs @@ -66,8 +66,7 @@ namespace Octokit try { - var response = await Connection.Get(ApiUrls.CheckAssignee(owner, name, assignee), null, null) - .ConfigureAwait(false); + var response = await Connection.Get(ApiUrls.CheckAssignee(owner, name, assignee), null, null).ConfigureAwait(false); return response.HttpResponse.IsTrue(); } catch (NotFoundException) diff --git a/Octokit/Clients/AuthorizationsClient.cs b/Octokit/Clients/AuthorizationsClient.cs index b6319241..4d6e0340 100644 --- a/Octokit/Clients/AuthorizationsClient.cs +++ b/Octokit/Clients/AuthorizationsClient.cs @@ -320,10 +320,7 @@ namespace Octokit { var endpoint = ApiUrls.AuthorizationsForClient(clientId); - return await ApiConnection.Put( - endpoint, - requestData, - twoFactorAuthenticationCode); + return await ApiConnection.Put(endpoint, requestData, twoFactorAuthenticationCode).ConfigureAwait(false); } catch (AuthorizationException e) { @@ -341,19 +338,17 @@ namespace Octokit /// Client ID of the OAuth application for the token /// The OAuth token to check /// The valid . - public async Task CheckApplicationAuthentication(string clientId, string accessToken) + public Task CheckApplicationAuthentication(string clientId, string accessToken) { Ensure.ArgumentNotNullOrEmptyString(clientId, "clientId"); Ensure.ArgumentNotNullOrEmptyString(accessToken, "accessToken"); var endpoint = ApiUrls.ApplicationAuthorization(clientId, accessToken); - return await ApiConnection.Get( - endpoint, - null); + return ApiConnection.Get(endpoint, null); } /// - /// Resets a valid OAuth token for an OAuth application without end user involvment. + /// Resets a valid OAuth token for an OAuth application without end user involvement. /// /// /// This method requires authentication. @@ -362,15 +357,14 @@ namespace Octokit /// ClientID of the OAuth application for the token /// The OAuth token to reset /// The valid with a new OAuth token - public async Task ResetApplicationAuthentication(string clientId, string accessToken) + public Task ResetApplicationAuthentication(string clientId, string accessToken) { Ensure.ArgumentNotNullOrEmptyString(clientId, "clientId"); Ensure.ArgumentNotNullOrEmptyString(accessToken, "accessToken"); var requestData = new { }; - return await ApiConnection.Post( - ApiUrls.ApplicationAuthorization(clientId, accessToken), requestData); + return ApiConnection.Post(ApiUrls.ApplicationAuthorization(clientId, accessToken), requestData); } /// diff --git a/Octokit/Clients/CommitStatusClient.cs b/Octokit/Clients/CommitStatusClient.cs index 6a42091e..b890bdff 100644 --- a/Octokit/Clients/CommitStatusClient.cs +++ b/Octokit/Clients/CommitStatusClient.cs @@ -36,7 +36,29 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); - return ApiConnection.GetAll(ApiUrls.CommitStatuses(owner, name, reference)); + return GetAll(owner,name,reference,ApiOptions.None); + } + + /// + /// Retrieves commit statuses for the specified reference. A reference can be a commit SHA, a branch name, or + /// a tag name. + /// + /// + /// https://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref + /// + /// The owner of the repository + /// The name of the repository + /// The reference (SHA, branch name, or tag name) to list commits for + /// Options for changing the API response + /// + public Task> GetAll(string owner, string name, string reference, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.CommitStatuses(owner, name, reference),options); } /// diff --git a/Octokit/Clients/DeploymentsClient.cs b/Octokit/Clients/DeploymentsClient.cs index ba84fe28..b543e73e 100644 --- a/Octokit/Clients/DeploymentsClient.cs +++ b/Octokit/Clients/DeploymentsClient.cs @@ -34,10 +34,30 @@ namespace Octokit /// All the s for the specified repository. public Task> GetAll(string owner, string name) { - Ensure.ArgumentNotNullOrEmptyString(owner, "login"); + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return ApiConnection.GetAll(ApiUrls.Deployments(owner, name)); + return GetAll(owner, name, ApiOptions.None); + } + + /// + /// Gets all the deployments for the specified repository. Any user with pull access + /// to a repository can view deployments. + /// + /// + /// http://developer.github.com/v3/repos/deployments/#list-deployments + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the specified repository. + public Task> GetAll(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.Deployments(owner, name), options); } /// diff --git a/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs b/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs index 11e5f9fb..cdbbd7de 100644 --- a/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs @@ -21,12 +21,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The statistics. - public async Task GetStatisticsIssues() + public Task GetStatisticsIssues() { var endpoint = ApiUrls.EnterpriseAdminStatsIssues(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } /// @@ -36,12 +35,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The statistics. - public async Task GetStatisticsHooks() + public Task GetStatisticsHooks() { var endpoint = ApiUrls.EnterpriseAdminStatsHooks(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } /// @@ -51,12 +49,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The statistics. - public async Task GetStatisticsMilestones() + public Task GetStatisticsMilestones() { var endpoint = ApiUrls.EnterpriseAdminStatsMilestones(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } /// @@ -66,12 +63,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The statistics. - public async Task GetStatisticsOrgs() + public Task GetStatisticsOrgs() { var endpoint = ApiUrls.EnterpriseAdminStatsOrgs(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } /// @@ -81,12 +77,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The statistics. - public async Task GetStatisticsComments() + public Task GetStatisticsComments() { var endpoint = ApiUrls.EnterpriseAdminStatsComments(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } /// @@ -96,12 +91,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The statistics. - public async Task GetStatisticsPages() + public Task GetStatisticsPages() { var endpoint = ApiUrls.EnterpriseAdminStatsPages(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } /// @@ -111,12 +105,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The statistics. - public async Task GetStatisticsUsers() + public Task GetStatisticsUsers() { var endpoint = ApiUrls.EnterpriseAdminStatsUsers(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } /// @@ -126,12 +119,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The statistics. - public async Task GetStatisticsGists() + public Task GetStatisticsGists() { var endpoint = ApiUrls.EnterpriseAdminStatsGists(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } /// @@ -141,12 +133,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The statistics. - public async Task GetStatisticsPulls() + public Task GetStatisticsPulls() { var endpoint = ApiUrls.EnterpriseAdminStatsPulls(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } /// @@ -156,12 +147,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The statistics. - public async Task GetStatisticsRepos() + public Task GetStatisticsRepos() { var endpoint = ApiUrls.EnterpriseAdminStatsRepos(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } /// @@ -171,12 +161,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The collection of statistics. - public async Task GetStatisticsAll() + public Task GetStatisticsAll() { var endpoint = ApiUrls.EnterpriseAdminStatsAll(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } } } diff --git a/Octokit/Clients/Enterprise/EnterpriseLdapClient.cs b/Octokit/Clients/Enterprise/EnterpriseLdapClient.cs index 1980dc6f..16c8987f 100644 --- a/Octokit/Clients/Enterprise/EnterpriseLdapClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseLdapClient.cs @@ -48,7 +48,7 @@ namespace Octokit var endpoint = ApiUrls.EnterpriseLdapUserSync(userName); - var response = await Connection.Post(endpoint); + var response = await Connection.Post(endpoint).ConfigureAwait(false); if (response.HttpResponse.StatusCode != HttpStatusCode.Created) { throw new ApiException("Invalid Status Code returned. Expected a 201", response.HttpResponse.StatusCode); @@ -90,7 +90,7 @@ namespace Octokit var endpoint = ApiUrls.EnterpriseLdapTeamSync(teamId); - var response = await Connection.Post(endpoint); + var response = await Connection.Post(endpoint).ConfigureAwait(false); if (response.HttpResponse.StatusCode != HttpStatusCode.Created) { throw new ApiException("Invalid Status Code returned. Expected a 201", response.HttpResponse.StatusCode); diff --git a/Octokit/Clients/Enterprise/EnterpriseLicenseClient.cs b/Octokit/Clients/Enterprise/EnterpriseLicenseClient.cs index 46638883..4efab54b 100644 --- a/Octokit/Clients/Enterprise/EnterpriseLicenseClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseLicenseClient.cs @@ -21,12 +21,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/license/#get-license-information /// /// The statistics. - public async Task Get() + public Task Get() { var endpoint = ApiUrls.EnterpriseLicense(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } } } diff --git a/Octokit/Clients/Enterprise/EnterpriseOrganizationClient.cs b/Octokit/Clients/Enterprise/EnterpriseOrganizationClient.cs index 0848ff8e..22fee148 100644 --- a/Octokit/Clients/Enterprise/EnterpriseOrganizationClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseOrganizationClient.cs @@ -22,13 +22,13 @@ namespace Octokit /// /// A instance describing the organization to be created /// The created. - public async Task Create(NewOrganization newOrganization) + public Task Create(NewOrganization newOrganization) { Ensure.ArgumentNotNull(newOrganization, "newOrganization"); var endpoint = ApiUrls.EnterpriseOrganization(); - return await ApiConnection.Post(endpoint, newOrganization); + return ApiConnection.Post(endpoint, newOrganization); } } } diff --git a/Octokit/Clients/Enterprise/EnterpriseSearchIndexingClient.cs b/Octokit/Clients/Enterprise/EnterpriseSearchIndexingClient.cs index 2351a2f1..0feea186 100644 --- a/Octokit/Clients/Enterprise/EnterpriseSearchIndexingClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseSearchIndexingClient.cs @@ -23,15 +23,14 @@ namespace Octokit /// /// A user or organization account /// The message. - public async Task Queue(string owner) + public Task Queue(string owner) { Ensure.ArgumentNotNull(owner, "owner"); var endpoint = ApiUrls.EnterpriseSearchIndexing(); var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}", owner)); - return await ApiConnection.Post(endpoint, target) - .ConfigureAwait(false); + return ApiConnection.Post(endpoint, target); } /// @@ -43,7 +42,7 @@ namespace Octokit /// A user or organization account /// A repository /// The message. - public async Task Queue(string owner, string repository) + public Task Queue(string owner, string repository) { Ensure.ArgumentNotNull(owner, "owner"); Ensure.ArgumentNotNull(repository, "repository"); @@ -51,8 +50,7 @@ namespace Octokit var endpoint = ApiUrls.EnterpriseSearchIndexing(); var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}/{1}", owner, repository)); - return await ApiConnection.Post(endpoint, target) - .ConfigureAwait(false); + return ApiConnection.Post(endpoint, target); } /// @@ -63,15 +61,14 @@ namespace Octokit /// /// A user or organization account /// The message. - public async Task QueueAll(string owner) + public Task QueueAll(string owner) { Ensure.ArgumentNotNull(owner, "owner"); var endpoint = ApiUrls.EnterpriseSearchIndexing(); var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}/*", owner)); - return await ApiConnection.Post(endpoint, target) - .ConfigureAwait(false); + return ApiConnection.Post(endpoint, target); } /// @@ -83,7 +80,7 @@ namespace Octokit /// A user or organization account /// A repository /// The message. - public async Task QueueAllIssues(string owner, string repository) + public Task QueueAllIssues(string owner, string repository) { Ensure.ArgumentNotNull(owner, "owner"); Ensure.ArgumentNotNull(repository, "repository"); @@ -91,8 +88,7 @@ namespace Octokit var endpoint = ApiUrls.EnterpriseSearchIndexing(); var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}/{1}/issues", owner, repository)); - return await ApiConnection.Post(endpoint, target) - .ConfigureAwait(false); + return ApiConnection.Post(endpoint, target); } /// @@ -103,15 +99,14 @@ namespace Octokit /// /// A user or organization account /// The message. - public async Task QueueAllIssues(string owner) + public Task QueueAllIssues(string owner) { Ensure.ArgumentNotNull(owner, "owner"); var endpoint = ApiUrls.EnterpriseSearchIndexing(); var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}/*/issues", owner)); - return await ApiConnection.Post(endpoint, target) - .ConfigureAwait(false); + return ApiConnection.Post(endpoint, target); } /// @@ -123,7 +118,7 @@ namespace Octokit /// A user or organization account /// A repository /// The message. - public async Task QueueAllCode(string owner, string repository) + public Task QueueAllCode(string owner, string repository) { Ensure.ArgumentNotNull(owner, "owner"); Ensure.ArgumentNotNull(repository, "repository"); @@ -131,8 +126,7 @@ namespace Octokit var endpoint = ApiUrls.EnterpriseSearchIndexing(); var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}/{1}/code", owner, repository)); - return await ApiConnection.Post(endpoint, target) - .ConfigureAwait(false); + return ApiConnection.Post(endpoint, target); } /// @@ -143,15 +137,14 @@ namespace Octokit /// /// A user or organization account /// The message. - public async Task QueueAllCode(string owner) + public Task QueueAllCode(string owner) { Ensure.ArgumentNotNull(owner, "owner"); var endpoint = ApiUrls.EnterpriseSearchIndexing(); var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}/*/code", owner)); - return await ApiConnection.Post(endpoint, target) - .ConfigureAwait(false); + return ApiConnection.Post(endpoint, target); } } } diff --git a/Octokit/Clients/EventsClient.cs b/Octokit/Clients/EventsClient.cs index 65e420f0..a1586ca2 100644 --- a/Octokit/Clients/EventsClient.cs +++ b/Octokit/Clients/EventsClient.cs @@ -29,7 +29,22 @@ namespace Octokit /// All the public s for the particular user. public Task> GetAll() { - return ApiConnection.GetAll(ApiUrls.Events()); + return GetAll(ApiOptions.None); + } + + /// + /// Gets all the public events + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events + /// + /// Options for changing the API response + /// All the public s for the particular user. + public Task> GetAll(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.Events(),options); } /// @@ -46,7 +61,26 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return ApiConnection.GetAll(ApiUrls.IssuesEvents(owner, name)); + return GetAllForRepository(owner,name,ApiOptions.None); + } + + /// + /// Gets all the events for a given repository + /// + /// + /// http://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the particular repository. + public Task> GetAllForRepository(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.IssuesEvents(owner, name),options); } /// @@ -63,7 +97,26 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return ApiConnection.GetAll(ApiUrls.NetworkEvents(owner, name)); + return GetAllForRepositoryNetwork(owner,name,ApiOptions.None); + } + + /// + /// Gets all the events for a given repository network + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-a-network-of-repositories + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the particular repository network. + public Task> GetAllForRepositoryNetwork(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.NetworkEvents(owner, name), options); } /// @@ -78,7 +131,24 @@ namespace Octokit { Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); - return ApiConnection.GetAll(ApiUrls.OrganizationEvents(organization)); + return GetAllForOrganization(organization, ApiOptions.None); + } + + /// + /// Gets all the events for a given organization + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-an-organization + /// + /// The name of the organization + /// Options for changing the API response + /// All the s for the particular organization. + public Task> GetAllForOrganization(string organization, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.OrganizationEvents(organization), options); } /// @@ -93,7 +163,24 @@ namespace Octokit { Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return ApiConnection.GetAll(ApiUrls.ReceivedEvents(user)); + return GetAllUserReceived(user, ApiOptions.None); + } + + /// + /// Gets all the events that have been received by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-that-a-user-has-received + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has received. + public Task> GetAllUserReceived(string user, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.ReceivedEvents(user), options); } /// @@ -108,7 +195,24 @@ namespace Octokit { Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return ApiConnection.GetAll(ApiUrls.ReceivedEvents(user, true)); + return GetAllUserReceivedPublic(user, ApiOptions.None); + } + + /// + /// Gets all the events that have been received by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-that-a-user-has-received + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has received. + public Task> GetAllUserReceivedPublic(string user, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.ReceivedEvents(user, true),options); } /// @@ -123,7 +227,24 @@ namespace Octokit { Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return ApiConnection.GetAll(ApiUrls.PerformedEvents(user)); + return GetAllUserPerformed(user, ApiOptions.None); + } + + /// + /// Gets all the events that have been performed by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-performed-by-a-user + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has performed. + public Task> GetAllUserPerformed(string user, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.PerformedEvents(user),options); } /// @@ -138,7 +259,24 @@ namespace Octokit { Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return ApiConnection.GetAll(ApiUrls.PerformedEvents(user, true)); + return GetAllUserPerformedPublic(user, ApiOptions.None); + } + + /// + /// Gets all the public events that have been performed by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-performed-by-a-user + /// + /// The login of the user + /// Options for changing the API response + /// All the public s that a particular user has performed. + public Task> GetAllUserPerformedPublic(string user, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.PerformedEvents(user, true), options); } /// @@ -155,7 +293,26 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(user, "user"); Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); - return ApiConnection.GetAll(ApiUrls.OrganizationEvents(user, organization)); + return GetAllForAnOrganization(user, organization, ApiOptions.None); + } + + /// + /// Gets all the events that are associated with an organization. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-for-an-organization + /// + /// The login of the user + /// The name of the organization + /// Options for changing the API response + /// All the public s that are associated with an organization. + public Task> GetAllForAnOrganization(string user, string organization, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.OrganizationEvents(user, organization),options); } } } diff --git a/Octokit/Clients/FollowersClient.cs b/Octokit/Clients/FollowersClient.cs index 5a6dcd44..d1295c2b 100644 --- a/Octokit/Clients/FollowersClient.cs +++ b/Octokit/Clients/FollowersClient.cs @@ -29,7 +29,22 @@ namespace Octokit /// A of s that follow the authenticated user. public Task> GetAllForCurrent() { - return ApiConnection.GetAll(ApiUrls.Followers()); + return GetAllForCurrent(ApiOptions.None); + } + + /// + /// List the authenticated user’s followers + /// + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that follow the authenticated user. + public Task> GetAllForCurrent(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.Followers(),options); } /// @@ -44,7 +59,24 @@ namespace Octokit { Ensure.ArgumentNotNullOrEmptyString(login, "login"); - return ApiConnection.GetAll(ApiUrls.Followers(login)); + return GetAll(login, ApiOptions.None); + } + + /// + /// List a user’s followers + /// + /// The login name for the user + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that follow the passed user. + public Task> GetAll(string login, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.Followers(login), options); } /// @@ -56,7 +88,22 @@ namespace Octokit /// A of s that the authenticated user follows. public Task> GetAllFollowingForCurrent() { - return ApiConnection.GetAll(ApiUrls.Following()); + return GetAllFollowingForCurrent(ApiOptions.None); + } + + /// + /// List who the authenticated user is following + /// + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that the authenticated user follows. + public Task> GetAllFollowingForCurrent(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.Following(), options); } /// @@ -71,7 +118,24 @@ namespace Octokit { Ensure.ArgumentNotNullOrEmptyString(login, "login"); - return ApiConnection.GetAll(ApiUrls.Following(login)); + return GetAllFollowing(login, ApiOptions.None); + } + + /// + /// List who a user is following + /// + /// The login name of the user + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that the passed user follows. + public Task> GetAllFollowing(string login, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.Following(login), options); } /// @@ -88,8 +152,7 @@ namespace Octokit try { - var response = await Connection.Get(ApiUrls.IsFollowing(following), null, null) - .ConfigureAwait(false); + var response = await Connection.Get(ApiUrls.IsFollowing(following), null, null).ConfigureAwait(false); return response.HttpResponse.IsTrue(); } catch (NotFoundException) @@ -114,8 +177,7 @@ namespace Octokit try { - var response = await Connection.Get(ApiUrls.IsFollowing(login, following), null, null) - .ConfigureAwait(false); + var response = await Connection.Get(ApiUrls.IsFollowing(login, following), null, null).ConfigureAwait(false); return response.HttpResponse.IsTrue(); } catch (NotFoundException) @@ -139,8 +201,7 @@ namespace Octokit try { var requestData = new { }; - var response = await Connection.Put(ApiUrls.IsFollowing(login), requestData) - .ConfigureAwait(false); + var response = await Connection.Put(ApiUrls.IsFollowing(login), requestData).ConfigureAwait(false); if (response.HttpResponse.StatusCode != HttpStatusCode.NoContent) { throw new ApiException("Invalid Status Code returned. Expected a 204", response.HttpResponse.StatusCode); diff --git a/Octokit/Clients/GistCommentsClient.cs b/Octokit/Clients/GistCommentsClient.cs index 47487159..23eccda0 100644 --- a/Octokit/Clients/GistCommentsClient.cs +++ b/Octokit/Clients/GistCommentsClient.cs @@ -39,7 +39,24 @@ namespace Octokit /// Task{IReadOnlyList{GistComment}}. public Task> GetAllForGist(string gistId) { - return ApiConnection.GetAll(ApiUrls.GistComments(gistId)); + Ensure.ArgumentNotNullOrEmptyString(gistId, "gistId"); + + return GetAllForGist(gistId, ApiOptions.None); + } + + /// + /// Gets all comments for the gist with the specified id. + /// + /// http://developer.github.com/v3/gists/comments/#list-comments-on-a-gist + /// The id of the gist + /// Options for changing the API response + /// Task{IReadOnlyList{GistComment}}. + public Task> GetAllForGist(string gistId, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(gistId, "gistId"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.GistComments(gistId), options); } /// diff --git a/Octokit/Clients/GistsClient.cs b/Octokit/Clients/GistsClient.cs index 87807656..e3d567ba 100644 --- a/Octokit/Clients/GistsClient.cs +++ b/Octokit/Clients/GistsClient.cs @@ -87,7 +87,7 @@ namespace Octokit /// The id of the gist public Task Delete(string id) { - Ensure.ArgumentNotNull(id, "id"); + Ensure.ArgumentNotNullOrEmptyString(id, "id"); return ApiConnection.Delete(ApiUrls.Gist(id)); } @@ -101,7 +101,22 @@ namespace Octokit /// public Task> GetAll() { - return ApiConnection.GetAll(ApiUrls.Gist()); + return GetAll(ApiOptions.None); + } + + /// + /// List the authenticated user’s gists or if called anonymously, + /// this will return all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + public Task> GetAll(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.Gist(), options); } /// @@ -114,8 +129,25 @@ namespace Octokit /// Only gists updated at or after this time are returned public Task> GetAll(DateTimeOffset since) { + + return GetAll(since, ApiOptions.None); + } + + /// + /// List the authenticated user’s gists or if called anonymously, + /// this will return all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + public Task> GetAll(DateTimeOffset since, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + var request = new GistRequest(since); - return ApiConnection.GetAll(ApiUrls.Gist(), request.ToParametersDictionary()); + return ApiConnection.GetAll(ApiUrls.Gist(), request.ToParametersDictionary(), options); } /// @@ -126,7 +158,21 @@ namespace Octokit /// public Task> GetAllPublic() { - return ApiConnection.GetAll(ApiUrls.PublicGists()); + return GetAllPublic(ApiOptions.None); + } + + /// + /// Lists all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + public Task> GetAllPublic(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.PublicGists(), options); } /// @@ -137,9 +183,25 @@ namespace Octokit /// /// Only gists updated at or after this time are returned public Task> GetAllPublic(DateTimeOffset since) + { + + return GetAllPublic(since, ApiOptions.None); + } + + /// + /// Lists all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + public Task> GetAllPublic(DateTimeOffset since, ApiOptions options) { + Ensure.ArgumentNotNull(options, "options"); + var request = new GistRequest(since); - return ApiConnection.GetAll(ApiUrls.PublicGists(), request.ToParametersDictionary()); + return ApiConnection.GetAll(ApiUrls.PublicGists(), request.ToParametersDictionary(), options); } /// @@ -150,7 +212,22 @@ namespace Octokit /// public Task> GetAllStarred() { - return ApiConnection.GetAll(ApiUrls.StarredGists()); + + return GetAllStarred(ApiOptions.None); + } + + /// + /// List the authenticated user’s starred gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + public Task> GetAllStarred(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.StarredGists(), options); } /// @@ -161,9 +238,25 @@ namespace Octokit /// /// Only gists updated at or after this time are returned public Task> GetAllStarred(DateTimeOffset since) + { + + return GetAllStarred(since, ApiOptions.None); + } + + /// + /// List the authenticated user’s starred gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + public Task> GetAllStarred(DateTimeOffset since, ApiOptions options) { + Ensure.ArgumentNotNull(options, "options"); + var request = new GistRequest(since); - return ApiConnection.GetAll(ApiUrls.StarredGists(), request.ToParametersDictionary()); + return ApiConnection.GetAll(ApiUrls.StarredGists(), request.ToParametersDictionary(), options); } /// @@ -175,9 +268,25 @@ namespace Octokit /// The user public Task> GetAllForUser(string user) { - Ensure.ArgumentNotNull(user, "user"); + Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return ApiConnection.GetAll(ApiUrls.UsersGists(user)); + return GetAllForUser(user, ApiOptions.None); + } + + /// + /// List a user's gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// The user + /// Options for changing the API response + public Task> GetAllForUser(string user, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.UsersGists(user), options); } /// @@ -190,10 +299,27 @@ namespace Octokit /// Only gists updated at or after this time are returned public Task> GetAllForUser(string user, DateTimeOffset since) { - Ensure.ArgumentNotNull(user, "user"); + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + + return GetAllForUser(user, since, ApiOptions.None); + } + + /// + /// List a user's gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// The user + /// Only gists updated at or after this time are returned + /// Options for changing the API response + public Task> GetAllForUser(string user, DateTimeOffset since, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); var request = new GistRequest(since); - return ApiConnection.GetAll(ApiUrls.UsersGists(user), request.ToParametersDictionary()); + return ApiConnection.GetAll(ApiUrls.UsersGists(user), request.ToParametersDictionary(), options); } /// @@ -207,7 +333,23 @@ namespace Octokit { Ensure.ArgumentNotNullOrEmptyString(id, "id"); - return ApiConnection.GetAll(ApiUrls.GistCommits(id)); + return GetAllCommits(id, ApiOptions.None); + } + + /// + /// List gist commits + /// + /// + /// http://developer.github.com/v3/gists/#list-gists-commits + /// + /// The id of the gist + /// Options for changing the API response + public Task> GetAllCommits(string id, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(id, "id"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.GistCommits(id), options); } /// @@ -221,7 +363,23 @@ namespace Octokit { Ensure.ArgumentNotNullOrEmptyString(id, "id"); - return ApiConnection.GetAll(ApiUrls.ForkGist(id)); + return GetAllForks(id, ApiOptions.None); + } + + /// + /// List gist forks + /// + /// + /// http://developer.github.com/v3/gists/#list-gists-forks + /// + /// The id of the gist + /// Options for changing the API response + public Task> GetAllForks(string id, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(id, "id"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.ForkGist(id), options); } /// @@ -234,7 +392,7 @@ namespace Octokit /// The update to the gist public Task Edit(string id, GistUpdate gistUpdate) { - Ensure.ArgumentNotNull(id, "id"); + Ensure.ArgumentNotNullOrEmptyString(id, "id"); Ensure.ArgumentNotNull(gistUpdate, "gistUpdate"); var filesAsJsonObject = new JsonObject(); @@ -261,6 +419,8 @@ namespace Octokit /// The id of the gist public Task Star(string id) { + Ensure.ArgumentNotNullOrEmptyString(id, "id"); + return ApiConnection.Put(ApiUrls.StarGist(id)); } @@ -273,6 +433,8 @@ namespace Octokit /// The id of the gist public Task Unstar(string id) { + Ensure.ArgumentNotNullOrEmptyString(id, "id"); + return ApiConnection.Delete(ApiUrls.StarGist(id)); } @@ -289,8 +451,7 @@ namespace Octokit try { - var response = await Connection.Get(ApiUrls.StarGist(id), null, null) - .ConfigureAwait(false); + var response = await Connection.Get(ApiUrls.StarGist(id), null, null).ConfigureAwait(false); return response.HttpResponse.IsTrue(); } catch (NotFoundException) diff --git a/Octokit/Clients/IAssigneesClient.cs b/Octokit/Clients/IAssigneesClient.cs index f3bc5b79..77d04912 100644 --- a/Octokit/Clients/IAssigneesClient.cs +++ b/Octokit/Clients/IAssigneesClient.cs @@ -24,7 +24,7 @@ namespace Octokit /// /// The owner of the repository /// The name of the repository - /// The options to chagne API's response. + /// The options to change API's response. /// Task> GetAllForRepository(string owner, string name, ApiOptions options); diff --git a/Octokit/Clients/IAuthorizationsClient.cs b/Octokit/Clients/IAuthorizationsClient.cs index c78a048d..994a9494 100644 --- a/Octokit/Clients/IAuthorizationsClient.cs +++ b/Octokit/Clients/IAuthorizationsClient.cs @@ -215,7 +215,7 @@ namespace Octokit Task CheckApplicationAuthentication(string clientId, string accessToken); /// - /// Resets a valid OAuth token for an OAuth application without end user involvment. + /// Resets a valid OAuth token for an OAuth application without end user involvement. /// /// /// This method requires authentication. diff --git a/Octokit/Clients/ICommitStatusClient.cs b/Octokit/Clients/ICommitStatusClient.cs index e9743ea7..eb3c7209 100644 --- a/Octokit/Clients/ICommitStatusClient.cs +++ b/Octokit/Clients/ICommitStatusClient.cs @@ -24,6 +24,20 @@ namespace Octokit /// Task> GetAll(string owner, string name, string reference); + /// + /// Retrieves commit statuses for the specified reference. A reference can be a commit SHA, a branch name, or + /// a tag name. + /// + /// + /// https://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref + /// + /// The owner of the repository + /// The name of the repository + /// The reference (SHA, branch name, or tag name) to list commits for + /// Options for changing the API response + /// + Task> GetAll(string owner, string name, string reference, ApiOptions options); + /// /// Retrieves a combined view of statuses for the specified reference. A reference can be a commit SHA, a branch name, or /// a tag name. diff --git a/Octokit/Clients/IDeploymentsClient.cs b/Octokit/Clients/IDeploymentsClient.cs index 97a8b245..3cbcd80f 100644 --- a/Octokit/Clients/IDeploymentsClient.cs +++ b/Octokit/Clients/IDeploymentsClient.cs @@ -24,6 +24,19 @@ namespace Octokit /// All the s for the specified repository. Task> GetAll(string owner, string name); + /// + /// Gets all the deployments for the specified repository. Any user with pull access + /// to a repository can view deployments. + /// + /// + /// http://developer.github.com/v3/repos/deployments/#list-deployments + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the specified repository. + Task> GetAll(string owner, string name, ApiOptions options); + /// /// Creates a new deployment for the specified repository. /// Users with push access can create a deployment for a given ref. diff --git a/Octokit/Clients/IEventsClient.cs b/Octokit/Clients/IEventsClient.cs index ec148815..06cb5ef6 100644 --- a/Octokit/Clients/IEventsClient.cs +++ b/Octokit/Clients/IEventsClient.cs @@ -21,6 +21,16 @@ namespace Octokit [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] Task> GetAll(); + /// + /// Gets all the public events + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events + /// + /// Options for changing the API response + /// All the public s for the particular user. + Task> GetAll(ApiOptions options); + /// /// Gets all the events for a given repository /// @@ -32,6 +42,20 @@ namespace Octokit /// All the s for the particular repository. Task> GetAllForRepository(string owner, string name); + /// + /// Gets all the events for a given repository + /// + /// + /// http://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the particular repository. + Task> GetAllForRepository(string owner, string name, ApiOptions options); + + + /// /// Gets all the events for a given repository network /// @@ -43,6 +67,18 @@ namespace Octokit /// All the s for the particular repository network. Task> GetAllForRepositoryNetwork(string owner, string name); + /// + /// Gets all the events for a given repository network + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-a-network-of-repositories + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the particular repository network. + Task> GetAllForRepositoryNetwork(string owner, string name,ApiOptions options); + /// /// Gets all the events for a given organization /// @@ -53,6 +89,17 @@ namespace Octokit /// All the s for the particular organization. Task> GetAllForOrganization(string organization); + /// + /// Gets all the events for a given organization + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-an-organization + /// + /// The name of the organization + /// Options for changing the API response + /// All the s for the particular organization. + Task> GetAllForOrganization(string organization, ApiOptions options); + /// /// Gets all the events that have been received by a given user. /// @@ -63,6 +110,17 @@ namespace Octokit /// All the s that a particular user has received. Task> GetAllUserReceived(string user); + /// + /// Gets all the events that have been received by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-that-a-user-has-received + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has received. + Task> GetAllUserReceived(string user, ApiOptions options); + /// /// Gets all the events that have been received by a given user. /// @@ -73,6 +131,17 @@ namespace Octokit /// All the s that a particular user has received. Task> GetAllUserReceivedPublic(string user); + /// + /// Gets all the events that have been received by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-that-a-user-has-received + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has received. + Task> GetAllUserReceivedPublic(string user, ApiOptions options); + /// /// Gets all the events that have been performed by a given user. /// @@ -83,6 +152,17 @@ namespace Octokit /// All the s that a particular user has performed. Task> GetAllUserPerformed(string user); + /// + /// Gets all the events that have been performed by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-performed-by-a-user + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has performed. + Task> GetAllUserPerformed(string user, ApiOptions options); + /// /// Gets all the public events that have been performed by a given user. /// @@ -93,6 +173,17 @@ namespace Octokit /// All the public s that a particular user has performed. Task> GetAllUserPerformedPublic(string user); + /// + /// Gets all the public events that have been performed by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-performed-by-a-user + /// + /// The login of the user + /// Options for changing the API response + /// All the public s that a particular user has performed. + Task> GetAllUserPerformedPublic(string user, ApiOptions options); + /// /// Gets all the events that are associated with an organization. /// @@ -103,5 +194,17 @@ namespace Octokit /// The name of the organization /// All the public s that are associated with an organization. Task> GetAllForAnOrganization(string user, string organization); + + /// + /// Gets all the events that are associated with an organization. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-for-an-organization + /// + /// The login of the user + /// The name of the organization + /// Options for changing the API response + /// All the public s that are associated with an organization. + Task> GetAllForAnOrganization(string user, string organization, ApiOptions options); } } \ No newline at end of file diff --git a/Octokit/Clients/IFollowersClient.cs b/Octokit/Clients/IFollowersClient.cs index 00f7b7e0..0c7dee8a 100644 --- a/Octokit/Clients/IFollowersClient.cs +++ b/Octokit/Clients/IFollowersClient.cs @@ -22,6 +22,16 @@ namespace Octokit [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] Task> GetAllForCurrent(); + /// + /// List the authenticated user’s followers + /// + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that follow the authenticated user. + Task> GetAllForCurrent(ApiOptions options); + /// /// List a user’s followers /// @@ -32,6 +42,17 @@ namespace Octokit /// A of s that follow the passed user. Task> GetAll(string login); + /// + /// List a user’s followers + /// + /// The login name for the user + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that follow the passed user. + Task> GetAll(string login, ApiOptions options); + /// /// List who the authenticated user is following /// @@ -42,6 +63,16 @@ namespace Octokit [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] Task> GetAllFollowingForCurrent(); + /// + /// List who the authenticated user is following + /// + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that the authenticated user follows. + Task> GetAllFollowingForCurrent(ApiOptions options); + /// /// List who a user is following /// @@ -52,6 +83,17 @@ namespace Octokit /// A of s that the passed user follows. Task> GetAllFollowing(string login); + /// + /// List who a user is following + /// + /// The login name of the user + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that the passed user follows. + Task> GetAllFollowing(string login, ApiOptions options); + /// /// Check if the authenticated user follows another user /// diff --git a/Octokit/Clients/IGistCommentsClient.cs b/Octokit/Clients/IGistCommentsClient.cs index bf91680c..30867774 100644 --- a/Octokit/Clients/IGistCommentsClient.cs +++ b/Octokit/Clients/IGistCommentsClient.cs @@ -31,6 +31,15 @@ namespace Octokit /// Task{IReadOnlyList{GistComment}}. Task> GetAllForGist(string gistId); + /// + /// Gets all comments for the gist with the specified id. + /// + /// http://developer.github.com/v3/gists/comments/#list-comments-on-a-gist + /// The id of the gist + /// Options for changing the API response + /// Task{IReadOnlyList{GistComment}}. + Task> GetAllForGist(string gistId, ApiOptions options); + /// /// Creates a comment for the gist with the specified id. /// diff --git a/Octokit/Clients/IGistsClient.cs b/Octokit/Clients/IGistsClient.cs index 5ac92298..877a3ce1 100644 --- a/Octokit/Clients/IGistsClient.cs +++ b/Octokit/Clients/IGistsClient.cs @@ -35,6 +35,16 @@ namespace Octokit /// Task> GetAll(); + /// + /// List the authenticated user’s gists or if called anonymously, + /// this will return all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + Task> GetAll(ApiOptions options); + /// /// List the authenticated user’s gists or if called anonymously, /// this will return all public gists @@ -45,6 +55,17 @@ namespace Octokit /// Only gists updated at or after this time are returned Task> GetAll(DateTimeOffset since); + /// + /// List the authenticated user’s gists or if called anonymously, + /// this will return all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + Task> GetAll(DateTimeOffset since, ApiOptions options); + /// /// Lists all public gists /// @@ -53,6 +74,15 @@ namespace Octokit /// Task> GetAllPublic(); + /// + /// Lists all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + Task> GetAllPublic(ApiOptions options); + /// /// Lists all public gists /// @@ -62,6 +92,18 @@ namespace Octokit /// Only gists updated at or after this time are returned Task> GetAllPublic(DateTimeOffset since); + /// + /// Lists all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + Task> GetAllPublic(DateTimeOffset since, ApiOptions options); + + + /// /// List the authenticated user’s starred gists /// @@ -70,6 +112,15 @@ namespace Octokit /// Task> GetAllStarred(); + /// + /// List the authenticated user’s starred gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + Task> GetAllStarred(ApiOptions options); + /// /// List the authenticated user’s starred gists /// @@ -79,6 +130,16 @@ namespace Octokit /// Only gists updated at or after this time are returned Task> GetAllStarred(DateTimeOffset since); + /// + /// List the authenticated user’s starred gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + Task> GetAllStarred(DateTimeOffset since, ApiOptions options); + /// /// List a user's gists /// @@ -88,6 +149,16 @@ namespace Octokit /// The user Task> GetAllForUser(string user); + /// + /// List a user's gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// The user + /// Options for changing the API response + Task> GetAllForUser(string user, ApiOptions options); + /// /// List a user's gists /// @@ -98,6 +169,17 @@ namespace Octokit /// Only gists updated at or after this time are returned Task> GetAllForUser(string user, DateTimeOffset since); + /// + /// List a user's gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// The user + /// Only gists updated at or after this time are returned + /// Options for changing the API response + Task> GetAllForUser(string user, DateTimeOffset since, ApiOptions options); + /// /// List gist commits /// @@ -107,6 +189,16 @@ namespace Octokit /// The id of the gist Task> GetAllCommits(string id); + /// + /// List gist commits + /// + /// + /// http://developer.github.com/v3/gists/#list-gists-commits + /// + /// The id of the gist + /// Options for changing the API response + Task> GetAllCommits(string id, ApiOptions options); + /// /// List gist forks /// @@ -116,6 +208,16 @@ namespace Octokit /// The id of the gist Task> GetAllForks(string id); + /// + /// List gist forks + /// + /// + /// http://developer.github.com/v3/gists/#list-gists-forks + /// + /// The id of the gist + /// Options for changing the API response + Task> GetAllForks(string id, ApiOptions options); + /// /// Creates a new gist /// diff --git a/Octokit/Clients/IIssueCommentsClient.cs b/Octokit/Clients/IIssueCommentsClient.cs index 1e091d28..147c3b84 100644 --- a/Octokit/Clients/IIssueCommentsClient.cs +++ b/Octokit/Clients/IIssueCommentsClient.cs @@ -33,6 +33,16 @@ namespace Octokit /// Task> GetAllForRepository(string owner, string name); + /// + /// Gets Issue Comments for a repository. + /// + /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// + Task> GetAllForRepository(string owner, string name, ApiOptions options); + /// /// Gets Issue Comments for a specified Issue. /// @@ -43,6 +53,17 @@ namespace Octokit /// Task> GetAllForIssue(string owner, string name, int number); + /// + /// Gets Issue Comments for a specified Issue. + /// + /// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// Options for changing the API response + /// + Task> GetAllForIssue(string owner, string name, int number, ApiOptions options); + /// /// Creates a new Issue Comment for a specified Issue. /// diff --git a/Octokit/Clients/IIssuesClient.cs b/Octokit/Clients/IIssuesClient.cs index bc0e362c..bea894bf 100644 --- a/Octokit/Clients/IIssuesClient.cs +++ b/Octokit/Clients/IIssuesClient.cs @@ -152,10 +152,10 @@ namespace Octokit Task Create(string owner, string name, NewIssue newIssue); /// - /// Creates an issue for the specified repository. Any user with pull access to a repository can create an + /// Updates an issue for the specified repository. Any user with pull access to a repository can update an /// issue. /// - /// http://developer.github.com/v3/issues/#create-an-issue + /// http://developer.github.com/v3/issues/#edit-an-issue /// The owner of the repository /// The name of the repository /// The issue number @@ -163,5 +163,25 @@ namespace Octokit /// /// Task Update(string owner, string name, int number, IssueUpdate issueUpdate); + + /// + /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. + /// + /// https://developer.github.com/v3/issues/#lock-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// + Task Lock(string owner, string name, int number); + + /// + /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. + /// + /// https://developer.github.com/v3/issues/#unlock-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// + Task Unlock(string owner, string name, int number); } } diff --git a/Octokit/Clients/IMiscellaneousClient.cs b/Octokit/Clients/IMiscellaneousClient.cs index 6df182db..3f20fabf 100644 --- a/Octokit/Clients/IMiscellaneousClient.cs +++ b/Octokit/Clients/IMiscellaneousClient.cs @@ -62,7 +62,7 @@ namespace Octokit Task> GetAllLicenses(); /// - /// Retrieves a license based on the licence key such as "mit" + /// Retrieves a license based on the license key such as "mit" /// /// /// A that includes the license key, text, and attributes of the license. diff --git a/Octokit/Clients/IOrganizationMembersClient.cs b/Octokit/Clients/IOrganizationMembersClient.cs index 3cb99a6f..61c7144b 100644 --- a/Octokit/Clients/IOrganizationMembersClient.cs +++ b/Octokit/Clients/IOrganizationMembersClient.cs @@ -57,15 +57,6 @@ namespace Octokit /// The users Task> GetAll(string org, OrganizationMembersFilter filter); - /// - /// Obsolete, - /// - /// The login for the organization - /// The user filter - /// The users - [Obsolete("No longer supported, use GetAll(string, OrganizationMembersFilter) instead")] - Task> GetAll(string org, string filter); - /// /// /// List all users who are members of an organization. A member is a user that diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index 098e03d0..0989d99f 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -73,7 +73,7 @@ namespace Octokit /// /// See the API documentation for more information. /// - /// Login of the organization in which to create the repostiory + /// Login of the organization in which to create the repository /// A instance describing the new repository to create /// Thrown when a general API error occurs. /// A instance for the created repository @@ -351,7 +351,7 @@ namespace Octokit /// /// The owner of the repository /// The name of the repository - /// All of the repositorys tags. + /// All of the repositories tags. Task> GetAllTags(string owner, string name); /// diff --git a/Octokit/Clients/IRepositoryCommitsClient.cs b/Octokit/Clients/IRepositoryCommitsClient.cs index bd486192..33c7b877 100644 --- a/Octokit/Clients/IRepositoryCommitsClient.cs +++ b/Octokit/Clients/IRepositoryCommitsClient.cs @@ -42,6 +42,15 @@ namespace Octokit /// Task> GetAll(string owner, string name); + /// + /// Gets all commits for a given repository + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// + Task> GetAll(string owner, string name, ApiOptions options); + /// /// Gets all commits for a given repository /// @@ -51,6 +60,15 @@ namespace Octokit /// Task> GetAll(string owner, string name, CommitRequest request); + /// + /// Gets all commits for a given repository + /// + /// The owner of the repository + /// The name of the repository + /// Used to filter list of commits returned + /// Options for changing the API response + /// + Task> GetAll(string owner, string name, CommitRequest request, ApiOptions options); /// /// Get the SHA-1 of a commit reference /// diff --git a/Octokit/Clients/IRepositoryContentsClient.cs b/Octokit/Clients/IRepositoryContentsClient.cs index b072dc17..272f3c06 100644 --- a/Octokit/Clients/IRepositoryContentsClient.cs +++ b/Octokit/Clients/IRepositoryContentsClient.cs @@ -80,7 +80,7 @@ namespace Octokit Task GetReadme(string owner, string name); /// - /// Gets the perferred README's HTML for the specified repository. + /// Gets the preferred README's HTML for the specified repository. /// /// /// See the API documentation for more information. @@ -91,19 +91,6 @@ namespace Octokit /// Task GetReadmeHtml(string owner, string name); - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// - [Obsolete("Use GetArchive to download the archive instead")] - Task GetArchiveLink(string owner, string name); - /// /// Get an archive of a given repository's contents /// @@ -113,20 +100,6 @@ namespace Octokit /// The binary contents of the archive Task GetArchive(string owner, string name); - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// The format of the archive. Can be either tarball or zipball - /// - [Obsolete("Use GetArchive to download the archive instead")] - Task GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat); - /// /// Get an archive of a given repository's contents, in a specific format /// @@ -137,21 +110,6 @@ namespace Octokit /// The binary contents of the archive Task GetArchive(string owner, string name, ArchiveFormat archiveFormat); - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// The format of the archive. Can be either tarball or zipball - /// A valid Git reference. - /// - [Obsolete("Use GetArchive to download the archive instead")] - Task GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat, string reference); - /// /// Get an archive of a given repository's contents, using a specific format and reference /// diff --git a/Octokit/Clients/IRepositoryHooksClient.cs b/Octokit/Clients/IRepositoryHooksClient.cs index c282a372..571306a4 100644 --- a/Octokit/Clients/IRepositoryHooksClient.cs +++ b/Octokit/Clients/IRepositoryHooksClient.cs @@ -10,9 +10,21 @@ namespace Octokit /// Gets the list of hooks defined for a repository /// /// See API documentation for more information. + /// The repository's owner + /// The repository's name /// Task> GetAll(string owner, string repositoryName); + /// + /// Gets the list of hooks defined for a repository + /// + /// See API documentation for more information. + /// The repository's owner + /// The repository's name + /// Options for changing the API response + /// + Task> GetAll(string owner, string repositoryName, ApiOptions options); + /// /// Gets a single hook by Id /// diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs index 45342768..4249acaf 100644 --- a/Octokit/Clients/ITeamsClient.cs +++ b/Octokit/Clients/ITeamsClient.cs @@ -30,10 +30,20 @@ namespace Octokit /// /// Returns all s for the current org. /// + /// Organization for which to list all teams. /// Thrown when a general API error occurs. /// A list of the orgs's teams s. Task> GetAll(string org); + /// + /// Returns all s for the current org. + /// + /// Organization for which to list all teams. + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// A list of the orgs's teams s. + Task> GetAll(string org, ApiOptions options); + /// /// Returns all s for the current user. /// @@ -42,6 +52,15 @@ namespace Octokit [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] Task> GetAllForCurrent(); + /// + /// Returns all s for the current user. + /// + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// A list of the user's s. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + Task> GetAllForCurrent(ApiOptions options); + /// /// Returns all members of the given team. /// @@ -52,6 +71,17 @@ namespace Octokit /// A list of the team's member s. Task> GetAllMembers(int id); + /// + /// Returns all members of the given team. + /// + /// The team identifier + /// Options to change API behaviour. + /// + /// https://developer.github.com/v3/orgs/teams/#list-team-members + /// + /// A list of the team's member s. + Task> GetAllMembers(int id, ApiOptions options); + /// /// Returns newly created for the current org. /// @@ -96,16 +126,6 @@ namespace Octokit /// if the user was removed from the team; otherwise. Task RemoveMembership(int id, string login); - /// - /// Gets whether the user with the given - /// is a member of the team with the given . - /// - /// The team to check. - /// The user to check. - /// if the user is a member of the team; otherwise. - [Obsolete("Use GetMembership(id, login) as this will report on pending requests")] - Task IsMember(int id, string login); - /// /// Gets whether the user with the given /// is a member of the team with the given . @@ -118,10 +138,20 @@ namespace Octokit /// /// Returns all team's repositories. /// + /// Team Id to list repos. /// Thrown when a general API error occurs. /// The team's repositories Task> GetAllRepositories(int id); + /// + /// Returns all team's repositories. + /// + /// Team Id to list repos. + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// The team's repositories + Task> GetAllRepositories(int id, ApiOptions options); + /// /// Add a repository to the team /// diff --git a/Octokit/Clients/IssueCommentsClient.cs b/Octokit/Clients/IssueCommentsClient.cs index 05b00e12..54748f77 100644 --- a/Octokit/Clients/IssueCommentsClient.cs +++ b/Octokit/Clients/IssueCommentsClient.cs @@ -47,7 +47,24 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return ApiConnection.GetAll(ApiUrls.IssueComments(owner, name)); + return GetAllForRepository(owner, name, ApiOptions.None); + } + + /// + /// Gets Issue Comments for a repository. + /// + /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// + public Task> GetAllForRepository(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.IssueComments(owner, name), options); } /// @@ -63,7 +80,24 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return ApiConnection.GetAll(ApiUrls.IssueComments(owner, name, number)); + return GetAllForIssue(owner, name, number, ApiOptions.None); + } + /// + /// Gets Issue Comments for a specified Issue. + /// + /// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// Options for changing the API response + /// + public Task> GetAllForIssue(string owner, string name, int number, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.IssueComments(owner, name, number), options); } /// diff --git a/Octokit/Clients/IssuesClient.cs b/Octokit/Clients/IssuesClient.cs index 8b924245..4757c014 100644 --- a/Octokit/Clients/IssuesClient.cs +++ b/Octokit/Clients/IssuesClient.cs @@ -225,5 +225,37 @@ namespace Octokit return ApiConnection.Patch(ApiUrls.Issue(owner, name, number), issueUpdate); } + + /// + /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. + /// + /// https://developer.github.com/v3/issues/#lock-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// + public Task Lock(string owner, string name, int number) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return ApiConnection.Put(ApiUrls.IssueLock(owner, name, number), new object(), null, AcceptHeaders.IssueLockingUnlockingApiPreview); + } + + /// + /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. + /// + /// https://developer.github.com/v3/issues/#unlock-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// + public Task Unlock(string owner, string name, int number) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return ApiConnection.Delete(ApiUrls.IssueLock(owner, name, number), new object(), AcceptHeaders.IssueLockingUnlockingApiPreview); + } } } diff --git a/Octokit/Clients/MiscellaneousClient.cs b/Octokit/Clients/MiscellaneousClient.cs index 7079fada..cf6242b9 100644 --- a/Octokit/Clients/MiscellaneousClient.cs +++ b/Octokit/Clients/MiscellaneousClient.cs @@ -38,8 +38,7 @@ namespace Octokit public async Task> GetAllEmojis() { var endpoint = new Uri("emojis", UriKind.Relative); - var response = await _connection.Get>(endpoint, null, null) - .ConfigureAwait(false); + var response = await _connection.Get>(endpoint, null, null).ConfigureAwait(false); return new ReadOnlyCollection( response.Body.Select(kvp => new Emoji(kvp.Key, new Uri(kvp.Value))).ToArray()); } @@ -53,8 +52,7 @@ namespace Octokit public async Task RenderRawMarkdown(string markdown) { var endpoint = new Uri("markdown/raw", UriKind.Relative); - var response = await _connection.Post(endpoint, markdown, "text/html", "text/plain") - .ConfigureAwait(false); + var response = await _connection.Post(endpoint, markdown, "text/html", "text/plain").ConfigureAwait(false); return response.Body; } @@ -67,8 +65,7 @@ namespace Octokit public async Task RenderArbitraryMarkdown(NewArbitraryMarkdown markdown) { var endpoint = new Uri("markdown", UriKind.Relative); - var response = await _connection.Post(endpoint, markdown, "text/html", "text/plain") - .ConfigureAwait(false); + var response = await _connection.Post(endpoint, markdown, "text/html", "text/plain").ConfigureAwait(false); return response.Body; } @@ -80,8 +77,7 @@ namespace Octokit { var endpoint = new Uri("gitignore/templates", UriKind.Relative); - var response = await _connection.Get(endpoint, null, null) - .ConfigureAwait(false); + var response = await _connection.Get(endpoint, null, null).ConfigureAwait(false); return new ReadOnlyCollection(response.Body); } @@ -96,8 +92,7 @@ namespace Octokit var endpoint = new Uri("gitignore/templates/" + Uri.EscapeUriString(templateName), UriKind.Relative); - var response = await _connection.Get(endpoint, null, null) - .ConfigureAwait(false); + var response = await _connection.Get(endpoint, null, null).ConfigureAwait(false); return response.Body; } @@ -111,13 +106,12 @@ namespace Octokit { var endpoint = new Uri("licenses", UriKind.Relative); - var response = await _connection.Get(endpoint, null, AcceptHeaders.LicensesApiPreview) - .ConfigureAwait(false); + var response = await _connection.Get(endpoint, null, AcceptHeaders.LicensesApiPreview).ConfigureAwait(false); return new ReadOnlyCollection(response.Body); } /// - /// Retrieves a license based on the licence key such as "mit" + /// Retrieves a license based on the license key such as "mit" /// /// /// A that includes the license key, text, and attributes of the license. @@ -125,8 +119,7 @@ namespace Octokit { var endpoint = new Uri("licenses/" + Uri.EscapeUriString(key), UriKind.Relative); - var response = await _connection.Get(endpoint, null, AcceptHeaders.LicensesApiPreview) - .ConfigureAwait(false); + var response = await _connection.Get(endpoint, null, AcceptHeaders.LicensesApiPreview).ConfigureAwait(false); return response.Body; } diff --git a/Octokit/Clients/OAuthClient.cs b/Octokit/Clients/OAuthClient.cs index d283b5a4..e6e17fb8 100644 --- a/Octokit/Clients/OAuthClient.cs +++ b/Octokit/Clients/OAuthClient.cs @@ -62,7 +62,7 @@ namespace Octokit var body = new FormUrlEncodedContent(request.ToParametersDictionary()); - var response = await connection.Post(endPoint, body, "application/json", null, hostAddress); + var response = await connection.Post(endPoint, body, "application/json", null, hostAddress).ConfigureAwait(false); return response.Body; } } diff --git a/Octokit/Clients/OrganizationMembersClient.cs b/Octokit/Clients/OrganizationMembersClient.cs index 02eb939a..ed6cadc5 100644 --- a/Octokit/Clients/OrganizationMembersClient.cs +++ b/Octokit/Clients/OrganizationMembersClient.cs @@ -109,21 +109,6 @@ namespace Octokit return ApiConnection.GetAll(ApiUrls.Members(org, filter)); } - /// - /// Obsolete, - /// - /// The login for the organization - /// The user filter - /// The users - [Obsolete("No longer supported, use GetAll(string, OrganizationMembersFilter) instead")] - public Task> GetAll(string org, string filter) - { - Ensure.ArgumentNotNullOrEmptyString(org, "org"); - Ensure.ArgumentNotNullOrEmptyString(filter, "filter"); - - return ApiConnection.GetAll(ApiUrls.Members(org, filter)); - } - /// /// /// List all users who are members of an organization. A member is a user that @@ -211,8 +196,7 @@ namespace Octokit try { - var response = await Connection.Get(ApiUrls.CheckMember(org, user), null, null) - .ConfigureAwait(false); + var response = await Connection.Get(ApiUrls.CheckMember(org, user), null, null).ConfigureAwait(false); var statusCode = response.HttpResponse.StatusCode; if (statusCode != HttpStatusCode.NotFound && statusCode != HttpStatusCode.NoContent @@ -245,8 +229,7 @@ namespace Octokit try { - var response = await Connection.Get(ApiUrls.CheckMemberPublic(org, user), null, null) - .ConfigureAwait(false); + var response = await Connection.Get(ApiUrls.CheckMemberPublic(org, user), null, null).ConfigureAwait(false); return response.HttpResponse.IsTrue(); } catch (NotFoundException) @@ -294,8 +277,7 @@ namespace Octokit try { var requestData = new { }; - var response = await Connection.Put(ApiUrls.OrganizationMembership(org, user), requestData) - .ConfigureAwait(false); + var response = await Connection.Put(ApiUrls.OrganizationMembership(org, user), requestData).ConfigureAwait(false); if (response.HttpResponse.StatusCode != HttpStatusCode.NoContent) { throw new ApiException("Invalid Status Code returned. Expected a 204", response.HttpResponse.StatusCode); diff --git a/Octokit/Clients/PullRequestReviewCommentsClient.cs b/Octokit/Clients/PullRequestReviewCommentsClient.cs index 5d8363b2..8db0925b 100644 --- a/Octokit/Clients/PullRequestReviewCommentsClient.cs +++ b/Octokit/Clients/PullRequestReviewCommentsClient.cs @@ -93,7 +93,8 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(comment, "comment"); - var response = await ApiConnection.Connection.Post(ApiUrls.PullRequestReviewComments(owner, name, number), comment, null, null).ConfigureAwait(false); + var endpoint = ApiUrls.PullRequestReviewComments(owner, name, number); + var response = await ApiConnection.Connection.Post(endpoint, comment, null, null).ConfigureAwait(false); if (response.HttpResponse.StatusCode != HttpStatusCode.Created) { @@ -118,7 +119,8 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(comment, "comment"); - var response = await ApiConnection.Connection.Post(ApiUrls.PullRequestReviewComments(owner, name, number), comment, null, null).ConfigureAwait(false); + var endpoint = ApiUrls.PullRequestReviewComments(owner, name, number); + var response = await ApiConnection.Connection.Post(endpoint, comment, null, null).ConfigureAwait(false); if (response.HttpResponse.StatusCode != HttpStatusCode.Created) { diff --git a/Octokit/Clients/PullRequestsClient.cs b/Octokit/Clients/PullRequestsClient.cs index 85ffe16f..c8c33478 100644 --- a/Octokit/Clients/PullRequestsClient.cs +++ b/Octokit/Clients/PullRequestsClient.cs @@ -118,7 +118,8 @@ namespace Octokit try { - return await ApiConnection.Put(ApiUrls.MergePullRequest(owner, name, number), mergePullRequest); + var endpoint = ApiUrls.MergePullRequest(owner, name, number); + return await ApiConnection.Put(endpoint, mergePullRequest).ConfigureAwait(false); } catch (ApiException ex) { @@ -151,8 +152,8 @@ namespace Octokit try { - var response = await Connection.Get(ApiUrls.MergePullRequest(owner, name, number), null, null) - .ConfigureAwait(false); + var endpoint = ApiUrls.MergePullRequest(owner, name, number); + var response = await Connection.Get(endpoint, null, null).ConfigureAwait(false); return response.HttpResponse.IsTrue(); } catch (NotFoundException) diff --git a/Octokit/Clients/RepoCollaboratorsClient.cs b/Octokit/Clients/RepoCollaboratorsClient.cs index af46fc91..db0d41d0 100644 --- a/Octokit/Clients/RepoCollaboratorsClient.cs +++ b/Octokit/Clients/RepoCollaboratorsClient.cs @@ -57,8 +57,7 @@ namespace Octokit try { - var response = await Connection.Get(endpoint, null, null) - .ConfigureAwait(false); + var response = await Connection.Get(endpoint, null, null).ConfigureAwait(false); return response.HttpResponse.IsTrue(); } catch (NotFoundException) diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index c6b5a1cf..dfb3806e 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -69,7 +69,7 @@ namespace Octokit /// /// See the API documentation for more information. /// - /// Login of the organization in which to create the repostiory + /// Login of the organization in which to create the repository /// A instance describing the new repository to create /// Thrown when a general API error occurs. /// A instance for the created repository @@ -87,7 +87,7 @@ namespace Octokit { try { - return await ApiConnection.Post(url, newRepository); + return await ApiConnection.Post(url, newRepository).ConfigureAwait(false); } catch (ApiValidationException e) { @@ -518,9 +518,8 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - var data = await ApiConnection - .Get>(ApiUrls.RepositoryLanguages(owner, name)) - .ConfigureAwait(false); + var endpoint = ApiUrls.RepositoryLanguages(owner, name); + var data = await ApiConnection.Get>(endpoint).ConfigureAwait(false); return new ReadOnlyCollection( data.Select(kvp => new RepositoryLanguage(kvp.Key, kvp.Value)).ToList()); @@ -551,7 +550,7 @@ namespace Octokit /// /// The owner of the repository /// The name of the repository - /// All of the repositorys tags. + /// All of the repositories tags. public Task> GetAllTags(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); diff --git a/Octokit/Clients/RepositoryCommitsClient.cs b/Octokit/Clients/RepositoryCommitsClient.cs index e5fa9613..ccbaa6d4 100644 --- a/Octokit/Clients/RepositoryCommitsClient.cs +++ b/Octokit/Clients/RepositoryCommitsClient.cs @@ -9,11 +9,12 @@ namespace Octokit /// /// See the Repository Commits API documentation for more information. /// - public class RepositoryCommitsClient : IRepositoryCommitsClient + public class RepositoryCommitsClient : ApiClient, IRepositoryCommitsClient { readonly IApiConnection _apiConnection; - public RepositoryCommitsClient(IApiConnection apiConnection) + public RepositoryCommitsClient(IApiConnection apiConnection) + : base(apiConnection) { _apiConnection = apiConnection; } @@ -60,9 +61,27 @@ namespace Octokit /// public Task> GetAll(string owner, string name) { - return GetAll(owner, name, new CommitRequest()); + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return GetAll(owner, name, new CommitRequest(), ApiOptions.None); } + /// + /// Gets all commits for a given repository + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// + public Task> GetAll(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return GetAll(owner, name, new CommitRequest(), options); + } + /// /// Gets all commits for a given repository /// @@ -76,8 +95,24 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(request, "request"); - return _apiConnection.GetAll(ApiUrls.RepositoryCommits(owner, name), - request.ToParametersDictionary()); + return GetAll(owner, name, request, ApiOptions.None); + } + + /// + /// Gets all commits for a given repository + /// + /// The owner of the repository + /// The name of the repository + /// Used to filter list of commits returned + /// Options for changing the API response + /// + public Task> GetAll(string owner, string name, CommitRequest request, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(request, "request"); + + return _apiConnection.GetAll(ApiUrls.RepositoryCommits(owner, name), request.ToParametersDictionary(), options); } /// diff --git a/Octokit/Clients/RepositoryContentsClient.cs b/Octokit/Clients/RepositoryContentsClient.cs index f181b70b..16c47e35 100644 --- a/Octokit/Clients/RepositoryContentsClient.cs +++ b/Octokit/Clients/RepositoryContentsClient.cs @@ -131,7 +131,7 @@ namespace Octokit } /// - /// Gets the perferred README's HTML for the specified repository. + /// Gets the preferred README's HTML for the specified repository. /// /// /// See the API documentation for more information. @@ -148,22 +148,6 @@ namespace Octokit return ApiConnection.GetHtml(ApiUrls.RepositoryReadme(owner, name), null); } - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// - [Obsolete("Octokit's HTTP library now follows redirects by default - this API will be removed in a future release")] - public Task GetArchiveLink(string owner, string name) - { - return GetArchiveLink(owner, name, ArchiveFormat.Tarball, string.Empty); - } - /// /// Get an archive of a given repository's contents /// @@ -176,23 +160,6 @@ namespace Octokit return GetArchive(owner, name, ArchiveFormat.Tarball, string.Empty); } - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// The format of the archive. Can be either tarball or zipball - /// - [Obsolete("Octokit's HTTP library now follows redirects by default - this API will be removed in a future release")] - public Task GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat) - { - return GetArchiveLink(owner, name, archiveFormat, string.Empty); - } - /// /// Get an archive of a given repository's contents, in a specific format /// @@ -206,27 +173,6 @@ namespace Octokit return GetArchive(owner, name, archiveFormat, string.Empty); } - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// The format of the archive. Can be either tarball or zipball - /// A valid Git reference. - /// - [Obsolete("Octokit's HTTP library now follows redirects by default - this API will be removed in a future release")] - public Task GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat, string reference) - { - Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - - return ApiConnection.GetRedirect(ApiUrls.RepositoryArchiveLink(owner, name, archiveFormat, reference)); - } - /// /// Get an archive of a given repository's contents, using a specific format and reference /// @@ -259,7 +205,7 @@ namespace Octokit var endpoint = ApiUrls.RepositoryArchiveLink(owner, name, archiveFormat, reference); - var response = await Connection.Get(endpoint, timeout); + var response = await Connection.Get(endpoint, timeout).ConfigureAwait(false); return response.Body; } diff --git a/Octokit/Clients/RepositoryHooksClient.cs b/Octokit/Clients/RepositoryHooksClient.cs index 458a1596..f2e6e9df 100644 --- a/Octokit/Clients/RepositoryHooksClient.cs +++ b/Octokit/Clients/RepositoryHooksClient.cs @@ -18,13 +18,32 @@ namespace Octokit /// Gets the list of hooks defined for a repository /// /// See API documentation for more information. + /// The repository's owner + /// The repository's name /// public Task> GetAll(string owner, string repositoryName) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - return ApiConnection.GetAll(ApiUrls.RepositoryHooks(owner, repositoryName)); + return GetAll(owner, repositoryName, ApiOptions.None); + } + + /// + /// Gets the list of hooks defined for a repository + /// + /// See API documentation for more information. + /// The repository's owner + /// The repository's name + /// Options for changing the API response + /// + public Task> GetAll(string owner, string repositoryName, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.RepositoryHooks(owner, repositoryName), options); } /// diff --git a/Octokit/Clients/StarredClient.cs b/Octokit/Clients/StarredClient.cs index 1ed20dcd..132ca2dc 100644 --- a/Octokit/Clients/StarredClient.cs +++ b/Octokit/Clients/StarredClient.cs @@ -189,9 +189,7 @@ namespace Octokit try { - var response = await Connection.Get(ApiUrls.Starred(owner, name), null, null) - .ConfigureAwait(false); - + var response = await Connection.Get(ApiUrls.Starred(owner, name), null, null).ConfigureAwait(false); return response.HttpResponse.StatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -213,9 +211,7 @@ namespace Octokit try { - var response = await Connection.Put(ApiUrls.Starred(owner, name), null, null) - .ConfigureAwait(false); - + var response = await Connection.Put(ApiUrls.Starred(owner, name), null, null).ConfigureAwait(false); return response.HttpResponse.StatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -237,9 +233,7 @@ namespace Octokit try { - var statusCode = await Connection.Delete(ApiUrls.Starred(owner, name)) - .ConfigureAwait(false); - + var statusCode = await Connection.Delete(ApiUrls.Starred(owner, name)).ConfigureAwait(false); return statusCode == HttpStatusCode.NoContent; } catch (NotFoundException) diff --git a/Octokit/Clients/StatisticsClient.cs b/Octokit/Clients/StatisticsClient.cs index f63a94ec..d55207d2 100644 --- a/Octokit/Clients/StatisticsClient.cs +++ b/Octokit/Clients/StatisticsClient.cs @@ -39,13 +39,13 @@ namespace Octokit /// The name of the repository /// A token used to cancel this potentially long running request /// A list of - public async Task> GetContributors(string owner, string repositoryName, CancellationToken cancellationToken) + public Task> GetContributors(string owner, string repositoryName, CancellationToken cancellationToken) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); var endpoint = "repos/{0}/{1}/stats/contributors".FormatUri(owner, repositoryName); - return await ApiConnection.GetQueuedOperation(endpoint, cancellationToken); + return ApiConnection.GetQueuedOperation(endpoint, cancellationToken); } /// @@ -72,7 +72,7 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); var endpoint = "repos/{0}/{1}/stats/commit_activity".FormatUri(owner, repositoryName); - var activity = await ApiConnection.GetQueuedOperation(endpoint, cancellationToken); + var activity = await ApiConnection.GetQueuedOperation(endpoint, cancellationToken).ConfigureAwait(false); return new CommitActivity(activity); } @@ -100,7 +100,7 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); var endpoint = "repos/{0}/{1}/stats/code_frequency".FormatUri(owner, repositoryName); - var rawFrequencies = await ApiConnection.GetQueuedOperation(endpoint, cancellationToken); + var rawFrequencies = await ApiConnection.GetQueuedOperation(endpoint, cancellationToken).ConfigureAwait(false); return new CodeFrequency(rawFrequencies); } @@ -128,7 +128,7 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); var endpoint = "repos/{0}/{1}/stats/participation".FormatUri(owner, repositoryName); - var result = await ApiConnection.GetQueuedOperation(endpoint, cancellationToken); + var result = await ApiConnection.GetQueuedOperation(endpoint, cancellationToken).ConfigureAwait(false); return result.FirstOrDefault(); } @@ -156,7 +156,7 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); var endpoint = "repos/{0}/{1}/stats/punch_card".FormatUri(owner, repositoryName); - var punchCardData = await ApiConnection.GetQueuedOperation(endpoint, cancellationToken); + var punchCardData = await ApiConnection.GetQueuedOperation(endpoint, cancellationToken).ConfigureAwait(false); return new PunchCard(punchCardData); } } diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index 4cdf2d27..3ec477ac 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -42,14 +42,28 @@ namespace Octokit /// /// Returns all s for the current org. /// + /// Organization to list teams of. /// Thrown when a general API error occurs. /// A list of the orgs's teams s. public Task> GetAll(string org) + { + return GetAll(org, ApiOptions.None); + } + + /// + /// Returns all s for the current org. + /// + /// Organization to list teams of. + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// A list of the orgs's teams s. + public Task> GetAll(string org, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); + Ensure.ArgumentNotNull(options, "options"); var endpoint = ApiUrls.OrganizationTeams(org); - return ApiConnection.GetAll(endpoint); + return ApiConnection.GetAll(endpoint, options); } /// @@ -59,8 +73,22 @@ namespace Octokit /// A list of the user's s. public Task> GetAllForCurrent() { + return GetAllForCurrent(ApiOptions.None); + } + + /// + /// Returns all s for the current user. + /// + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// A list of the user's s. + public Task> GetAllForCurrent(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + var endpoint = ApiUrls.UserTeams(); - return ApiConnection.GetAll(endpoint); + + return ApiConnection.GetAll(endpoint, options); } /// @@ -73,9 +101,25 @@ namespace Octokit /// A list of the team's member s. public Task> GetAllMembers(int id) { + return GetAllMembers(id, ApiOptions.None); + } + + /// + /// Returns all members of the given team. + /// + /// + /// https://developer.github.com/v3/orgs/teams/#list-team-members + /// + /// The team identifier + /// Options to change API behaviour. + /// A list of the team's member s. + public Task> GetAllMembers(int id, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + var endpoint = ApiUrls.TeamMembers(id); - return ApiConnection.GetAll(endpoint); + return ApiConnection.GetAll(endpoint, options); } /// @@ -93,7 +137,7 @@ namespace Octokit try { - response = await ApiConnection.Get>(endpoint); + response = await ApiConnection.Get>(endpoint).ConfigureAwait(false); } catch (NotFoundException) { @@ -164,7 +208,7 @@ namespace Octokit try { - response = await ApiConnection.Put>(endpoint, RequestBody.Empty); + response = await ApiConnection.Put>(endpoint, RequestBody.Empty).ConfigureAwait(false); } catch (NotFoundException) { @@ -198,7 +242,7 @@ namespace Octokit try { - var httpStatusCode = await ApiConnection.Connection.Delete(endpoint); + var httpStatusCode = await ApiConnection.Connection.Delete(endpoint).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } @@ -209,40 +253,30 @@ namespace Octokit } /// - /// Gets whether the user with the given - /// is a member of the team with the given . + /// Returns all team's repositories. /// - /// The team to check. - /// The user to check. - /// if the user is a member of the team; otherwise. - [Obsolete("Use GetMembership(id, login) as this will report on pending requests")] - public async Task IsMember(int id, string login) + /// Team Id. + /// Thrown when a general API error occurs. + /// The team's repositories + public Task> GetAllRepositories(int id) { - Ensure.ArgumentNotNullOrEmptyString(login, "login"); - - var endpoint = ApiUrls.TeamMember(id, login); - - try - { - var response = await ApiConnection.Connection.GetResponse(endpoint); - return response.HttpResponse.StatusCode == HttpStatusCode.NoContent; - } - catch (NotFoundException) - { - return false; - } + return GetAllRepositories(id, ApiOptions.None); } /// /// Returns all team's repositories. /// + /// Team Id. + /// Options to change API behaviour. /// Thrown when a general API error occurs. /// The team's repositories - public Task> GetAllRepositories(int id) + public Task> GetAllRepositories(int id, ApiOptions options) { + Ensure.ArgumentNotNull(options, "options"); + var endpoint = ApiUrls.TeamRepositories(id); - return ApiConnection.GetAll(endpoint); + return ApiConnection.GetAll(endpoint, options); } /// @@ -274,7 +308,7 @@ namespace Octokit try { - var httpStatusCode = await ApiConnection.Connection.Put(endpoint); + var httpStatusCode = await ApiConnection.Connection.Put(endpoint).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -297,7 +331,7 @@ namespace Octokit try { - var httpStatusCode = await ApiConnection.Connection.Delete(endpoint); + var httpStatusCode = await ApiConnection.Connection.Delete(endpoint).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } @@ -326,7 +360,7 @@ namespace Octokit try { - var response = await ApiConnection.Connection.GetResponse(endpoint); + var response = await ApiConnection.Connection.GetResponse(endpoint).ConfigureAwait(false); return response.HttpResponse.StatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) diff --git a/Octokit/Clients/UserAdministrationClient.cs b/Octokit/Clients/UserAdministrationClient.cs index 1b7a15e6..cd7c14cb 100644 --- a/Octokit/Clients/UserAdministrationClient.cs +++ b/Octokit/Clients/UserAdministrationClient.cs @@ -95,13 +95,11 @@ namespace Octokit var endpoint = ApiUrls.UserAdministrationAuthorization(login); - var response = ((HttpStatusCode)await Connection.Delete(endpoint)); + var response = await Connection.Delete(endpoint).ConfigureAwait(false); if (response != HttpStatusCode.NoContent) { throw new ApiException("Invalid Status Code returned. Expected a 204", response); } - - return; } /// @@ -196,13 +194,11 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(login, "login"); var endpoint = ApiUrls.UserAdministration(login); - var response = ((HttpStatusCode)await Connection.Delete(endpoint)); + var response = await Connection.Delete(endpoint).ConfigureAwait(false); if (response != HttpStatusCode.NoContent) { throw new ApiException("Invalid Status Code returned. Expected a 204", response); } - - return; } /// @@ -219,13 +215,11 @@ namespace Octokit Ensure.ArgumentNotNull(keyId, "keyId"); var endpoint = ApiUrls.UserAdministrationPublicKeys(keyId); - var response = ((HttpStatusCode)await Connection.Delete(endpoint)); + var response = await Connection.Delete(endpoint).ConfigureAwait(false); if (response != HttpStatusCode.NoContent) { throw new ApiException("Invalid Status Code returned. Expected a 204", response); } - - return; } } } diff --git a/Octokit/Clients/WatchedClient.cs b/Octokit/Clients/WatchedClient.cs index fbc23c97..e406696a 100644 --- a/Octokit/Clients/WatchedClient.cs +++ b/Octokit/Clients/WatchedClient.cs @@ -77,8 +77,8 @@ namespace Octokit try { - var subscription = await ApiConnection.Get(ApiUrls.Watched(owner, name)) - .ConfigureAwait(false); + var endpoint = ApiUrls.Watched(owner, name); + var subscription = await ApiConnection.Get(endpoint).ConfigureAwait(false); return subscription != null; } @@ -117,8 +117,8 @@ namespace Octokit try { - var statusCode = await Connection.Delete(ApiUrls.Watched(owner, name)) - .ConfigureAwait(false); + var endpoint = ApiUrls.Watched(owner, name); + var statusCode = await Connection.Delete(endpoint).ConfigureAwait(false); return statusCode == HttpStatusCode.NoContent; } diff --git a/Octokit/Exceptions/ApiException.cs b/Octokit/Exceptions/ApiException.cs index 9f4aff05..adee41be 100644 --- a/Octokit/Exceptions/ApiException.cs +++ b/Octokit/Exceptions/ApiException.cs @@ -154,8 +154,8 @@ namespace Octokit : base(info, context) { if (info == null) return; - StatusCode = (HttpStatusCode)(info.GetInt32("HttpStatusCode")); - ApiError = (ApiError)(info.GetValue("ApiError", typeof(ApiError))); + StatusCode = (HttpStatusCode) info.GetInt32("HttpStatusCode"); + ApiError = (ApiError) info.GetValue("ApiError", typeof(ApiError)); } public override void GetObjectData(SerializationInfo info, StreamingContext context) diff --git a/Octokit/Exceptions/LegalRestrictionException.cs b/Octokit/Exceptions/LegalRestrictionException.cs new file mode 100644 index 00000000..df115d4d --- /dev/null +++ b/Octokit/Exceptions/LegalRestrictionException.cs @@ -0,0 +1,73 @@ +using System; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Runtime.Serialization; + +namespace Octokit +{ + /// + /// Represents a HTTP 451 - Unavailable For Legal Reasons response returned from the API. + /// This will returned if GitHub has been asked to takedown the requested resource due to + /// a DMCA takedown. + /// +#if !NETFX_CORE + [Serializable] +#endif + [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", + Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] + public class LegalRestrictionException : ApiException + { + public override string Message + { + get { return ApiErrorMessageSafe ?? "Resource taken down due to a DMCA notice."; } + } + + /// + /// Constructs an instance of LegalRestrictionException + /// + /// The HTTP payload from the server + public LegalRestrictionException(IResponse response) : this(response, null) + { + } + + /// + /// Constructs an instance of LegalRestrictionException + /// + /// The exception message + /// The http status code returned by the response + public LegalRestrictionException(string message, HttpStatusCode statusCode) : base(message, statusCode) + { + } + + /// + /// Constructs an instance of LegalRestrictionException + /// + /// The HTTP payload from the server + /// The inner exception + public LegalRestrictionException(IResponse response, Exception innerException) + : base(response, innerException) + { + Debug.Assert(response != null && response.StatusCode == (HttpStatusCode)451, + "LegalRestrictionException created with wrong status code"); + } + +#if !NETFX_CORE + /// + /// Constructs an instance of LegalRestrictionException + /// + /// + /// The that holds the + /// serialized object data about the exception being thrown. + /// + /// + /// The that contains + /// contextual information about the source or destination. + /// + protected LegalRestrictionException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } +#endif + } +} diff --git a/Octokit/Exceptions/RepositoryExistsException.cs b/Octokit/Exceptions/RepositoryExistsException.cs index d637d87a..c772926a 100644 --- a/Octokit/Exceptions/RepositoryExistsException.cs +++ b/Octokit/Exceptions/RepositoryExistsException.cs @@ -114,7 +114,7 @@ namespace Octokit RepositoryName = info.GetString("RepositoryName"); Organization = info.GetString("Organization"); OwnerIsOrganization = info.GetBoolean("OwnerIsOrganization"); - ExistingRepositoryWebUrl = (Uri)(info.GetValue("ExistingRepositoryWebUrl", typeof(Uri))); + ExistingRepositoryWebUrl = (Uri) info.GetValue("ExistingRepositoryWebUrl", typeof(Uri)); } public override void GetObjectData(SerializationInfo info, StreamingContext context) diff --git a/Octokit/Exceptions/TwoFactorAuthorizationException.cs b/Octokit/Exceptions/TwoFactorAuthorizationException.cs index 4279c801..db6d1a6f 100644 --- a/Octokit/Exceptions/TwoFactorAuthorizationException.cs +++ b/Octokit/Exceptions/TwoFactorAuthorizationException.cs @@ -77,7 +77,7 @@ namespace Octokit : base(info, context) { if (info == null) return; - TwoFactorType = (TwoFactorType)(info.GetInt32("TwoFactorType")); + TwoFactorType = (TwoFactorType) info.GetInt32("TwoFactorType"); } public override void GetObjectData(SerializationInfo info, StreamingContext context) diff --git a/Octokit/Helpers/AcceptHeaders.cs b/Octokit/Helpers/AcceptHeaders.cs index 21c0047e..bf3423b3 100644 --- a/Octokit/Helpers/AcceptHeaders.cs +++ b/Octokit/Helpers/AcceptHeaders.cs @@ -14,6 +14,8 @@ public const string StarCreationTimestamps = "application/vnd.github.v3.star+json"; + public const string IssueLockingUnlockingApiPreview = "application/vnd.github.the-key-preview+json"; + public const string CommitReferenceSha1Preview = "application/vnd.github.chitauri-preview+sha"; } } diff --git a/Octokit/Helpers/ApiExtensions.cs b/Octokit/Helpers/ApiExtensions.cs index 81b1ab8e..b0afbd42 100644 --- a/Octokit/Helpers/ApiExtensions.cs +++ b/Octokit/Helpers/ApiExtensions.cs @@ -80,7 +80,7 @@ namespace Octokit Ensure.ArgumentNotNull(connection, "connection"); Ensure.ArgumentNotNull(uri, "uri"); - return connection.Get(uri, null, null, false); + return connection.Get(uri, null, null); } /// diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index b59cb950..9ee3213c 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -17,7 +17,7 @@ namespace Octokit static readonly Uri _currentUserAllIssues = new Uri("issues", UriKind.Relative); static readonly Uri _currentUserOwnedAndMemberIssues = new Uri("user/issues", UriKind.Relative); static readonly Uri _oauthAuthorize = new Uri("login/oauth/authorize", UriKind.Relative); - static readonly Uri _oauthAccesToken = new Uri("login/oauth/access_token", UriKind.Relative); + static readonly Uri _oauthAccessToken = new Uri("login/oauth/access_token", UriKind.Relative); /// /// Returns the that returns all public repositories in @@ -294,6 +294,18 @@ namespace Octokit return "repos/{0}/{1}/issues/{2}".FormatUri(owner, name, number); } + /// + /// Returns the for the specified issue to be locked/unlocked. + /// + /// The owner of the repository + /// The name of the repository + /// The issue number + /// + public static Uri IssueLock(string owner, string name, int number) + { + return "repos/{0}/{1}/issues/{2}/lock".FormatUri(owner, name, number); + } + /// /// Returns the for the comments for all issues in a specific repo. /// @@ -409,18 +421,6 @@ namespace Octokit return "orgs/{0}/members?filter={1}".FormatUri(org, filter.ToParameter()); } - /// - /// - /// - /// The organization - /// The member filter - /// The correct uri - [Obsolete("No longer supported, use Members(string, OrganizationMembersFilter)")] - public static Uri Members(string org, string filter) - { - return "orgs/{0}/members?filter={1}".FormatUri(org, filter); - } - /// /// Returns the that returns all of the members of the organization /// @@ -1135,7 +1135,7 @@ namespace Octokit } /// - /// Returns the for a specifc blob. + /// Returns the for a specific blob. /// /// The owner of the blob /// The name of the organization @@ -1146,7 +1146,7 @@ namespace Octokit } /// - /// Returns the for a specifc blob. + /// Returns the for a specific blob. /// /// The owner of the blob /// The name of the organization @@ -1560,7 +1560,7 @@ namespace Octokit /// public static Uri OauthAccessToken() { - return _oauthAccesToken; + return _oauthAccessToken; } /// diff --git a/Octokit/Helpers/AuthorizationExtensions.cs b/Octokit/Helpers/AuthorizationExtensions.cs index 0d115ab9..1a490e8f 100644 --- a/Octokit/Helpers/AuthorizationExtensions.cs +++ b/Octokit/Helpers/AuthorizationExtensions.cs @@ -41,8 +41,7 @@ namespace Octokit TwoFactorRequiredException twoFactorException = null; try { - return await authorizationsClient.GetOrCreateApplicationAuthentication(clientId, clientSecret, newAuthorization) - .ConfigureAwait(false); + return await authorizationsClient.GetOrCreateApplicationAuthentication(clientId, clientSecret, newAuthorization).ConfigureAwait(false); } catch (TwoFactorRequiredException exception) { diff --git a/Octokit/Helpers/ModelExtensions.cs b/Octokit/Helpers/ModelExtensions.cs index ab5cf8c0..ecf52b2b 100644 --- a/Octokit/Helpers/ModelExtensions.cs +++ b/Octokit/Helpers/ModelExtensions.cs @@ -28,7 +28,7 @@ namespace Octokit var key = sshKey.Key; if (key == null) return null; var match = sshKeyRegex.Match(key); - return (match.Success ? new SshKeyInfo(match.Groups["data"].Value, match.Groups["name"].Value) : null); + return match.Success ? new SshKeyInfo(match.Groups["data"].Value, match.Groups["name"].Value) : null; } /// diff --git a/Octokit/Helpers/ReferenceExtensions.cs b/Octokit/Helpers/ReferenceExtensions.cs index 93bd4f70..b7220a9a 100644 --- a/Octokit/Helpers/ReferenceExtensions.cs +++ b/Octokit/Helpers/ReferenceExtensions.cs @@ -29,7 +29,8 @@ namespace Octokit.Helpers throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, "The specified branch name '{0}' appears to be a ref name and not a branch name because it starts with the string 'refs/heads'. Either specify just the branch name or use the Create method if you need to specify the full ref name", branchName), "branchName"); } - return await referencesClient.Create(owner, name, new NewReference("refs/heads/" + branchName, baseReference.Object.Sha)); + var newReference = new NewReference("refs/heads/" + branchName, baseReference.Object.Sha); + return await referencesClient.Create(owner, name, newReference).ConfigureAwait(false); } /// @@ -50,8 +51,9 @@ namespace Octokit.Helpers throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, "The specified branch name '{0}' appears to be a ref name and not a branch name because it starts with the string 'refs/heads'. Either specify just the branch name or use the Create method if you need to specify the full ref name", branchName), "branchName"); } - var baseBranch = await referencesClient.Get(owner, name, "heads/master"); - return await referencesClient.Create(owner, name, new NewReference("refs/heads/" + branchName, baseBranch.Object.Sha)); + var baseBranch = await referencesClient.Get(owner, name, "heads/master").ConfigureAwait(false); + var newReference = new NewReference("refs/heads/" + branchName, baseBranch.Object.Sha); + return await referencesClient.Create(owner, name, newReference).ConfigureAwait(false); } } } diff --git a/Octokit/Http/ApiConnection.cs b/Octokit/Http/ApiConnection.cs index 0cf57496..3838e555 100644 --- a/Octokit/Http/ApiConnection.cs +++ b/Octokit/Http/ApiConnection.cs @@ -171,8 +171,7 @@ namespace Octokit { Ensure.ArgumentNotNull(uri, "uri"); - return _pagination.GetAllPages(async () => await GetPage(uri, parameters, accepts) - .ConfigureAwait(false), uri); + return _pagination.GetAllPages(async () => await GetPage(uri, parameters, accepts).ConfigureAwait(false), uri); } public Task> GetAll(Uri uri, IDictionary parameters, string accepts, ApiOptions options) @@ -182,8 +181,7 @@ namespace Octokit parameters = Pagination.Setup(parameters, options); - return _pagination.GetAllPages(async () => await GetPage(uri, parameters, accepts, options) - .ConfigureAwait(false), uri); + return _pagination.GetAllPages(async () => await GetPage(uri, parameters, accepts, options).ConfigureAwait(false), uri); } /// @@ -259,11 +257,7 @@ namespace Octokit Ensure.ArgumentNotNull(uri, "uri"); Ensure.ArgumentNotNull(data, "data"); - var response = await Connection.Post( - uri, - data, - accepts, - contentType).ConfigureAwait(false); + var response = await Connection.Post(uri, data, accepts, contentType).ConfigureAwait(false); return response.Body; } @@ -284,12 +278,7 @@ namespace Octokit Ensure.ArgumentNotNull(data, "data"); Ensure.ArgumentNotNull(twoFactorAuthenticationCode, "twoFactorAuthenticationCode"); - var response = await Connection.Post( - uri, - data, - accepts, - contentType, - twoFactorAuthenticationCode).ConfigureAwait(false); + var response = await Connection.Post(uri, data, accepts, contentType, twoFactorAuthenticationCode).ConfigureAwait(false); return response.Body; } @@ -299,12 +288,7 @@ namespace Octokit Ensure.ArgumentNotNull(uri, "uri"); Ensure.ArgumentNotNull(data, "data"); - var response = await Connection.Post( - uri, - data, - accepts, - contentType, - timeout).ConfigureAwait(false); + var response = await Connection.Post(uri, data, accepts, contentType, timeout).ConfigureAwait(false); return response.Body; } @@ -467,6 +451,21 @@ namespace Octokit return Connection.Delete(uri, data); } + /// + /// Performs an asynchronous HTTP DELETE request that expects an empty response. + /// + /// URI endpoint to send request to + /// The object to serialize as the body of the request + /// Specifies accept response media type + /// The returned + public Task Delete(Uri uri, object data, string accepts) + { + Ensure.ArgumentNotNull(uri, "uri"); + Ensure.ArgumentNotNull(data, "data"); + Ensure.ArgumentNotNull(accepts, "accepts"); + + return Connection.Delete(uri, data, accepts); + } /// /// Executes a GET to the API object at the specified URI. This operation is appropriate for /// API calls which wants to return the redirect URL. @@ -479,7 +478,7 @@ namespace Octokit public async Task GetRedirect(Uri uri) { Ensure.ArgumentNotNull(uri, "uri"); - var response = await Connection.GetRedirect(uri); + var response = await Connection.GetRedirect(uri).ConfigureAwait(false); if (response.HttpResponse.StatusCode == HttpStatusCode.Redirect) { @@ -507,7 +506,7 @@ namespace Octokit { Ensure.ArgumentNotNull(uri, "uri"); - var response = await Connection.GetResponse>(uri, cancellationToken); + var response = await Connection.GetResponse>(uri, cancellationToken).ConfigureAwait(false); switch (response.HttpResponse.StatusCode) { diff --git a/Octokit/Http/Connection.cs b/Octokit/Http/Connection.cs index 81a1f86b..8f7412e1 100644 --- a/Octokit/Http/Connection.cs +++ b/Octokit/Http/Connection.cs @@ -142,7 +142,7 @@ namespace Octokit /// representing the information returned as part of an Api call public ApiInfo GetLastApiInfo() { - // We've choosen to not wrap the _lastApiInfo in a lock. Originally the code was returning a reference - so there was a danger of + // We've chosen to not wrap the _lastApiInfo in a lock. Originally the code was returning a reference - so there was a danger of // on thread writing to the object while another was reading. Now we are cloning the ApiInfo on request - thus removing the need (or overhead) // of putting locks in place. // See https://github.com/octokit/octokit.net/pull/855#discussion_r36774884 @@ -157,24 +157,6 @@ namespace Octokit return SendData(uri.ApplyParameters(parameters), HttpMethod.Get, null, accepts, null, CancellationToken.None); } - /// - /// Performs an asynchronous HTTP GET request. - /// Attempts to map the response to an object of type - /// - /// The type to map the response to - /// URI endpoint to send request to - /// Querystring parameters for the request - /// Specifies accepted response media types. - /// To follow redirect links automatically or not - /// representing the received HTTP response - [Obsolete("allowAutoRedirect is no longer respected and will be deprecated in a future release")] - public Task> Get(Uri uri, IDictionary parameters, string accepts, bool allowAutoRedirect) - { - Ensure.ArgumentNotNull(uri, "uri"); - - return SendData(uri.ApplyParameters(parameters), HttpMethod.Get, null, accepts, null, CancellationToken.None); - } - public Task> Get(Uri uri, IDictionary parameters, string accepts, CancellationToken cancellationToken) { Ensure.ArgumentNotNull(uri, "uri"); @@ -233,7 +215,7 @@ namespace Octokit { Ensure.ArgumentNotNull(uri, "uri"); - var response = await SendData(uri, HttpMethod.Post, null, null, null, CancellationToken.None); + var response = await SendData(uri, HttpMethod.Post, null, null, null, CancellationToken.None).ConfigureAwait(false); return response.HttpResponse.StatusCode; } @@ -399,7 +381,7 @@ namespace Octokit BaseAddress = BaseAddress, Endpoint = uri }; - var response = await Run(request, CancellationToken.None); + var response = await Run(request, CancellationToken.None).ConfigureAwait(false); return response.HttpResponse.StatusCode; } @@ -418,7 +400,7 @@ namespace Octokit BaseAddress = BaseAddress, Endpoint = uri }; - var response = await Run(request, CancellationToken.None); + var response = await Run(request, CancellationToken.None).ConfigureAwait(false); return response.HttpResponse.StatusCode; } @@ -437,7 +419,7 @@ namespace Octokit BaseAddress = BaseAddress, Endpoint = uri }; - var response = await Run(request, CancellationToken.None); + var response = await Run(request, CancellationToken.None).ConfigureAwait(false); return response.HttpResponse.StatusCode; } @@ -451,14 +433,7 @@ namespace Octokit { Ensure.ArgumentNotNull(uri, "uri"); - var response = await SendData( - uri, - HttpMethod.Delete, - null, - null, - null, - CancellationToken.None, - twoFactorAuthenticationCode); + var response = await SendData(uri, HttpMethod.Delete, null, null, null, CancellationToken.None, twoFactorAuthenticationCode).ConfigureAwait(false); return response.HttpResponse.StatusCode; } @@ -480,7 +455,23 @@ namespace Octokit BaseAddress = BaseAddress, Endpoint = uri }; - var response = await Run(request, CancellationToken.None); + var response = await Run(request, CancellationToken.None).ConfigureAwait(false); + return response.HttpResponse.StatusCode; + } + + /// + /// Performs an asynchronous HTTP DELETE request that expects an empty response. + /// + /// URI endpoint to send request to + /// The object to serialize as the body of the request + /// Specifies accept response media type + /// The returned + public async Task Delete(Uri uri,object data, string accepts) + { + Ensure.ArgumentNotNull(uri, "uri"); + Ensure.ArgumentNotNull(accepts, "accepts"); + + var response = await SendData(uri, HttpMethod.Delete, data, accepts, null, CancellationToken.None).ConfigureAwait(false); return response.HttpResponse.StatusCode; } @@ -527,7 +518,7 @@ namespace Octokit async Task> GetHtml(IRequest request) { request.Headers.Add("Accept", AcceptHeaders.StableVersionHtml); - var response = await RunRequest(request, CancellationToken.None); + var response = await RunRequest(request, CancellationToken.None).ConfigureAwait(false); return new ApiResponse(response, response.Body as string); } @@ -559,7 +550,8 @@ namespace Octokit { HttpStatusCode.Unauthorized, GetExceptionForUnauthorized }, { HttpStatusCode.Forbidden, GetExceptionForForbidden }, { HttpStatusCode.NotFound, response => new NotFoundException(response) }, - { (HttpStatusCode)422, response => new ApiValidationException(response) } + { (HttpStatusCode)422, response => new ApiValidationException(response) }, + { (HttpStatusCode)451, response => new LegalRestrictionException(response) } }; static void HandleErrors(IResponse response) diff --git a/Octokit/Http/HttpClientAdapter.cs b/Octokit/Http/HttpClientAdapter.cs index 1c6a65a5..16bb8868 100644 --- a/Octokit/Http/HttpClientAdapter.cs +++ b/Octokit/Http/HttpClientAdapter.cs @@ -43,8 +43,7 @@ namespace Octokit.Internal using (var requestMessage = BuildRequestMessage(request)) { // Make the request - var responseMessage = await _http.SendAsync(requestMessage, HttpCompletionOption.ResponseContentRead, cancellationTokenForRequest) - .ConfigureAwait(false); + var responseMessage = await _http.SendAsync(requestMessage, HttpCompletionOption.ResponseContentRead, cancellationTokenForRequest).ConfigureAwait(false); return await BuildResponse(responseMessage).ConfigureAwait(false); } } @@ -178,7 +177,7 @@ namespace Octokit.Internal protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { - var response = await base.SendAsync(request, cancellationToken); + var response = await base.SendAsync(request, cancellationToken).ConfigureAwait(false); // Can't redirect without somewhere to redirect too. Throw? if (response.Headers.Location == null) return response; @@ -213,7 +212,7 @@ namespace Octokit.Internal { if (request.Content != null && request.Content.Headers.ContentLength != 0) { - var stream = await request.Content.ReadAsStreamAsync(); + var stream = await request.Content.ReadAsStreamAsync().ConfigureAwait(false); if (stream.CanSeek) { stream.Position = 0; @@ -230,7 +229,7 @@ namespace Octokit.Internal { newRequest.Headers.Authorization = null; } - response = await SendAsync(newRequest, cancellationToken); + response = await SendAsync(newRequest, cancellationToken).ConfigureAwait(false); } return response; diff --git a/Octokit/Http/IApiConnection.cs b/Octokit/Http/IApiConnection.cs index 81966a10..2e50e8c4 100644 --- a/Octokit/Http/IApiConnection.cs +++ b/Octokit/Http/IApiConnection.cs @@ -293,6 +293,15 @@ namespace Octokit /// A for the request's execution. Task Delete(Uri uri, object data); + /// + /// Performs an asynchronous HTTP DELETE request that expects an empty response. + /// + /// URI endpoint to send request to + /// The object to serialize as the body of the request + /// Specifies accept response media type + /// The returned + Task Delete(Uri uri, object data, string accepts); + /// /// Executes a GET to the API object at the specified URI. This operation is appropriate for /// API calls which wants to return the redirect URL. @@ -301,6 +310,7 @@ namespace Octokit /// URI of the API resource to get /// The URL returned by the API in the Location header /// Thrown when an API error occurs, or the API does not respond with a 302 Found + [Obsolete("Octokit's HTTP library now follows redirects by default - this API will be removed in a future release")] Task GetRedirect(Uri uri); /// diff --git a/Octokit/Http/IApiInfoProvider.cs b/Octokit/Http/IApiInfoProvider.cs index c0b5dfb9..8221682a 100644 --- a/Octokit/Http/IApiInfoProvider.cs +++ b/Octokit/Http/IApiInfoProvider.cs @@ -1,7 +1,7 @@ namespace Octokit { /// - /// Provides a property for the Last recorded API infomation + /// Provides a property for the Last recorded API information /// public interface IApiInfoProvider { diff --git a/Octokit/Http/IConnection.cs b/Octokit/Http/IConnection.cs index 137f488e..39ddac53 100644 --- a/Octokit/Http/IConnection.cs +++ b/Octokit/Http/IConnection.cs @@ -32,20 +32,6 @@ namespace Octokit [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] Task> Get(Uri uri, IDictionary parameters, string accepts); - /// - /// Performs an asynchronous HTTP GET request. - /// Attempts to map the response to an object of type - /// - /// The type to map the response to - /// URI endpoint to send request to - /// Querystring parameters for the request - /// Specifies accepted response media types. - /// To follow redirect links automatically or not - /// representing the received HTTP response - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] - [Obsolete("allowAutoRedirect is no longer respected and will be deprecated in a future release")] - Task> Get(Uri uri, IDictionary parameters, string accepts, bool allowAutoRedirect); - /// /// Performs an asynchronous HTTP GET request. /// Attempts to map the response to an object of type @@ -234,6 +220,15 @@ namespace Octokit /// The returned Task Delete(Uri uri, object data); + /// + /// Performs an asynchronous HTTP DELETE request that expects an empty response. + /// + /// URI endpoint to send request to + /// The object to serialize as the body of the request + /// Specifies accept response media type + /// The returned + Task Delete(Uri uri, object data, string accepts); + /// /// Base address for the connection. /// diff --git a/Octokit/Models/Request/NewArbitraryMarkDown.cs b/Octokit/Models/Request/NewArbitraryMarkDown.cs index 5a4020b3..763440fb 100644 --- a/Octokit/Models/Request/NewArbitraryMarkDown.cs +++ b/Octokit/Models/Request/NewArbitraryMarkDown.cs @@ -81,7 +81,7 @@ namespace Octokit { if (mode != _markdown && mode != _gfm) { - throw (new FormatException("The mode must be either 'markdown' or 'gfm'")); + throw new FormatException("The mode must be either 'markdown' or 'gfm'"); } else return mode; diff --git a/Octokit/Models/Request/RepositoryIssueRequest.cs b/Octokit/Models/Request/RepositoryIssueRequest.cs index 6e82cefc..30915cc6 100644 --- a/Octokit/Models/Request/RepositoryIssueRequest.cs +++ b/Octokit/Models/Request/RepositoryIssueRequest.cs @@ -3,7 +3,7 @@ namespace Octokit { /// - /// Used to requent and filter a list of repository issues. + /// Used to request and filter a list of repository issues. /// [DebuggerDisplay("{DebuggerDisplay,nq}")] public class RepositoryIssueRequest : IssueRequest diff --git a/Octokit/Models/Request/RepositoryRequest.cs b/Octokit/Models/Request/RepositoryRequest.cs index ddb0beb4..813de9f5 100644 --- a/Octokit/Models/Request/RepositoryRequest.cs +++ b/Octokit/Models/Request/RepositoryRequest.cs @@ -90,7 +90,7 @@ namespace Octokit Owner, /// - /// Returns public repositoires. + /// Returns public repositories. /// Public, diff --git a/Octokit/Models/Request/SearchIssuesRequest.cs b/Octokit/Models/Request/SearchIssuesRequest.cs index 619eb47f..a1392aed 100644 --- a/Octokit/Models/Request/SearchIssuesRequest.cs +++ b/Octokit/Models/Request/SearchIssuesRequest.cs @@ -32,16 +32,6 @@ namespace Octokit Repos = new RepositoryCollection(); } - [Obsolete("this will be deprecated in a future version")] - public SearchIssuesRequest(string term, string owner, string name) - : this(term) - { - Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - - Repos.Add(owner, name); - } - /// /// Optional Sort field. One of comments, created, updated or merged /// If not provided, results are sorted by best match. diff --git a/Octokit/Models/Request/SearchQualifierOperator.cs b/Octokit/Models/Request/SearchQualifierOperator.cs index 5ed9481f..de42deb6 100644 --- a/Octokit/Models/Request/SearchQualifierOperator.cs +++ b/Octokit/Models/Request/SearchQualifierOperator.cs @@ -1,7 +1,7 @@ namespace Octokit { /// - /// Used to qualify a serch term. + /// Used to qualify a search term. /// public enum SearchQualifierOperator { diff --git a/Octokit/Models/Request/SearchRepositoriesRequest.cs b/Octokit/Models/Request/SearchRepositoriesRequest.cs index 9cce0203..3c2990e7 100644 --- a/Octokit/Models/Request/SearchRepositoriesRequest.cs +++ b/Octokit/Models/Request/SearchRepositoriesRequest.cs @@ -321,10 +321,10 @@ namespace Octokit } /// - /// helper method to create a LessThan Date Comparision + /// helper method to create a LessThan Date Comparison /// e.g. < 2011 /// - /// date to be used for comparision (times are ignored) + /// date to be used for comparison (times are ignored) /// public static DateRange LessThan(DateTime date) { @@ -332,10 +332,10 @@ namespace Octokit } /// - /// helper method to create a LessThanOrEqualTo Date Comparision + /// helper method to create a LessThanOrEqualTo Date Comparison /// e.g. <= 2011 /// - /// date to be used for comparision (times are ignored) + /// date to be used for comparison (times are ignored) /// public static DateRange LessThanOrEquals(DateTime date) { @@ -343,10 +343,10 @@ namespace Octokit } /// - /// helper method to create a GreaterThan Date Comparision + /// helper method to create a GreaterThan Date Comparison /// e.g. > 2011 /// - /// date to be used for comparision (times are ignored) + /// date to be used for comparison (times are ignored) /// public static DateRange GreaterThan(DateTime date) { @@ -354,10 +354,10 @@ namespace Octokit } /// - /// helper method to create a GreaterThanOrEqualTo Date Comparision + /// helper method to create a GreaterThanOrEqualTo Date Comparison /// e.g. >= 2011 /// - /// date to be used for comparision (times are ignored) + /// date to be used for comparison (times are ignored) /// public static DateRange GreaterThanOrEquals(DateTime date) { @@ -479,6 +479,10 @@ namespace Octokit [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Edn")] Edn, Eiffel, + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Elixir")] + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Elixir")] + Elixir, + [Obsolete("This item is incorrect and will be removed in a future update. Use Elixir instead.")] [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Elixer")] [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Elixer")] Elixer, @@ -709,6 +713,10 @@ namespace Octokit [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "TypeScript")] [Parameter(Value = "TypeScript")] TypeScript, + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Parallel")] + [Parameter(Value = "Unified Parallel C")] + UnifiedParallelC, + [Obsolete("This item is incorrect and will be removed in a future update. Use UnifiedParallelC instead.")] [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Paralel")] [Parameter(Value = "Unified Paralel C")] UnifiedParalelC, diff --git a/Octokit/Models/Response/BranchProtection.cs b/Octokit/Models/Response/BranchProtection.cs index 31a2f3f1..0cd63840 100644 --- a/Octokit/Models/Response/BranchProtection.cs +++ b/Octokit/Models/Response/BranchProtection.cs @@ -82,7 +82,7 @@ namespace Octokit Off, /// - /// Required status checks will be enforeced for non-admins. + /// Required status checks will be enforced for non-admins. /// NonAdmins, diff --git a/Octokit/Models/Response/CompareResult.cs b/Octokit/Models/Response/CompareResult.cs index 38588f38..bd47b7ce 100644 --- a/Octokit/Models/Response/CompareResult.cs +++ b/Octokit/Models/Response/CompareResult.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Diagnostics; using System.Globalization; @@ -9,7 +10,7 @@ namespace Octokit { public CompareResult() { } - public CompareResult(string url, string htmlUrl, string permalinkUrl, string diffUrl, string patchUrl, GitHubCommit baseCommit, GitHubCommit mergedBaseCommit, string status, int aheadBy, int behindBy, int totalCommits, IReadOnlyList commits, IReadOnlyList files) + public CompareResult(string url, string htmlUrl, string permalinkUrl, string diffUrl, string patchUrl, GitHubCommit baseCommit, GitHubCommit mergeBaseCommit, string status, int aheadBy, int behindBy, int totalCommits, IReadOnlyList commits, IReadOnlyList files) { Url = url; HtmlUrl = htmlUrl; @@ -17,7 +18,7 @@ namespace Octokit DiffUrl = diffUrl; PatchUrl = patchUrl; BaseCommit = baseCommit; - MergedBaseCommit = mergedBaseCommit; + MergeBaseCommit = mergeBaseCommit; Status = status; AheadBy = aheadBy; BehindBy = behindBy; @@ -32,7 +33,9 @@ namespace Octokit public string DiffUrl { get; protected set; } public string PatchUrl { get; protected set; } public GitHubCommit BaseCommit { get; protected set; } + [Obsolete("This property is obsolete. Use MergeBaseCommit instead.", false)] public GitHubCommit MergedBaseCommit { get; protected set; } + public GitHubCommit MergeBaseCommit { get; protected set; } public string Status { get; protected set; } public int AheadBy { get; protected set; } public int BehindBy { get; protected set; } diff --git a/Octokit/Models/Response/License.cs b/Octokit/Models/Response/License.cs index 673f3ab2..d5d2b53b 100644 --- a/Octokit/Models/Response/License.cs +++ b/Octokit/Models/Response/License.cs @@ -79,7 +79,7 @@ namespace Octokit public IReadOnlyList Required { get; protected set; } /// - /// Set of codes for what is permitted under the terms of the license. For example, "commerical-use" + /// Set of codes for what is permitted under the terms of the license. For example, "commercial-use" /// public IReadOnlyList Permitted { get; protected set; } diff --git a/Octokit/Models/Response/Meta.cs b/Octokit/Models/Response/Meta.cs index 3d388827..0dec38c9 100644 --- a/Octokit/Models/Response/Meta.cs +++ b/Octokit/Models/Response/Meta.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Globalization; +using Octokit.Internal; namespace Octokit { @@ -25,18 +26,21 @@ namespace Octokit /// An array of IP addresses in CIDR format specifying the addresses that incoming service hooks will originate from on GitHub.com. /// An array of IP addresses in CIDR format specifying the Git servers for the GitHub server /// An array of IP addresses in CIDR format specifying the A records for GitHub Pages. + /// An Array of IP addresses specifying the addresses that source imports will originate from on GitHub.com. public Meta( bool verifiablePasswordAuthentication, string gitHubServicesSha, IReadOnlyList hooks, IReadOnlyList git, - IReadOnlyList pages) + IReadOnlyList pages, + IReadOnlyList importer) { VerifiablePasswordAuthentication = verifiablePasswordAuthentication; GitHubServicesSha = gitHubServicesSha; Hooks = hooks; Git = git; Pages = pages; + Importer = importer; } /// @@ -49,6 +53,7 @@ namespace Octokit /// /// The currently-deployed SHA of github-services. /// + [Parameter(Key = "github_services_sha")] public string GitHubServicesSha { get; private set; } /// @@ -68,6 +73,11 @@ namespace Octokit /// public IReadOnlyList Pages { get; private set; } + /// + /// An Array of IP addresses specifying the addresses that source imports will originate from on GitHub.com. + /// + public IReadOnlyList Importer { get; private set; } + internal string DebuggerDisplay { get diff --git a/Octokit/Models/Response/Readme.cs b/Octokit/Models/Response/Readme.cs index b5ce2100..9a6784bd 100644 --- a/Octokit/Models/Response/Readme.cs +++ b/Octokit/Models/Response/Readme.cs @@ -45,7 +45,7 @@ namespace Octokit public Uri Url { get; private set; } [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", - Justification = "Makse a network request")] + Justification = "Makes a network request")] public Task GetHtmlContent() { return htmlContent.Value; diff --git a/Octokit/Models/Response/Repository.cs b/Octokit/Models/Response/Repository.cs index 08aafecc..84811d85 100644 --- a/Octokit/Models/Response/Repository.cs +++ b/Octokit/Models/Response/Repository.cs @@ -14,7 +14,7 @@ namespace Octokit Id = id; } - public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, int id, User owner, string name, string fullName, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, int subscribersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, User organization, Repository parent, Repository source, bool hasIssues, bool hasWiki, bool hasDownloads) + public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, int id, User owner, string name, string fullName, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, Repository parent, Repository source, bool hasIssues, bool hasWiki, bool hasDownloads) { Url = url; HtmlUrl = htmlUrl; @@ -34,18 +34,12 @@ namespace Octokit Fork = fork; ForksCount = forksCount; StargazersCount = stargazersCount; -#pragma warning disable 612,618 - SubscribersCount = subscribersCount; -#pragma warning restore 612,618 DefaultBranch = defaultBranch; OpenIssuesCount = openIssuesCount; PushedAt = pushedAt; CreatedAt = createdAt; UpdatedAt = updatedAt; Permissions = permissions; -#pragma warning disable 612, 618 - Organization = organization; -#pragma warning restore 612, 618 Parent = parent; Source = source; HasIssues = hasIssues; @@ -89,9 +83,6 @@ namespace Octokit public int StargazersCount { get; protected set; } - [Obsolete("This property has been obsoleted. Please use WatchedClient.GetAllWatchers instead.")] - public int SubscribersCount { get; protected set; } - public string DefaultBranch { get; protected set; } public int OpenIssuesCount { get; protected set; } @@ -104,9 +95,6 @@ namespace Octokit public RepositoryPermissions Permissions { get; protected set; } - [Obsolete("This property has been obsoleted by Repository.Owner. Please use Repository.Owner.Type instead.")] - public User Organization { get; protected set; } - public Repository Parent { get; protected set; } public Repository Source { get; protected set; } diff --git a/Octokit/Models/Response/TagObject.cs b/Octokit/Models/Response/TagObject.cs index 5260023a..a157d17b 100644 --- a/Octokit/Models/Response/TagObject.cs +++ b/Octokit/Models/Response/TagObject.cs @@ -15,7 +15,7 @@ namespace Octokit } [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods", - Justification = "Name defined by web api and required for deserialisation")] + Justification = "Name defined by web api and required for deserialization")] public TaggedType Type { get; protected set; } } diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index 2506e59f..044a32bf 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -458,6 +458,7 @@ + diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index 53efa2a7..49bcf338 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -467,6 +467,7 @@ + diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index aaf0efdf..b3ee893a 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -463,6 +463,7 @@ + diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj index 3c1f3f69..ce5c1dba 100644 --- a/Octokit/Octokit-Portable.csproj +++ b/Octokit/Octokit-Portable.csproj @@ -455,6 +455,7 @@ + diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index 59bc6b51..77215bf7 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -462,6 +462,7 @@ + diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 6fe16737..44e007ab 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -91,6 +91,7 @@ + diff --git a/SolutionInfo.cs b/SolutionInfo.cs index 22509412..a52961be 100644 --- a/SolutionInfo.cs +++ b/SolutionInfo.cs @@ -6,10 +6,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyVersionAttribute("0.19.0")] [assembly: AssemblyFileVersionAttribute("0.19.0")] [assembly: ComVisibleAttribute(false)] -namespace System -{ - internal static class AssemblyVersionInformation - { +namespace System { + internal static class AssemblyVersionInformation { internal const string Version = "0.19.0"; } }