Esempio n. 1
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()));
            }
Esempio n. 2
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()));
    }
Esempio n. 3
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()));
 }
Esempio n. 4
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 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 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);
            }
        /// <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());
        }