public void EnsuresNonNullArguments()
            {
                var client = new RepoCollaboratorsClient(Substitute.For<IApiConnection>());

                Assert.Throws<ArgumentNullException>(() => client.GetAll(null,"test"));
                Assert.Throws<ArgumentException>(() => client.GetAll("", "test"));
                Assert.Throws<ArgumentNullException>(() => client.GetAll("owner", null));
                Assert.Throws<ArgumentException>(() => client.GetAll("owner", ""));
            }
示例#2
0
            public void EnsuresNonNullArguments()
            {
                var client = new RepoCollaboratorsClient(Substitute.For <IApiConnection>());

                Assert.Throws <ArgumentNullException>(() => client.GetAll(null, "test"));
                Assert.Throws <ArgumentException>(() => client.GetAll("", "test"));
                Assert.Throws <ArgumentNullException>(() => client.GetAll("owner", null));
                Assert.Throws <ArgumentException>(() => client.GetAll("owner", ""));
            }
            public void RequestsCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepoCollaboratorsClient(connection);

                client.GetAll("owner", "test");
                connection.Received().GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators"), null, "application/vnd.github.ironman-preview+json", Args.ApiOptions);
            }
示例#4
0
 public async Task <IEnumerable <User> > GetCollaboratorsForRepository(long repositoryId, GitHubClient gitHubClient)
 {
     if (_repoCollaboratorsClient == null)
     {
         _repoCollaboratorsClient = new RepoCollaboratorsClient(new ApiConnection(gitHubClient.Connection));
     }
     return(await _repoCollaboratorsClient.GetAll(repositoryId));
 }
示例#5
0
            public void RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepoCollaboratorsClient(connection);

                client.GetAll("owner", "test");
                connection.Received().GetAll <User>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/test/collaborators"));
            }
            public void RequestsCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepoCollaboratorsClient(connection);

                client.GetAll("owner", "test");
                connection.Received().GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators"));
            }
示例#7
0
            public void RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepoCollaboratorsClient(connection);

                client.GetAll("owner", "test");
                connection.Received().GetAll <User>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/test/collaborators"), null, "application/vnd.github.ironman-preview+json", Args.ApiOptions);
            }
            public void RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepoCollaboratorsClient(connection);

                client.GetAll(1);

                connection.Received().GetAll <User>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/collaborators"), Args.ApiOptions);
            }
            public void RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepoCollaboratorsClient(connection);

                client.GetAll(1);

                connection.Received().GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/collaborators"), Args.ApiOptions);
            }
示例#10
0
            public void RequestsCorrectUrlWithCollaboratorFilterAndRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepoCollaboratorsClient(connection);

                var request = new RepositoryCollaboratorListRequest();

                client.GetAll(1, request);

                connection.Received()
                .GetAll <User>(
                    Arg.Is <Uri>(u => u.ToString() == "repositories/1/collaborators"),
                    Arg.Is <Dictionary <string, string> >(d => d["affiliation"] == "all"),
                    "application/vnd.github.hellcat-preview+json",
                    Args.ApiOptions);

                request = new RepositoryCollaboratorListRequest
                {
                    Affiliation = CollaboratorAffiliation.Direct
                };

                client.GetAll(1, request);

                connection.Received()
                .GetAll <User>(
                    Arg.Is <Uri>(u => u.ToString() == "repositories/1/collaborators"),
                    Arg.Is <Dictionary <string, string> >(d => d["affiliation"] == "direct"),
                    "application/vnd.github.hellcat-preview+json",
                    Args.ApiOptions);

                request = new RepositoryCollaboratorListRequest
                {
                    Affiliation = CollaboratorAffiliation.Outside
                };

                client.GetAll(1, request);

                connection.Received()
                .GetAll <User>(
                    Arg.Is <Uri>(u => u.ToString() == "repositories/1/collaborators"),
                    Arg.Is <Dictionary <string, string> >(d => d["affiliation"] == "outside"),
                    "application/vnd.github.hellcat-preview+json",
                    Args.ApiOptions);
            }
示例#11
0
            public void RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepoCollaboratorsClient(connection);

                client.GetAll(1);

                connection.Received().GetAll <User>(
                    Arg.Is <Uri>(u => u.ToString() == "repositories/1/collaborators"),
                    Arg.Any <Dictionary <string, string> >(),
                    "application/vnd.github.hellcat-preview+json",
                    Args.ApiOptions);
            }
示例#12
0
            public void RequestsCorrectUrlWithCollaboratorFilter()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepoCollaboratorsClient(connection);

                var request = new RepositoryCollaboratorListRequest();

                client.GetAll("owner", "test", request);

                connection.Received()
                .GetAll <User>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/test/collaborators"),
                               Arg.Is <Dictionary <string, string> >(d => d["affiliation"] == "all"),
                               Args.ApiOptions);

                request = new RepositoryCollaboratorListRequest
                {
                    Affiliation = CollaboratorAffiliation.Direct
                };

                client.GetAll("owner", "test", request);

                connection.Received()
                .GetAll <User>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/test/collaborators"),
                               Arg.Is <Dictionary <string, string> >(d => d["affiliation"] == "direct"),
                               Args.ApiOptions);

                request = new RepositoryCollaboratorListRequest
                {
                    Affiliation = CollaboratorAffiliation.Outside
                };

                client.GetAll("owner", "test", request);

                connection.Received()
                .GetAll <User>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/test/collaborators"),
                               Arg.Is <Dictionary <string, string> >(d => d["affiliation"] == "outside"),
                               Args.ApiOptions);
            }
            public async Task EnsuresNonNullArguments()
            {
                var client = new RepoCollaboratorsClient(Substitute.For<IApiConnection>());

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "test"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "test"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", ""));

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "test", ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null, ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "test", null));
            }
示例#14
0
            public async Task EnsuresNonNullArguments()
            {
                var client = new RepoCollaboratorsClient(Substitute.For <IApiConnection>());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll(null, "test"));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("", "test"));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll("owner", null));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("owner", ""));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll(null, "test", ApiOptions.None));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll("owner", null, ApiOptions.None));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll("owner", "test", options: null));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll("owner", "test", request: null));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll(1, options: null));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll(1, request: null));
            }
            public void RequestsCorrectUrlWithApiOptionsAndRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepoCollaboratorsClient(connection);

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

                client.GetAll(1, options);

                connection.Received()
                .GetAll <User>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/collaborators"), options);
            }
            public void RequestsCorrectUrlWithApiOptionsAndRepositoryId()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepoCollaboratorsClient(connection);

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

                client.GetAll(1, options);

                connection.Received()
                    .GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/collaborators"), options);
            }
示例#17
0
            public void RequestsCorrectUrlWithApiOptions()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepoCollaboratorsClient(connection);

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

                client.GetAll("owner", "test", options);

                connection.Received()
                .GetAll <User>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/test/collaborators"),
                               Arg.Any <Dictionary <string, string> >(),
                               options);
            }