public void AddOrUpdatePermission() { var connection = Substitute.For <IApiConnection>(); var client = new TeamsClient(connection); var newPermission = new RepositoryPermissionRequest(Permission.Admin); client.AddRepository(1, "org", "repo", newPermission); connection.Connection.Received().Put <HttpStatusCode>(Arg.Is <Uri>(u => u.ToString() == "teams/1/repos/org/repo"), Arg.Any <object>(), "", "application/vnd.github.ironman-preview+json"); }
public async Task AddOrUpdatePermission() { var connection = Substitute.For <IApiConnection>(); var client = new TeamsClient(connection); var newPermission = new RepositoryPermissionRequest(Permission.Admin); await client.AddRepository(1, "org", "repo", newPermission); connection.Connection.Received().Put <HttpStatusCode>( Arg.Is <Uri>(u => u.ToString() == "teams/1/repos/org/repo"), newPermission); }
/// <summary> /// Adds a <see cref="Repository"/> to a <see cref="Team"/>. /// </summary> /// <param name="id">The team identifier.</param> /// <param name="organization">Org to associate the repo with.</param> /// <param name="repoName">Name of the repo.</param> /// <param name="permission">The permission to grant the team on this repository.</param> /// <exception cref="ApiValidationException">Thrown if you attempt to add a repository to a team that is not owned by the organization.</exception> /// <remarks> /// See the <a href="https://developer.github.com/v3/orgs/teams/#add-team-repo">API documentation</a> for more information. /// </remarks> /// <returns><see langword="true"/> if the repository was added to the team; <see langword="false"/> otherwise.</returns> public IObservable<bool> AddRepository(int id, string organization, string repoName, RepositoryPermissionRequest permission) { Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); Ensure.ArgumentNotNullOrEmptyString(repoName, "repoName"); return _client.AddRepository(id, organization, repoName, permission).ToObservable(); }
/// <summary> /// Adds a <see cref="Repository"/> to a <see cref="Team"/>. /// </summary> /// <param name="id">The team identifier.</param> /// <param name="organization">Org to associate the repo with.</param> /// <param name="repoName">Name of the repo.</param> /// <param name="permission">The permission to grant the team on this repository.</param> /// <exception cref="ApiValidationException">Thrown if you attempt to add a repository to a team that is not owned by the organization.</exception> /// <remarks> /// See the <a href="https://developer.github.com/v3/orgs/teams/#add-team-repo">API documentation</a> for more information. /// </remarks> /// <returns><see langword="true"/> if the repository was added to the team; <see langword="false"/> otherwise.</returns> public IObservable <bool> AddRepository(int id, string organization, string repoName, RepositoryPermissionRequest permission) { Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization)); Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName)); return(_client.AddRepository(id, organization, repoName, permission).ToObservable()); }
public void AddOrUpdatePermission() { var connection = Substitute.For<IApiConnection>(); var client = new TeamsClient(connection); var newPermission = new RepositoryPermissionRequest(Permission.Admin); client.AddRepository(1, "org", "repo", newPermission); connection.Connection.Received().Put<HttpStatusCode>(Arg.Is<Uri>(u => u.ToString() == "teams/1/repos/org/repo"), Arg.Any<object>(), "", "application/vnd.github.ironman-preview+json"); }