From db8738b6750967e2d0894259fcc2e6b5d620b58c Mon Sep 17 00:00:00 2001 From: Prayank Mathur Date: Thu, 17 Mar 2016 11:55:44 +0530 Subject: [PATCH] Corrected TheUpdateMethod.EnsureArgumentsNotNull() --- .../Enterprise/IObservableEnterpriseLdapClient.cs | 2 +- .../Enterprise/ObservableEnterpriseLdapClient.cs | 2 +- .../Enterprise/EnterpriseLdapClientTests.cs | 2 +- .../Clients/RepositoriesClientTests.cs | 2 +- .../Clients/UserAdministrationClientTests.cs | 4 ++-- Octokit.Tests.Integration/EnterpriseHelper.cs | 8 ++++---- .../ObservableEnterpriseLdapClientTests.cs | 4 ++-- .../Reactive/ObservableUserKeysClientTests.cs | 2 +- .../EnterpriseOrganizationClientTests.cs | 2 +- Octokit.Tests/Clients/RepositoriesClientTests.cs | 1 - .../Clients/RepositoryContentsClientTests.cs | 2 +- .../Clients/UserAdministrationClientTests.cs | 8 ++++---- .../ObservableEnterpriseLdapClientTests.cs | 14 +++++++------- .../ObservableEnterpriseOrganizationClientTests.cs | 6 +++--- ...bservableEnterpriseSearchIndexingClientTests.cs | 2 +- .../Reactive/ObservableIssuesClientTests.cs | 10 +++++----- .../ObservableUserAdministrationClientTests.cs | 2 +- Octokit/Clients/Enterprise/EnterpriseLdapClient.cs | 6 +++--- .../Enterprise/EnterpriseSearchIndexingClient.cs | 2 +- Octokit/Clients/UserAdministrationClient.cs | 2 +- Octokit/Http/IApiConnection.cs | 2 +- Octokit/Models/Request/CreateFileRequest.cs | 2 +- SolutionInfo.cs | 6 ++++-- 23 files changed, 47 insertions(+), 46 deletions(-) diff --git a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseLdapClient.cs b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseLdapClient.cs index d5f4bd1f68..1791d57e0c 100644 --- a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseLdapClient.cs +++ b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseLdapClient.cs @@ -33,7 +33,7 @@ public interface IObservableEnterpriseLdapClient /// The username to sync LDAP mapping /// The of the queue request. IObservable QueueSyncUserMapping(string userName); - + /// /// Update the LDAP mapping for a team on a GitHub Enterprise appliance (must be Site Admin user). /// diff --git a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseLdapClient.cs b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseLdapClient.cs index f096e496ab..0a037406f0 100644 --- a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseLdapClient.cs +++ b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseLdapClient.cs @@ -49,7 +49,7 @@ public IObservable QueueSyncUserMapping(string userName) { return _client.QueueSyncUserMapping(userName).ToObservable(); } - + /// /// Update the LDAP mapping for a team on a GitHub Enterprise appliance (must be Site Admin user). /// diff --git a/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseLdapClientTests.cs b/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseLdapClientTests.cs index edbca49664..5fbac3728e 100644 --- a/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseLdapClientTests.cs +++ b/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseLdapClientTests.cs @@ -19,7 +19,7 @@ public class EnterpriseLdapClientTests : IDisposable public EnterpriseLdapClientTests() { _github = EnterpriseHelper.GetAuthenticatedClient(); - + NewTeam newTeam = new NewTeam(Helper.MakeNameWithTimestamp("test-team")) { Description = "Test Team" }; _context = _github.CreateEnterpriseTeamContext(EnterpriseHelper.Organization, newTeam).Result; } diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index 78247ebc78..ebd29eb2b5 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -447,7 +447,7 @@ public async Task DeletesRepository() var repoName = Helper.MakeNameWithTimestamp("repo-to-delete"); await github.Repository.Create(new NewRepository(repoName)); - + await github.Repository.Delete(Helper.UserName, repoName); } } diff --git a/Octokit.Tests.Integration/Clients/UserAdministrationClientTests.cs b/Octokit.Tests.Integration/Clients/UserAdministrationClientTests.cs index 321017ac3d..b9c049abd4 100644 --- a/Octokit.Tests.Integration/Clients/UserAdministrationClientTests.cs +++ b/Octokit.Tests.Integration/Clients/UserAdministrationClientTests.cs @@ -95,7 +95,7 @@ public async Task CanAddAndDeleteImpersonationToken() Assert.NotNull(token); Assert.True( - token.Scopes.Count() == 1 && + token.Scopes.Count() == 1 && token.Scopes.All(s => s == "public_repo")); // Delete Impersonation token @@ -187,7 +187,7 @@ public async Task CanDeletePublicKey() { // Ensure user has a key //var key = await _github.User.Keys.Create(new NewPublicKey("title", "key")); - + // Delete key //await _github.User.Administration.DeletePublicKey(key.Id); } diff --git a/Octokit.Tests.Integration/EnterpriseHelper.cs b/Octokit.Tests.Integration/EnterpriseHelper.cs index 7e03a604a2..baf16c9a33 100644 --- a/Octokit.Tests.Integration/EnterpriseHelper.cs +++ b/Octokit.Tests.Integration/EnterpriseHelper.cs @@ -55,7 +55,7 @@ public static class EnterpriseHelper string enabled = Environment.GetEnvironmentVariable("OCTOKIT_GHE_ENABLED"); return !String.IsNullOrWhiteSpace(enabled); }); - + static readonly Lazy _gitHubEnterpriseUrl = new Lazy(() => { string uri = Environment.GetEnvironmentVariable("OCTOKIT_GHE_URL"); @@ -76,7 +76,7 @@ static EnterpriseHelper() public static string UserName { get; private set; } public static string Organization { get; private set; } - + /// /// These credentials should be set to a test GitHub account using the powershell script configure-integration-tests.ps1 /// @@ -88,8 +88,8 @@ static EnterpriseHelper() public static bool IsGitHubEnterpriseEnabled { get { return _gitHubEnterpriseEnabled.Value; } } - public static Uri GitHubEnterpriseUrl { get { return _gitHubEnterpriseUrl.Value; } } - + public static Uri GitHubEnterpriseUrl { get { return _gitHubEnterpriseUrl.Value; } } + public static bool IsUsingToken { get diff --git a/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs b/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs index dde932d8c9..948a52a65a 100644 --- a/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs @@ -14,10 +14,10 @@ public class ObservableEnterpriseLdapClientTests : IDisposable readonly string _testUser = "test-user"; readonly string _distinguishedNameUser = "uid=test-user,ou=users,dc=company,dc=com"; - + readonly EnterpriseTeamContext _context; readonly string _distinguishedNameTeam = "cn=test-team,ou=groups,dc=company,dc=com"; - + public ObservableEnterpriseLdapClientTests() { _github = new ObservableGitHubClient(EnterpriseHelper.GetAuthenticatedClient()); diff --git a/Octokit.Tests.Integration/Reactive/ObservableUserKeysClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableUserKeysClientTests.cs index cf56317b7b..4e48c55f53 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableUserKeysClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableUserKeysClientTests.cs @@ -68,7 +68,7 @@ public async Task CanCreateAndDeleteKey() // Create a key string keyTitle = "title"; string keyData = "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAjo4DqFKg8dOxiz/yjypmN1A4itU5QOStyYrfOFuTinesU/2zm9hqxJ5BctIhgtSHJ5foxkhsiBji0qrUg73Q25BThgNg8YFE8njr4EwjmqSqW13akx/zLV0GFFU0SdJ2F6rBldhi93lMnl0ex9swBqa3eLTY8C+HQGBI6MQUMw+BKp0oFkz87Kv+Pfp6lt/Uo32ejSxML1PT5hTH5n+fyl0ied+sRmPGZWmWoHB5Bc9mox7lB6I6A/ZgjtBqbEEn4HQ2/6vp4ojKfSgA4Mm7XMu0bZzX0itKjH1QWD9Lr5apV1cmZsj49Xf8SHucTtH+bq98hb8OOXEGFzplwsX2MQ=="; - + var observable = _github.User.Keys.Create(new NewPublicKey(keyTitle, keyData)); var key = await observable; diff --git a/Octokit.Tests/Clients/Enterprise/EnterpriseOrganizationClientTests.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseOrganizationClientTests.cs index 4b078b1290..b3c815b565 100644 --- a/Octokit.Tests/Clients/Enterprise/EnterpriseOrganizationClientTests.cs +++ b/Octokit.Tests/Clients/Enterprise/EnterpriseOrganizationClientTests.cs @@ -17,7 +17,7 @@ public void RequestsCorrectUrl() string expectedUri = "admin/organizations"; client.Create(new NewOrganization("org", "admin", "org name")); - + connection.Received().Post(Arg.Is(u => u.ToString() == expectedUri), Arg.Any()); } diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index e74cc97b83..0dadb511f5 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -404,7 +404,6 @@ public void CanFilterByAffiliation() var request = new RepositoryRequest { - Affiliation = RepositoryAffiliation.Owner, Sort = RepositorySort.FullName }; diff --git a/Octokit.Tests/Clients/RepositoryContentsClientTests.cs b/Octokit.Tests/Clients/RepositoryContentsClientTests.cs index 0e59b5334d..5dea73d816 100644 --- a/Octokit.Tests/Clients/RepositoryContentsClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryContentsClientTests.cs @@ -100,7 +100,7 @@ public void RequestsCorrectUrl() string expectedUri = "repos/org/repo/contents/path/to/file"; client.CreateFile("org", "repo", "path/to/file", new CreateFileRequest("message", "myfilecontents", "mybranch")); - + connection.Received().Put(Arg.Is(u => u.ToString() == expectedUri), Arg.Any()); } diff --git a/Octokit.Tests/Clients/UserAdministrationClientTests.cs b/Octokit.Tests/Clients/UserAdministrationClientTests.cs index 4174b06be5..4712b24b2e 100644 --- a/Octokit.Tests/Clients/UserAdministrationClientTests.cs +++ b/Octokit.Tests/Clients/UserAdministrationClientTests.cs @@ -29,7 +29,7 @@ public void RequestsTheCorrectUrl() client.Create(new NewUser("name", "email@company.com")); connection.Received().Post( - Arg.Is(u => u.ToString() == expectedUri), + Arg.Is(u => u.ToString() == expectedUri), Arg.Any()); } @@ -38,13 +38,13 @@ public void PassesRequestObject() { var connection = Substitute.For(); var client = new UserAdministrationClient(connection); - + client.Create(new NewUser("name", "email@company.com")); connection.Received().Post( - Arg.Any(), + Arg.Any(), Arg.Is(a => - a.Login == "name" && + a.Login == "name" && a.Email == "email@company.com")); } } diff --git a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs index a1fc976947..ec8de49524 100644 --- a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs +++ b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs @@ -10,7 +10,7 @@ public class ObservableEnterpriseLDAPClientTests public class TheUpdateUserMappingMethod { readonly string _distinguishedName = "uid=test-user,ou=users,dc=company,dc=com"; - + [Fact] public void CallsIntoClient() { @@ -20,11 +20,11 @@ public void CallsIntoClient() client.UpdateUserMapping("test-user", new NewLdapMapping(_distinguishedName)); github.Enterprise.Ldap.Received(1).UpdateUserMapping( Arg.Is(a => a == "test-user"), - Arg.Is(a => + Arg.Is(a => a.LdapDistinguishedName == _distinguishedName)); } } - + public class TheQueueSyncUserMappingMethod { [Fact] @@ -38,11 +38,11 @@ public void CallsIntoClient() Arg.Is(a => a == "test-user")); } } - + public class TheUpdateTeamMappingMethod { readonly string _distinguishedName = "cn=test-team,ou=groups,dc=company,dc=com"; - + [Fact] public void CallsIntoClient() { @@ -52,11 +52,11 @@ public void CallsIntoClient() client.UpdateTeamMapping(1, new NewLdapMapping(_distinguishedName)); github.Enterprise.Ldap.Received(1).UpdateTeamMapping( Arg.Is(a => a == 1), - Arg.Is(a => + Arg.Is(a => a.LdapDistinguishedName == _distinguishedName)); } } - + public class TheQueueSyncTeamMappingMethod { [Fact] diff --git a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseOrganizationClientTests.cs b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseOrganizationClientTests.cs index 47046e05fd..5e849d849a 100644 --- a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseOrganizationClientTests.cs +++ b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseOrganizationClientTests.cs @@ -17,9 +17,9 @@ public void CallsIntoClient() client.Create(new NewOrganization("org", "admin", "org name")); github.Enterprise.Organization.Received(1).Create( - Arg.Is(a => - a.Login == "org" - && a.Admin == "admin" + Arg.Is(a => + a.Login == "org" + && a.Admin == "admin" && a.ProfileName == "org name")); } } diff --git a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseSearchIndexingClientTests.cs b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseSearchIndexingClientTests.cs index 491acbfc10..e185081fe6 100644 --- a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseSearchIndexingClientTests.cs +++ b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseSearchIndexingClientTests.cs @@ -17,7 +17,7 @@ public void CallsIntoClient() client.Queue("org"); github.Enterprise.SearchIndexing.Received(1). - Queue(Arg.Is( "org" )); + Queue(Arg.Is("org")); client.Queue("org", "repo"); github.Enterprise.SearchIndexing.Received(1). diff --git a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs index aa23f958fd..b09a498a69 100644 --- a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs @@ -329,11 +329,11 @@ public void EnsuresArgumentsNotNull() var gitHubClient = Substitute.For(); var client = new ObservableIssuesClient(gitHubClient); - Assert.Throws(() => client.Create(null, "name", new NewIssue("title"))); - Assert.Throws(() => client.Create("", "name", new NewIssue("x"))); - Assert.Throws(() => client.Create("owner", null, new NewIssue("x"))); - Assert.Throws(() => client.Create("owner", "", new NewIssue("x"))); - Assert.Throws(() => client.Create("owner", "name", null)); + Assert.Throws(() => client.Update(null, "name", 42, new IssueUpdate())); + Assert.Throws(() => client.Update("", "name", 42, new IssueUpdate())); + Assert.Throws(() => client.Update("owner", null, 42, new IssueUpdate())); + Assert.Throws(() => client.Update("owner", "", 42, new IssueUpdate())); + Assert.Throws(() => client.Update("owner", "name", 42, null)); } } diff --git a/Octokit.Tests/Reactive/ObservableUserAdministrationClientTests.cs b/Octokit.Tests/Reactive/ObservableUserAdministrationClientTests.cs index d247ddb30f..682a09b64c 100644 --- a/Octokit.Tests/Reactive/ObservableUserAdministrationClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableUserAdministrationClientTests.cs @@ -19,7 +19,7 @@ public void CallsIntoClient() client.Create(new NewUser("auser", "email@company.com")); gitHubClient.User.Administration.Received().Create( - Arg.Is(a => + Arg.Is(a => a.Login == "auser" && a.Email == "email@company.com")); } diff --git a/Octokit/Clients/Enterprise/EnterpriseLdapClient.cs b/Octokit/Clients/Enterprise/EnterpriseLdapClient.cs index 6357da504e..1980dc6f1a 100644 --- a/Octokit/Clients/Enterprise/EnterpriseLdapClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseLdapClient.cs @@ -45,7 +45,7 @@ public Task UpdateUserMapping(string userName, NewLdapMapping newLdapMappi public async Task QueueSyncUserMapping(string userName) { Ensure.ArgumentNotNull(userName, "userName"); - + var endpoint = ApiUrls.EnterpriseLdapUserSync(userName); var response = await Connection.Post(endpoint); @@ -56,7 +56,7 @@ public async Task QueueSyncUserMapping(string userName) return response.Body; } - + /// /// Update the LDAP mapping for a team on a GitHub Enterprise appliance (must be Site Admin user). /// @@ -87,7 +87,7 @@ public Task UpdateTeamMapping(int teamId, NewLdapMapping newLdapMapping) public async Task QueueSyncTeamMapping(int teamId) { Ensure.ArgumentNotNull(teamId, "teamId"); - + var endpoint = ApiUrls.EnterpriseLdapTeamSync(teamId); var response = await Connection.Post(endpoint); diff --git a/Octokit/Clients/Enterprise/EnterpriseSearchIndexingClient.cs b/Octokit/Clients/Enterprise/EnterpriseSearchIndexingClient.cs index 7e157bfbcf..2351a2f115 100644 --- a/Octokit/Clients/Enterprise/EnterpriseSearchIndexingClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseSearchIndexingClient.cs @@ -146,7 +146,7 @@ public async Task QueueAllCode(string owner, string repo public async Task QueueAllCode(string owner) { Ensure.ArgumentNotNull(owner, "owner"); - + var endpoint = ApiUrls.EnterpriseSearchIndexing(); var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}/*/code", owner)); diff --git a/Octokit/Clients/UserAdministrationClient.cs b/Octokit/Clients/UserAdministrationClient.cs index a39fcb8dd8..1b7a15e60d 100644 --- a/Octokit/Clients/UserAdministrationClient.cs +++ b/Octokit/Clients/UserAdministrationClient.cs @@ -218,7 +218,7 @@ public async Task DeletePublicKey(int keyId) { Ensure.ArgumentNotNull(keyId, "keyId"); var endpoint = ApiUrls.UserAdministrationPublicKeys(keyId); - + var response = ((HttpStatusCode)await Connection.Delete(endpoint)); if (response != HttpStatusCode.NoContent) { diff --git a/Octokit/Http/IApiConnection.cs b/Octokit/Http/IApiConnection.cs index 4984870b61..81966a101e 100644 --- a/Octokit/Http/IApiConnection.cs +++ b/Octokit/Http/IApiConnection.cs @@ -141,7 +141,7 @@ public interface IApiConnection /// The created API resource. /// Thrown when an API error occurs. Task Post(Uri uri); - + /// /// Creates a new API resource in the list at the specified URI. /// diff --git a/Octokit/Models/Request/CreateFileRequest.cs b/Octokit/Models/Request/CreateFileRequest.cs index b9529e3bff..7104b3642d 100644 --- a/Octokit/Models/Request/CreateFileRequest.cs +++ b/Octokit/Models/Request/CreateFileRequest.cs @@ -26,7 +26,7 @@ protected ContentRequest(string message) /// /// The message. /// The branch the request is for. - protected ContentRequest(string message, string branch): this(message) + protected ContentRequest(string message, string branch) : this(message) { Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); diff --git a/SolutionInfo.cs b/SolutionInfo.cs index a52961be74..22509412fb 100644 --- a/SolutionInfo.cs +++ b/SolutionInfo.cs @@ -6,8 +6,10 @@ [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"; } }