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); }
/// <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 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)); }
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 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 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("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"); }
/// <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(); }
/// <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(); }
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)); }
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); }