コード例 #1
0
            public void PostsToTheCorrectUrl()
            {
                var orgMembershipUpdate = new OrganizationMembershipUpdate();

                var connection = Substitute.For <IApiConnection>();
                var client     = new OrganizationMembersClient(connection);

                client.AddOrUpdateOrganizationMembership("org", "username", orgMembershipUpdate);

                connection.Received().Put <OrganizationMembership>(Arg.Is <Uri>(u => u.ToString() == "orgs/org/memberships/username"), Arg.Any <object>());
            }
コード例 #2
0
            public void PostsToTheCorrectUrl()
            {
                var orgMembershipUpdate = new OrganizationMembershipUpdate();

                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableOrganizationMembersClient(gitHubClient);

                client.AddOrUpdateOrganizationMembership("org", "username", orgMembershipUpdate);

                gitHubClient.Organization.Member.Received().AddOrUpdateOrganizationMembership("org", "username", orgMembershipUpdate);
            }
コード例 #3
0
            public async Task EnsuresNonNullArguments()
            {
                var orgMembershipUpdate = new OrganizationMembershipUpdate();
                var client = new ObservableOrganizationMembersClient(Substitute.For <IGitHubClient>());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.AddOrUpdateOrganizationMembership(null, "username", orgMembershipUpdate).ToTask());

                await Assert.ThrowsAsync <ArgumentException>(() => client.AddOrUpdateOrganizationMembership("", "username", orgMembershipUpdate).ToTask());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.AddOrUpdateOrganizationMembership("org", null, orgMembershipUpdate).ToTask());

                await Assert.ThrowsAsync <ArgumentException>(() => client.AddOrUpdateOrganizationMembership("org", "", orgMembershipUpdate).ToTask());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.AddOrUpdateOrganizationMembership("org", "username", null).ToTask());
            }
コード例 #4
0
        /// <summary>
        /// Add a user to the organization or update the user's role withing the organization.
        /// </summary>
        /// <remarks>
        /// This method requires authentication.
        /// The authenticated user must be an organization owner.
        /// See the <a href="https://developer.github.com/v3/orgs/members/#add-or-update-organization-membership">API documentation</a>
        /// for more information.
        /// </remarks>
        /// <param name="org">The login for the organization</param>
        /// <param name="user">The login for the user</param>
        /// <param name="addOrUpdateRequest">An <see cref="OrganizationMembershipUpdate"/> instance describing the
        /// changes to make to the user's organization membership</param>
        /// <returns></returns>
        public IObservable <OrganizationMembership> AddOrUpdateOrganizationMembership(string org, string user, OrganizationMembershipUpdate addOrUpdateRequest)
        {
            Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
            Ensure.ArgumentNotNullOrEmptyString(user, nameof(user));
            Ensure.ArgumentNotNull(addOrUpdateRequest, nameof(addOrUpdateRequest));

            return(_client.AddOrUpdateOrganizationMembership(org, user, addOrUpdateRequest).ToObservable());
        }