Example #1
0
            public async Task ReturnsNoOutsideCollaborators()
            {
                var outsideCollaborators = await _client
                                           .GetAll(Helper.Organization).ToList();

                Assert.NotNull(outsideCollaborators);
                Assert.Empty(outsideCollaborators);
            }
            public async Task EnsuresNonNullArguments()
            {
                var client = new ObservableOrganizationOutsideCollaboratorsClient(Substitute.For <IGitHubClient>());


                Assert.Throws <ArgumentNullException>(() => client.GetAll(null));

                Assert.Throws <ArgumentNullException>(() => client.GetAll(null, OrganizationMembersFilter.All));

                Assert.Throws <ArgumentException>(() => client.GetAll(""));
                Assert.Throws <ArgumentException>(() => client.GetAll("", OrganizationMembersFilter.All));
            }
Example #3
0
            public async Task CanConvertOrgMemberToOutsideCollaborator()
            {
                var result = await _client.ConvertFromMember(Helper.Organization, _fixtureCollaborator);

                Assert.True(result);

                var outsideCollaborators = await _client
                                           .GetAll(Helper.Organization).ToList();

                Assert.Equal(1, outsideCollaborators.Count);
                Assert.Equal(_fixtureCollaborator, outsideCollaborators[0].Login);
            }
            public void TwoFactorFilterRequestsTheCorrectUrl()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableOrganizationOutsideCollaboratorsClient(gitHubClient);

                client.GetAll("org", OrganizationMembersFilter.TwoFactorAuthenticationDisabled);

                gitHubClient.Connection.Received(1).Get <List <User> >(
                    Arg.Is <Uri>(u => u.ToString() == "orgs/org/outside_collaborators?filter=2fa_disabled"),
                    null,
                    "application/vnd.github.korra-preview+json");
            }
            public void AllFilterRequestsTheCorrectUrl()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableOrganizationOutsideCollaboratorsClient(gitHubClient);

                client.GetAll("org", OrganizationMembersFilter.All);

                gitHubClient.Connection.Received(1).Get <List <User> >(
                    Arg.Is <Uri>(u => u.ToString() == "orgs/org/outside_collaborators?filter=all"),
                    Args.EmptyDictionary,
                    "application/vnd.github.korra-preview+json");
            }
Example #6
0
            public async Task CanRemoveOutsideCollaborator()
            {
                var repoName = Helper.MakeNameWithTimestamp("public-repo");

                using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName)))
                {
                    await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator);

                    var result = await _client.Delete(Helper.Organization, _fixtureCollaborator);

                    Assert.True(result);

                    var outsideCollaborators = await _client
                                               .GetAll(Helper.Organization).ToList();

                    Assert.Empty(outsideCollaborators);
                }
            }
            public void AllFilterRequestsTheCorrectUrlWithApiOptions()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableOrganizationOutsideCollaboratorsClient(gitHubClient);

                var options = new ApiOptions
                {
                    PageSize  = 1,
                    PageCount = 1,
                    StartPage = 1
                };

                client.GetAll("org", OrganizationMembersFilter.All, options);

                gitHubClient.Connection.Received(1).Get <List <User> >(
                    Arg.Is <Uri>(u => u.ToString() == "orgs/org/outside_collaborators?filter=all"),
                    Arg.Is <IDictionary <string, string> >(d => d.Count == 2),
                    "application/vnd.github.korra-preview+json");
            }