Example #1
0
    public Task <Repository> Fork(string owner, string name)
    {
        var apiConnection = new ApiConnection(client.Connection);
        var forkClient    = new RepositoryForksClient(apiConnection);

        return(forkClient.Create(owner, name, new NewRepositoryFork()));
    }
Example #2
0
 public async Task <Repository> ForkRepository(long repositoryId, GitHubClient authorizedGitHubClient)
 {
     if (_repositoryForksClient == null)
     {
         _repositoryForksClient = new RepositoryForksClient(new ApiConnection(authorizedGitHubClient.Connection));
     }
     return(await _repositoryForksClient.Create(repositoryId, new NewRepositoryFork()));
 }
Example #3
0
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryForksClient(connection);

                await client.GetAll("fake", "repo");

                connection.Received().GetAll <Repository>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/forks"), Args.ApiOptions);
            }
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryForksClient(connection);

                await client.GetAll("fake", "repo");

                connection.Received().GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/forks"), Args.ApiOptions);
            }
Example #5
0
            public void RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryForksClient(connection);

                var newRepositoryFork = new NewRepositoryFork();

                client.Create("fake", "repo", newRepositoryFork);

                connection.Received().Post <Repository>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/forks"), newRepositoryFork);
            }
            public async Task RequestsCorrectUrlWithRequestParameters()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryForksClient(connection);

                await client.GetAll("fake", "repo", new RepositoryForksListRequest { Sort = Sort.Stargazers });

                connection.Received().GetAll<Repository>(
                    Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/forks"),
                    Arg.Is<Dictionary<string, string>>(d => d["sort"] == "stargazers"), Args.ApiOptions);
            }
Example #7
0
            public async Task RequestsCorrectUrlWithRequestParameters()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryForksClient(connection);

                await client.GetAll("fake", "repo", new RepositoryForksListRequest { Sort = Sort.Stargazers });

                connection.Received().GetAll <Repository>(
                    Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/forks"),
                    Arg.Is <Dictionary <string, string> >(d => d["sort"] == "stargazers"), Args.ApiOptions);
            }
Example #8
0
            public async Task EnsuresNonNullArguments()
            {
                var client = new RepositoryForksClient(Substitute.For <IApiConnection>());

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("", "name", new RepositoryForksListRequest()));

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

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("", "name", new RepositoryForksListRequest(), ApiOptions.None));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("owner", "", new RepositoryForksListRequest(), ApiOptions.None));
            }
Example #9
0
            public async Task EnsuresNonNullArguments()
            {
                var client = new RepositoryForksClient(Substitute.For <IApiConnection>());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create(null, "name", new NewRepositoryFork()));

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

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

                await Assert.ThrowsAsync <ArgumentException>(() => client.Create("", "name", new NewRepositoryFork()));

                await Assert.ThrowsAsync <ArgumentException>(() => client.Create("owner", "", new NewRepositoryFork()));
            }
Example #10
0
            public async Task RequestsCorrectUrlWithApiOptions()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryForksClient(connection);

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

                await client.GetAll("fake", "repo", options);

                connection.Received().GetAll <Repository>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/forks"), options);
            }
            public async Task RequestsCorrectUrlWithApiOptions()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryForksClient(connection);

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

                await client.GetAll("fake", "repo", options);

                connection.Received().GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/forks"), options);
            }
Example #12
0
            public async Task RequestsCorrectUrlWithRepositoryIdWithRequestParametersWithApiOptions()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryForksClient(connection);

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

                await client.GetAll(1, new RepositoryForksListRequest { Sort = Sort.Stargazers }, options);

                connection.Received().GetAll <Repository>(
                    Arg.Is <Uri>(u => u.ToString() == "repositories/1/forks"),
                    Arg.Is <Dictionary <string, string> >(d => d["sort"] == "stargazers"), options);
            }
        /// <summary>
        /// Create a fork of the current repository
        /// </summary>
        private void ForkRepository()
        {
            var forkClient = new RepositoryForksClient(new ApiConnection(GithubClientService.GetAuthorizedGithubClient().Connection));

            forkClient.Create(Repository.Id, new NewRepositoryFork());
        }
            public void RequestsCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryForksClient(connection);

                var newRepositoryFork = new NewRepositoryFork();

                client.Create("fake", "repo", newRepositoryFork);

                connection.Received().Post<Repository>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/forks"), newRepositoryFork);
            }
            public async Task EnsuresNonNullArguments()
            {
                var client = new RepositoryForksClient(Substitute.For<IApiConnection>());

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

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

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, "name", new NewRepositoryFork()));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", null, new NewRepositoryFork()));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "name", null));

                await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", new NewRepositoryFork()));
                await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", new NewRepositoryFork()));
            }
            public async Task RequestsCorrectUrlWithRepositoryIdWithRequestParametersWithApiOptions()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryForksClient(connection);

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

                await client.GetAll(1, new RepositoryForksListRequest { Sort = Sort.Stargazers }, options);

                connection.Received().GetAll<Repository>(
                    Arg.Is<Uri>(u => u.ToString() == "repositories/1/forks"),
                    Arg.Is<Dictionary<string, string>>(d => d["sort"] == "stargazers"), options);
            }