示例#1
0
            public void EnsuresArguments()
            {
                var client = new RepositoriesClient(Substitute.For <IApiConnection>());

                Assert.Throws <ArgumentNullException>(() => client.GetAllContributors(null, "repo"));
                Assert.Throws <ArgumentNullException>(() => client.GetAllContributors("owner", null));
                Assert.Throws <ArgumentException>(() => client.GetAllContributors("", "repo"));
                Assert.Throws <ArgumentException>(() => client.GetAllContributors("owner", ""));
            }
示例#2
0
 public async Task <IEnumerable <RepositoryContributor> > GetContributorsForRepository(long repositoryId, GitHubClient gitHubClient)
 {
     if (_repositoriesClient == null)
     {
         _repositoriesClient = new RepositoriesClient(new ApiConnection(gitHubClient.Connection));
     }
     return(await _repositoriesClient.GetAllContributors(repositoryId));
 }
示例#3
0
            public void GetsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoriesClient(connection);

                client.GetAllContributors("owner", "name");

                connection.Received()
                .GetAll <RepositoryContributor>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/name/contributors"), Arg.Any <IDictionary <string, string> >());
            }
示例#4
0
            public async Task RequestsTheCorrectUrlWithRepositoryIdIncludeAnonymous()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoriesClient(connection);

                await client.GetAllContributors(1, true);

                connection.Received()
                .GetAll <RepositoryContributor>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/contributors"), Arg.Is <IDictionary <string, string> >(d => d["anon"] == "1"), Args.ApiOptions);
            }
示例#5
0
            public async Task RequestsTheCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoriesClient(connection);

                await client.GetAllContributors("owner", "name");

                connection.Received()
                .GetAll <RepositoryContributor>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/name/contributors"), Arg.Any <IDictionary <string, string> >(), Args.ApiOptions);
            }
示例#6
0
            public async Task RequestsTheCorrectUrlWithApiOptionsIncludeAnonymous()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoriesClient(connection);

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

                await client.GetAllContributors("owner", "name", true, options);

                connection.Received()
                .GetAll <RepositoryContributor>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/name/contributors"), Arg.Is <IDictionary <string, string> >(d => d["anon"] == "1"), options);
            }
示例#7
0
            public void RequestsTheCorrectUrlWithRepositoryIdWithApiOptions()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoriesClient(connection);

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

                client.GetAllContributors(1, options);

                connection.Received()
                .GetAll <RepositoryContributor>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/contributors"), Arg.Any <IDictionary <string, string> >(), options);
            }
示例#8
0
            public async Task EnsuresNonNullArguments()
            {
                var client = new RepositoriesClient(Substitute.For <IApiConnection>());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContributors(null, "repo"));

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

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

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

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

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContributors(null, "repo", false, ApiOptions.None));

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

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

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContributors(1, null));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContributors(1, false, null));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllContributors("", "repo"));

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

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllContributors("", "repo", ApiOptions.None));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllContributors("owner", "", ApiOptions.None));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllContributors("", "repo", false, ApiOptions.None));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllContributors("owner", "", false, ApiOptions.None));
            }
            public async Task EnsuresNonNullArguments()
            {
                var client = new RepositoriesClient(Substitute.For<IApiConnection>());

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

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContributors(1, null));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContributors(1, false, null));

                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContributors("", "repo"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContributors("owner", ""));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContributors("", "repo", ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContributors("owner", "", ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContributors("", "repo", false, ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContributors("owner", "", false, ApiOptions.None));
            }
            public async Task RequestsTheCorrectUrlWithRepositoryIdWithApiOptionsIncludeAnonymous()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);

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

                await client.GetAllContributors(1, true, options);

                connection.Received()
                    .GetAll<RepositoryContributor>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/contributors"), Arg.Is<IDictionary<string, string>>(d => d["anon"] == "1"), options);
            }
            public async Task RequestsTheCorrectUrlIncludeAnonymous()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);

                await client.GetAllContributors("owner", "name", true);

                connection.Received()
                    .GetAll<RepositoryContributor>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/contributors"), Arg.Is<IDictionary<string, string>>(d => d["anon"] == "1"), Args.ApiOptions);
            }
            public void RequestsTheCorrectUrlWithRepositoryIdWithApiOptions()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);

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

                client.GetAllContributors(1, options);

                connection.Received()
                    .GetAll<RepositoryContributor>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/contributors"), Arg.Any<IDictionary<string, string>>(), options);
            }
            public async Task RequestsTheCorrectUrlWithApiOptions()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);

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

                await client.GetAllContributors("owner", "name", options);

                connection.Received()
                    .GetAll<RepositoryContributor>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/contributors"), Arg.Any<IDictionary<string, string>>(), options);
            }
            public async Task RequestsTheCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);

                await client.GetAllContributors(1);

                connection.Received()
                    .GetAll<RepositoryContributor>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/contributors"), Arg.Any<IDictionary<string, string>>(), Args.ApiOptions);
            }
示例#15
0
            public void GetsCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);

                client.GetAllContributors("owner", "name");

                connection.Received()
                    .GetAll<RepositoryContributor>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/contributors"), Arg.Any<IDictionary<string, string>>());
            }