Skip to content

Commit

Permalink
Corrected TheUpdateMethod.EnsureArgumentsNotNull()
Browse files Browse the repository at this point in the history
  • Loading branch information
prayankmathur committed Mar 17, 2016
1 parent f354d1b commit db8738b
Show file tree
Hide file tree
Showing 23 changed files with 47 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public interface IObservableEnterpriseLdapClient
/// <param name="userName">The username to sync LDAP mapping</param>
/// <returns>The <see cref="LdapSyncResponse"/> of the queue request.</returns>
IObservable<LdapSyncResponse> QueueSyncUserMapping(string userName);

/// <summary>
/// Update the LDAP mapping for a team on a GitHub Enterprise appliance (must be Site Admin user).
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public IObservable<LdapSyncResponse> QueueSyncUserMapping(string userName)
{
return _client.QueueSyncUserMapping(userName).ToObservable();
}

/// <summary>
/// Update the LDAP mapping for a team on a GitHub Enterprise appliance (must be Site Admin user).
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions Octokit.Tests.Integration/EnterpriseHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static class EnterpriseHelper
string enabled = Environment.GetEnvironmentVariable("OCTOKIT_GHE_ENABLED");
return !String.IsNullOrWhiteSpace(enabled);
});

static readonly Lazy<Uri> _gitHubEnterpriseUrl = new Lazy<Uri>(() =>
{
string uri = Environment.GetEnvironmentVariable("OCTOKIT_GHE_URL");
Expand All @@ -76,7 +76,7 @@ static EnterpriseHelper()

public static string UserName { get; private set; }
public static string Organization { get; private set; }

/// <summary>
/// These credentials should be set to a test GitHub account using the powershell script configure-integration-tests.ps1
/// </summary>
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void RequestsCorrectUrl()

string expectedUri = "admin/organizations";
client.Create(new NewOrganization("org", "admin", "org name"));

connection.Received().Post<Organization>(Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Any<object>());
}

Expand Down
1 change: 0 additions & 1 deletion Octokit.Tests/Clients/RepositoriesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ public void CanFilterByAffiliation()

var request = new RepositoryRequest
{

Affiliation = RepositoryAffiliation.Owner,
Sort = RepositorySort.FullName
};
Expand Down
2 changes: 1 addition & 1 deletion Octokit.Tests/Clients/RepositoryContentsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RepositoryContentChangeSet>(Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Any<object>());
}

Expand Down
8 changes: 4 additions & 4 deletions Octokit.Tests/Clients/UserAdministrationClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void RequestsTheCorrectUrl()
client.Create(new NewUser("name", "[email protected]"));

connection.Received().Post<User>(
Arg.Is<Uri>(u => u.ToString() == expectedUri),
Arg.Is<Uri>(u => u.ToString() == expectedUri),
Arg.Any<object>());
}

Expand All @@ -38,13 +38,13 @@ public void PassesRequestObject()
{
var connection = Substitute.For<IApiConnection>();
var client = new UserAdministrationClient(connection);

client.Create(new NewUser("name", "[email protected]"));

connection.Received().Post<User>(
Arg.Any<Uri>(),
Arg.Any<Uri>(),
Arg.Is<NewUser>(a =>
a.Login == "name" &&
a.Login == "name" &&
a.Email == "[email protected]"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -20,11 +20,11 @@ public void CallsIntoClient()
client.UpdateUserMapping("test-user", new NewLdapMapping(_distinguishedName));
github.Enterprise.Ldap.Received(1).UpdateUserMapping(
Arg.Is<string>(a => a == "test-user"),
Arg.Is<NewLdapMapping>(a =>
Arg.Is<NewLdapMapping>(a =>
a.LdapDistinguishedName == _distinguishedName));
}
}

public class TheQueueSyncUserMappingMethod
{
[Fact]
Expand All @@ -38,11 +38,11 @@ public void CallsIntoClient()
Arg.Is<string>(a => a == "test-user"));
}
}

public class TheUpdateTeamMappingMethod
{
readonly string _distinguishedName = "cn=test-team,ou=groups,dc=company,dc=com";

[Fact]
public void CallsIntoClient()
{
Expand All @@ -52,11 +52,11 @@ public void CallsIntoClient()
client.UpdateTeamMapping(1, new NewLdapMapping(_distinguishedName));
github.Enterprise.Ldap.Received(1).UpdateTeamMapping(
Arg.Is<int>(a => a == 1),
Arg.Is<NewLdapMapping>(a =>
Arg.Is<NewLdapMapping>(a =>
a.LdapDistinguishedName == _distinguishedName));
}
}

public class TheQueueSyncTeamMappingMethod
{
[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public void CallsIntoClient()

client.Create(new NewOrganization("org", "admin", "org name"));
github.Enterprise.Organization.Received(1).Create(
Arg.Is<NewOrganization>(a =>
a.Login == "org"
&& a.Admin == "admin"
Arg.Is<NewOrganization>(a =>
a.Login == "org"
&& a.Admin == "admin"
&& a.ProfileName == "org name"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void CallsIntoClient()

client.Queue("org");
github.Enterprise.SearchIndexing.Received(1).
Queue(Arg.Is<string>( "org" ));
Queue(Arg.Is<string>("org"));

client.Queue("org", "repo");
github.Enterprise.SearchIndexing.Received(1).
Expand Down
10 changes: 5 additions & 5 deletions Octokit.Tests/Reactive/ObservableIssuesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,11 @@ public void EnsuresArgumentsNotNull()
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableIssuesClient(gitHubClient);

Assert.Throws<ArgumentNullException>(() => client.Create(null, "name", new NewIssue("title")));
Assert.Throws<ArgumentException>(() => client.Create("", "name", new NewIssue("x")));
Assert.Throws<ArgumentNullException>(() => client.Create("owner", null, new NewIssue("x")));
Assert.Throws<ArgumentException>(() => client.Create("owner", "", new NewIssue("x")));
Assert.Throws<ArgumentNullException>(() => client.Create("owner", "name", null));
Assert.Throws<ArgumentNullException>(() => client.Update(null, "name", 42, new IssueUpdate()));
Assert.Throws<ArgumentException>(() => client.Update("", "name", 42, new IssueUpdate()));
Assert.Throws<ArgumentNullException>(() => client.Update("owner", null, 42, new IssueUpdate()));
Assert.Throws<ArgumentException>(() => client.Update("owner", "", 42, new IssueUpdate()));
Assert.Throws<ArgumentNullException>(() => client.Update("owner", "name", 42, null));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void CallsIntoClient()
client.Create(new NewUser("auser", "[email protected]"));

gitHubClient.User.Administration.Received().Create(
Arg.Is<NewUser>(a =>
Arg.Is<NewUser>(a =>
a.Login == "auser" &&
a.Email == "[email protected]"));
}
Expand Down
6 changes: 3 additions & 3 deletions Octokit/Clients/Enterprise/EnterpriseLdapClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public Task<User> UpdateUserMapping(string userName, NewLdapMapping newLdapMappi
public async Task<LdapSyncResponse> QueueSyncUserMapping(string userName)
{
Ensure.ArgumentNotNull(userName, "userName");

var endpoint = ApiUrls.EnterpriseLdapUserSync(userName);

var response = await Connection.Post<LdapSyncResponse>(endpoint);
Expand All @@ -56,7 +56,7 @@ public async Task<LdapSyncResponse> QueueSyncUserMapping(string userName)

return response.Body;
}

/// <summary>
/// Update the LDAP mapping for a team on a GitHub Enterprise appliance (must be Site Admin user).
/// </summary>
Expand Down Expand Up @@ -87,7 +87,7 @@ public Task<Team> UpdateTeamMapping(int teamId, NewLdapMapping newLdapMapping)
public async Task<LdapSyncResponse> QueueSyncTeamMapping(int teamId)
{
Ensure.ArgumentNotNull(teamId, "teamId");

var endpoint = ApiUrls.EnterpriseLdapTeamSync(teamId);

var response = await Connection.Post<LdapSyncResponse>(endpoint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public async Task<SearchIndexingResponse> QueueAllCode(string owner, string repo
public async Task<SearchIndexingResponse> QueueAllCode(string owner)
{
Ensure.ArgumentNotNull(owner, "owner");

var endpoint = ApiUrls.EnterpriseSearchIndexing();
var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}/*/code", owner));

Expand Down
2 changes: 1 addition & 1 deletion Octokit/Clients/UserAdministrationClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion Octokit/Http/IApiConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public interface IApiConnection
/// <returns>The created API resource.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
Task<T> Post<T>(Uri uri);

/// <summary>
/// Creates a new API resource in the list at the specified URI.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Octokit/Models/Request/CreateFileRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected ContentRequest(string message)
/// </summary>
/// <param name="message">The message.</param>
/// <param name="branch">The branch the request is for.</param>
protected ContentRequest(string message, string branch): this(message)
protected ContentRequest(string message, string branch) : this(message)
{
Ensure.ArgumentNotNullOrEmptyString(branch, "branch");

Expand Down
6 changes: 4 additions & 2 deletions SolutionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}

0 comments on commit db8738b

Please sign in to comment.