public void CanSerialize()
        {
            var expected = "{\"name\":\"Hello-World\"," +
                           "\"description\":\"This is your first repository\"," +
                           "\"homepage\":\"https://github.com\"," +
                           "\"private\":true," +
                           "\"has_issues\":true," +
                           "\"has_wiki\":true," +
                           "\"has_downloads\":true}";

            var update = new RepositoryUpdate
            {
                Name = "Hello-World",
                Description = "This is your first repository",
                Homepage = "https://github.com",
                Private = true,
                HasIssues = true,
                HasWiki = true,
                HasDownloads = true
            };

            var json = new SimpleJsonSerializer().Serialize(update);

            Assert.Equal(expected, json);
        }
Esempio n. 2
0
        public async Task UpdatesHasIssues()
        {
            var github   = CreateGitHubClient();
            var repoName = Helper.MakeNameWithTimestamp("public-repo");

            _repository = await github.Repository.Create(new NewRepository { Name = repoName, AutoInit = true });

            var update = new RepositoryUpdate {
                Name = repoName, HasIssues = false
            };

            _repository = await github.Repository.Edit(Helper.UserName, repoName, update);

            Assert.Equal(false, _repository.HasIssues);
        }
        public async Task UpdatesHomepage()
        {
            var github   = CreateGitHubClient();
            var repoName = Helper.MakeNameWithTimestamp("public-repo");

            _repository = await github.Repository.Create(new NewRepository { Name = repoName, AutoInit = true });

            var update = new RepositoryUpdate {
                Name = repoName, Homepage = "http://aUrl.to/nowhere"
            };

            _repository = await github.Repository.Edit(Helper.UserName, repoName, update);

            Assert.Equal("http://aUrl.to/nowhere", _repository.Homepage);
        }
        public async Task UpdatesDescription()
        {
            var github   = CreateGitHubClient();
            var repoName = Helper.MakeNameWithTimestamp("public-repo");

            _repository = await github.Repository.Create(new NewRepository { Name = repoName, AutoInit = true });

            var update = new RepositoryUpdate {
                Name = repoName, Description = "Updated description"
            };

            _repository = await github.Repository.Edit(Helper.UserName, repoName, update);

            Assert.Equal("Updated description", _repository.Description);
        }
Esempio n. 5
0
            public async Task EnsuresArguments()
            {
                var github            = Substitute.For <IGitHubClient>();
                var nonreactiveClient = new RepositoriesClient(Substitute.For <IApiConnection>());

                github.Repository.Returns(nonreactiveClient);
                var client = new ObservableRepositoriesClient(github);
                var update = new RepositoryUpdate();

                Assert.Throws <ArgumentNullException>(() => client.Edit(null, "repo", update));
                Assert.Throws <ArgumentNullException>(() => client.Edit("owner", null, update));
                Assert.Throws <ArgumentNullException>(() => client.Edit("owner", "repo", null));
                Assert.Throws <ArgumentException>(() => client.Edit("", "repo", update));
                Assert.Throws <ArgumentException>(() => client.Edit("owner", "", update));
            }
Esempio n. 6
0
        public async Task UpdatesHasWiki()
        {
            var github   = Helper.GetAuthenticatedClient();
            var repoName = Helper.MakeNameWithTimestamp("public-repo");

            _repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true });

            var update = new RepositoryUpdate {
                Name = repoName, HasWiki = false
            };

            _repository = await github.Repository.Edit(Helper.UserName, repoName, update);

            Assert.Equal(false, _repository.HasWiki);
        }
            public async Task EnsuresNonNullArguments()
            {
                var client = new RepositoriesClient(Substitute.For <IApiConnection>());
                var update = new RepositoryUpdate();

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

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

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

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

                await Assert.ThrowsAsync <ArgumentException>(() => client.Edit("owner", "", update));
            }
Esempio n. 8
0
        public async Task UpdatesName()
        {
            var github   = Helper.GetAuthenticatedClient();
            var repoName = Helper.MakeNameWithTimestamp("public-repo");

            _repository = await github.Repository.Create(new NewRepository { Name = repoName, AutoInit = true });

            var updatedName = Helper.MakeNameWithTimestamp("updated-repo");
            var update      = new RepositoryUpdate {
                Name = updatedName
            };

            _repository = await github.Repository.Edit(Helper.UserName, repoName, update);

            Assert.Equal(update.Name, _repository.Name);
        }
Esempio n. 9
0
        public async Task <string> CreateAsync(string name)
        {
            var newRepo = new NewRepository(name)
            {
                AutoInit = true
            };

            var repository = await Client.Repository.Create(newRepo).ConfigureAwait(false);

            var newLabels =
                Configuration.repository.labels.Select(label => new NewLabel(label.name, label.color)).ToList();

            foreach (var newLabel in newLabels)
            {
                await Client.Issue.Labels.Create(repository.Owner.Login, repository.Name, newLabel).ConfigureAwait(false);
            }
            foreach (var branch in Configuration.repository.branches)
            {
                var master =
                    await
                    Client.GitDatabase.Reference.Get(repository.Owner.Login, repository.Name, "heads/master")
                    .ConfigureAwait(false);

                var reference        = new NewReference($"refs/heads/{branch.Name}", master.Object.Sha);
                var createdReference = await
                                       Client.GitDatabase.Reference.Create(repository.Owner.Login, repository.Name, reference)
                                       .ConfigureAwait(false);

                if (branch.IsDefault)
                {
                    var repositoryUpdate = new RepositoryUpdate();
                    repositoryUpdate.Name          = repository.Name;
                    repositoryUpdate.DefaultBranch = branch.Name;
                    await Client.Repository.Edit(repository.Owner.Login, repository.Name, repositoryUpdate).ConfigureAwait(false);
                }
            }

            return(repository.HtmlUrl);
        }
Esempio n. 10
0
        public async Task UpdatesPrivate()
        {
            var github = Helper.GetAuthenticatedClient();

            var userDetails = await github.User.Current();

            if (userDetails.Plan.PrivateRepos == 0)
            {
                throw new Exception("Test cannot complete, account is on free plan");
            }

            var repoName = Helper.MakeNameWithTimestamp("public-repo");

            _repository = await github.Repository.Create(new NewRepository { Name = repoName, AutoInit = true });

            var update = new RepositoryUpdate {
                Name = repoName, Private = true
            };

            _repository = await github.Repository.Edit(Helper.UserName, repoName, update);

            Assert.Equal(true, _repository.Private);
        }
Esempio n. 11
0
        public void CanSerialize()
        {
            var expected = "{\"name\":\"Hello-World\"," +
                           "\"description\":\"This is your first repository\"," +
                           "\"homepage\":\"https://github.com\"," +
                           "\"private\":true," +
                           "\"has_issues\":true," +
                           "\"has_wiki\":true," +
                           "\"has_downloads\":true}";

            var update = new RepositoryUpdate("Hello-World")
            {
                Description  = "This is your first repository",
                Homepage     = "https://github.com",
                Private      = true,
                HasIssues    = true,
                HasWiki      = true,
                HasDownloads = true
            };

            var json = new SimpleJsonSerializer().Serialize(update);

            Assert.Equal(expected, json);
        }
            public void PatchsTheCorrectUrlWithRepositoryId()
            {
                var github = Substitute.For<IGitHubClient>();
                var client = new ObservableRepositoriesClient(github);
                var update = new RepositoryUpdate();

                client.Edit(1, update);

                github.Repository.Received(1).Edit(1, update);
            }
Esempio n. 13
0
 private static async Task <StageStats> Update(params ModUpdate[] updates)
 {
     return(await RepositoryUpdate.Update(updates.ToList(), null));
 }
Esempio n. 14
0
 public async Task <Repository> UpdateRepository(long repositoryId, RepositoryUpdate updatedRepositoryDetails,
                                                 GitHubClient authorizedGitHubClient)
 {
     return(await _repoRepository.UpdateRepository(repositoryId, updatedRepositoryDetails, authorizedGitHubClient));
 }
            public async Task EnsuresNonNullArguments()
            {
                var client = new RepositoriesClient(Substitute.For<IApiConnection>());
                var update = new RepositoryUpdate();

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

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

                await Assert.ThrowsAsync<ArgumentException>(() => client.Edit("", "repo", update));
                await Assert.ThrowsAsync<ArgumentException>(() => client.Edit("owner", "", update));
            }
            public void PatchesCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);
                var update = new RepositoryUpdate();

                client.Edit(1, update);

                connection.Received()
                    .Patch<Repository>(Arg.Is<Uri>(u => u.ToString() == "repositories/1"), Arg.Any<RepositoryUpdate>());
            }
            public void PatchesCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);
                var update = new RepositoryUpdate("repo");

                client.Edit(1, update);

                connection.Received()
                    .Patch<Repository>(Arg.Is<Uri>(u => u.ToString() == "repositories/1"), Arg.Any<RepositoryUpdate>(), "application/vnd.github.polaris-preview+json");
            }
            public async Task EnsuresArguments()
            {
                var github = Substitute.For<IGitHubClient>();
                var nonreactiveClient = new RepositoriesClient(Substitute.For<IApiConnection>());
                github.Repository.Returns(nonreactiveClient);
                var client = new ObservableRepositoriesClient(github);
                var update = new RepositoryUpdate();

                Assert.Throws<ArgumentNullException>(() => client.Edit(null, "repo", update));
                Assert.Throws<ArgumentNullException>(() => client.Edit("owner", null, update));
                Assert.Throws<ArgumentNullException>(() => client.Edit("owner", "repo", null));
                Assert.Throws<ArgumentException>(() => client.Edit("", "repo", update));
                Assert.Throws<ArgumentException>(() => client.Edit("owner", "", update));
            }
 /// <summary>
 /// Updates the specified repository with the values given in <paramref name="update"/>
 /// </summary>
 /// <param name="owner">The owner of the repository</param>
 /// <param name="name">The name of the repository</param>
 /// <param name="update">New values to update the repository with</param>
 /// <returns>The updated <see cref="T:Octokit.Repository"/></returns>
 public IObservable<Repository> Edit(string owner, string name, RepositoryUpdate update)
 {
     return _client.Edit(owner, name, update).ToObservable();
 }
            public void CallsIntoClient()
            {
                var github = Substitute.For<IGitHubClient>();
                var client = new ObservableRepositoriesClient(github);
                var update = new RepositoryUpdate();

                client.Edit("owner", "repo", update);

                github.Repository.Received(1).Edit("owner", "repo", update);
            }
            public async Task EnsuresNonNullArguments()
            {
                var client = new ObservableRepositoriesClient(Substitute.For<IGitHubClient>());
                var update = new RepositoryUpdate();

                Assert.Throws<ArgumentNullException>(() => client.Edit(null, "repo", update));
                Assert.Throws<ArgumentNullException>(() => client.Edit("owner", null, update));
                Assert.Throws<ArgumentNullException>(() => client.Edit("owner", "repo", null));

                Assert.Throws<ArgumentNullException>(() => client.Edit(1, null));

                Assert.Throws<ArgumentException>(() => client.Edit("", "repo", update));
                Assert.Throws<ArgumentException>(() => client.Edit("owner", "", update));
            }
 /// <summary>
 /// Updates the specified repository with the values given in <paramref name="update"/>
 /// </summary>
 /// <param name="owner">The owner of the repository</param>
 /// <param name="name">The name of the repository</param>
 /// <param name="update">New values to update the repository with</param>
 /// <returns>The updated <see cref="T:Octokit.Repository"/></returns>
 public IObservable <Repository> Edit(string owner, string name, RepositoryUpdate update)
 {
     return(_client.Edit(owner, name, update).ToObservable());
 }
        /// <summary>
        /// Updates the specified repository with the values given in <paramref name="update"/>
        /// </summary>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="update">New values to update the repository with</param>
        /// <returns>The updated <see cref="T:Octokit.Repository"/></returns>
        public IObservable<Repository> Edit(string owner, string name, RepositoryUpdate update)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNull(update, "update");

            return _client.Edit(owner, name, update).ToObservable();
        }
Esempio n. 24
0
        /// <summary>
        /// Updates the specified repository with the values given in <paramref name="update"/>
        /// </summary>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="update">New values to update the repository with</param>
        /// <returns>The updated <see cref="T:Octokit.Repository"/></returns>
        public IObservable <Repository> Edit(long repositoryId, RepositoryUpdate update)
        {
            Ensure.ArgumentNotNull(update, nameof(update));

            return(_client.Edit(repositoryId, update).ToObservable());
        }
        /// <summary>
        /// Updates the specified repository with the values given in <paramref name="update"/>
        /// </summary>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="update">New values to update the repository with</param>
        /// <returns>The updated <see cref="T:Octokit.Repository"/></returns>
        public IObservable<Repository> Edit(long repositoryId, RepositoryUpdate update)
        {
            Ensure.ArgumentNotNull(update, "update");

            return _client.Edit(repositoryId, update).ToObservable();
        }