diff --git a/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs
index 1ab8ab7b..110c0bd6 100644
--- a/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs
+++ b/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs
@@ -6,6 +6,9 @@ namespace Octokit.Reactive
///
/// Client for accessing contents of files within a repository as base64 encoded content.
///
+ ///
+ /// See the Repository Contents API documentation for more information.
+ ///
public interface IObservableRepositoryContentsClient
{
///
@@ -13,16 +16,26 @@ namespace Octokit.Reactive
///
/// The owner of the repository
/// The name of the repository
- ///
IObservable GetReadme(string owner, string name);
+ ///
+ /// Returns the HTML rendered README.
+ ///
+ /// The ID of the repository
+ IObservable GetReadme(int repositoryId);
+
///
/// Returns just the HTML portion of the README without the surrounding HTML document.
///
/// The owner of the repository
/// The name of the repository
- ///
IObservable GetReadmeHtml(string owner, string name);
+
+ ///
+ /// Returns just the HTML portion of the README without the surrounding HTML document.
+ ///
+ /// The ID of the repository
+ IObservable GetReadmeHtml(int repositoryId);
///
/// Get an archive of a given repository's contents
@@ -30,9 +43,15 @@ namespace Octokit.Reactive
/// https://developer.github.com/v3/repos/contents/#get-archive-link
/// The owner of the repository
/// The name of the repository
- /// A promise, containing the binary contents of the archive
IObservable GetArchive(string owner, string name);
+ ///
+ /// Get an archive of a given repository's contents
+ ///
+ /// https://developer.github.com/v3/repos/contents/#get-archive-link
+ /// The ID of the repository
+ IObservable GetArchive(int repositoryId);
+
///
/// Get an archive of a given repository's contents, in a specific format
///
@@ -40,9 +59,16 @@ namespace Octokit.Reactive
/// The owner of the repository
/// The name of the repository
/// The format of the archive. Can be either tarball or zipball
- /// A promise, containing the binary contents of the archive
IObservable GetArchive(string owner, string name, ArchiveFormat archiveFormat);
+ ///
+ /// Get an archive of a given repository's contents, in a specific format
+ ///
+ /// https://developer.github.com/v3/repos/contents/#get-archive-link
+ /// The ID of the repository
+ /// The format of the archive. Can be either tarball or zipball
+ IObservable GetArchive(int repositoryId, ArchiveFormat archiveFormat);
+
///
/// Get an archive of a given repository's contents, using a specific format and reference
///
@@ -51,9 +77,17 @@ namespace Octokit.Reactive
/// The name of the repository
/// The format of the archive. Can be either tarball or zipball
/// A valid Git reference.
- /// A promise, containing the binary contents of the archive
IObservable GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference);
+ ///
+ /// Get an archive of a given repository's contents, using a specific format and reference
+ ///
+ /// https://developer.github.com/v3/repos/contents/#get-archive-link
+ /// The ID of the repository
+ /// The format of the archive. Can be either tarball or zipball
+ /// A valid Git reference.
+ IObservable GetArchive(int repositoryId, ArchiveFormat archiveFormat, string reference);
+
///
/// Get an archive of a given repository's contents, in a specific format
///
@@ -63,9 +97,18 @@ namespace Octokit.Reactive
/// The format of the archive. Can be either tarball or zipball
/// A valid Git reference.
/// Time span until timeout
- /// The binary contents of the archive
IObservable GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference, TimeSpan timeout);
+ ///
+ /// Get an archive of a given repository's contents, in a specific format
+ ///
+ /// https://developer.github.com/v3/repos/contents/#get-archive-link
+ /// The ID of the repository
+ /// The format of the archive. Can be either tarball or zipball
+ /// A valid Git reference.
+ /// Time span until timeout
+ IObservable GetArchive(int repositoryId, ArchiveFormat archiveFormat, string reference, TimeSpan timeout);
+
///
/// Returns the contents of a file or directory in a repository.
///
@@ -75,21 +118,31 @@ namespace Octokit.Reactive
/// The owner of the repository
/// The name of the repository
/// The content path
- ///
- /// A collection of representing the content at the specified path
- ///
IObservable GetAllContents(string owner, string name, string path);
+ ///
+ /// Returns the contents of a file or directory in a repository.
+ ///
+ ///
+ /// If given a path to a single file, this method returns a collection containing only that file.
+ ///
+ /// The ID of the repository
+ /// The content path
+ IObservable GetAllContents(int repositoryId, string path);
+
///
/// Returns the contents of the root directory in a repository.
///
/// The owner of the repository
/// The name of the repository
- ///
- /// A collection of representing the content at the specified path
- ///
IObservable GetAllContents(string owner, string name);
+ ///
+ /// Returns the contents of the root directory in a repository.
+ ///
+ /// The ID of the repository
+ IObservable GetAllContents(int repositoryId);
+
///
/// Returns the contents of a file or directory in a repository.
///
@@ -101,23 +154,35 @@ namespace Octokit.Reactive
/// The name of the repository
/// The name of the commit/branch/tag. Default: the repository’s default branch (usually master)
/// The content path
- ///
- /// A collection of representing the content at the specified path
- ///
IObservable GetAllContentsByRef(string owner, string name, string reference, string path);
-
+ ///
+ /// Returns the contents of a file or directory in a repository.
+ ///
+ ///
+ /// If given a path to a single file, this method returns a collection containing only that file.
+ /// See the API documentation for more information.
+ ///
+ /// The ID of the repository
+ /// The name of the commit/branch/tag. Default: the repository’s default branch (usually master)
+ /// The content path
+ IObservable GetAllContentsByRef(int repositoryId, string reference, string path);
+
///
/// Returns the contents of the home directory in a repository.
///
/// The owner of the repository
/// The name of the repository
/// The name of the commit/branch/tag. Default: the repository’s default branch (usually master)
- ///
- /// A collection of representing the content at the specified path
- ///
IObservable GetAllContentsByRef(string owner, string name, string reference);
+ ///
+ /// Returns the contents of the home directory in a repository.
+ ///
+ /// The ID of the repository
+ /// The name of the commit/branch/tag. Default: the repository’s default branch (usually master)
+ IObservable GetAllContentsByRef(int repositoryId, string reference);
+
///
/// Creates a commit that creates a new file in a repository.
///
@@ -125,9 +190,16 @@ namespace Octokit.Reactive
/// The name of the repository
/// The path to the file
/// Information about the file to create
- ///
IObservable CreateFile(string owner, string name, string path, CreateFileRequest request);
+ ///
+ /// Creates a commit that creates a new file in a repository.
+ ///
+ /// The ID of the repository
+ /// The path to the file
+ /// Information about the file to create
+ IObservable CreateFile(int repositoryId, string path, CreateFileRequest request);
+
///
/// Creates a commit that updates the contents of a file in a repository.
///
@@ -135,9 +207,16 @@ namespace Octokit.Reactive
/// The name of the repository
/// The path to the file
/// Information about the file to update
- /// The updated content
IObservable UpdateFile(string owner, string name, string path, UpdateFileRequest request);
+ ///
+ /// Creates a commit that updates the contents of a file in a repository.
+ ///
+ /// The ID of the repository
+ /// The path to the file
+ /// Information about the file to update
+ IObservable UpdateFile(int repositoryId, string path, UpdateFileRequest request);
+
///
/// Creates a commit that deletes a file in a repository.
///
@@ -146,5 +225,13 @@ namespace Octokit.Reactive
/// The path to the file
/// Information about the file to delete
IObservable DeleteFile(string owner, string name, string path, DeleteFileRequest request);
+
+ ///
+ /// Creates a commit that deletes a file in a repository.
+ ///
+ /// The ID of the repository
+ /// The path to the file
+ /// Information about the file to delete
+ IObservable DeleteFile(int repositoryId, string path, DeleteFileRequest request);
}
}
\ No newline at end of file
diff --git a/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs
index 456ce31b..71625ead 100644
--- a/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs
+++ b/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs
@@ -1,4 +1,5 @@
using System;
+using System.Reactive;
using System.Reactive.Threading.Tasks;
using Octokit.Reactive.Internal;
@@ -7,6 +8,9 @@ namespace Octokit.Reactive
///
/// Client for accessing contents of files within a repository as base64 encoded content.
///
+ ///
+ /// See the Repository Contents API documentation for more information.
+ ///
public class ObservableRepositoryContentsClient : IObservableRepositoryContentsClient
{
readonly IGitHubClient _client;
@@ -17,6 +21,8 @@ namespace Octokit.Reactive
///
public ObservableRepositoryContentsClient(IGitHubClient client)
{
+ Ensure.ArgumentNotNull(client, "client");
+
_client = client;
}
@@ -25,7 +31,6 @@ namespace Octokit.Reactive
///
/// The owner of the repository
/// The name of the repository
- ///
public IObservable GetReadme(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -34,12 +39,20 @@ namespace Octokit.Reactive
return _client.Repository.Content.GetReadme(owner, name).ToObservable();
}
+ ///
+ /// Returns the HTML rendered README.
+ ///
+ /// The ID of the repository
+ public IObservable GetReadme(int repositoryId)
+ {
+ return _client.Repository.Content.GetReadme(repositoryId).ToObservable();
+ }
+
///
/// Returns just the HTML portion of the README without the surrounding HTML document.
///
/// The owner of the repository
/// The name of the repository
- ///
public IObservable GetReadmeHtml(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -48,18 +61,39 @@ namespace Octokit.Reactive
return _client.Repository.Content.GetReadmeHtml(owner, name).ToObservable();
}
+ ///
+ /// Returns just the HTML portion of the README without the surrounding HTML document.
+ ///
+ /// The ID of the repository
+ public IObservable GetReadmeHtml(int repositoryId)
+ {
+ return _client.Repository.Content.GetReadmeHtml(repositoryId).ToObservable();
+ }
+
///
/// Get an archive of a given repository's contents
///
/// https://developer.github.com/v3/repos/contents/#get-archive-link
/// The owner of the repository
/// The name of the repository
- /// A promise, containing the binary contents of the archive
public IObservable GetArchive(string owner, string name)
{
+ Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
+ Ensure.ArgumentNotNullOrEmptyString(name, "name");
+
return GetArchive(owner, name, ArchiveFormat.Tarball);
}
+ ///
+ /// Get an archive of a given repository's contents
+ ///
+ /// https://developer.github.com/v3/repos/contents/#get-archive-link
+ /// The ID of the repository
+ public IObservable GetArchive(int repositoryId)
+ {
+ return GetArchive(repositoryId, ArchiveFormat.Tarball);
+ }
+
///
/// Get an archive of a given repository's contents, in a specific format
///
@@ -67,12 +101,25 @@ namespace Octokit.Reactive
/// The owner of the repository
/// The name of the repository
/// The format of the archive. Can be either tarball or zipball
- /// A promise, containing the binary contents of the archive
public IObservable GetArchive(string owner, string name, ArchiveFormat archiveFormat)
{
+ Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
+ Ensure.ArgumentNotNullOrEmptyString(name, "name");
+
return GetArchive(owner, name, archiveFormat, string.Empty);
}
+ ///
+ /// Get an archive of a given repository's contents, in a specific format
+ ///
+ /// https://developer.github.com/v3/repos/contents/#get-archive-link
+ /// The ID of the repository
+ /// The format of the archive. Can be either tarball or zipball
+ public IObservable GetArchive(int repositoryId, ArchiveFormat archiveFormat)
+ {
+ return GetArchive(repositoryId, archiveFormat, string.Empty);
+ }
+
///
/// Get an archive of a given repository's contents, using a specific format and reference
///
@@ -81,12 +128,64 @@ namespace Octokit.Reactive
/// The name of the repository
/// The format of the archive. Can be either tarball or zipball
/// A valid Git reference.
- /// A promise, containing the binary contents of the archive
public IObservable GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference)
{
+ Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
+ Ensure.ArgumentNotNullOrEmptyString(name, "name");
+ Ensure.ArgumentNotNull(reference, "reference");
+
return GetArchive(owner, name, archiveFormat, reference, TimeSpan.FromMinutes(60));
}
+ ///
+ /// Get an archive of a given repository's contents, using a specific format and reference
+ ///
+ /// https://developer.github.com/v3/repos/contents/#get-archive-link
+ /// The ID of the repository
+ /// The format of the archive. Can be either tarball or zipball
+ /// A valid Git reference.
+ public IObservable GetArchive(int repositoryId, ArchiveFormat archiveFormat, string reference)
+ {
+ Ensure.ArgumentNotNull(reference, "reference");
+
+ return GetArchive(repositoryId, archiveFormat, reference, TimeSpan.FromMinutes(60));
+ }
+
+ ///
+ /// Get an archive of a given repository's contents, in a specific format
+ ///
+ /// https://developer.github.com/v3/repos/contents/#get-archive-link
+ /// The owner of the repository
+ /// The name of the repository
+ /// The format of the archive. Can be either tarball or zipball
+ /// A valid Git reference.
+ /// Time span until timeout
+ public IObservable GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference, TimeSpan timeout)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
+ Ensure.ArgumentNotNullOrEmptyString(name, "name");
+ Ensure.ArgumentNotNull(reference, "reference");
+ Ensure.GreaterThanZero(timeout, "timeout");
+
+ return _client.Repository.Content.GetArchive(owner, name, archiveFormat, reference, timeout).ToObservable();
+ }
+
+ ///
+ /// Get an archive of a given repository's contents, in a specific format
+ ///
+ /// https://developer.github.com/v3/repos/contents/#get-archive-link
+ /// The ID of the repository
+ /// The format of the archive. Can be either tarball or zipball
+ /// A valid Git reference.
+ /// Time span until timeout
+ public IObservable GetArchive(int repositoryId, ArchiveFormat archiveFormat, string reference, TimeSpan timeout)
+ {
+ Ensure.GreaterThanZero(timeout, "timeout");
+ Ensure.ArgumentNotNull(reference, "reference");
+
+ return _client.Repository.Content.GetArchive(repositoryId, archiveFormat, reference, timeout).ToObservable();
+ }
+
///
/// Returns the contents of a file or directory in a repository.
///
@@ -96,9 +195,6 @@ namespace Octokit.Reactive
/// The owner of the repository
/// The name of the repository
/// The content path
- ///
- /// A collection of representing the content at the specified path
- ///
public IObservable GetAllContents(string owner, string name, string path)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -111,22 +207,20 @@ namespace Octokit.Reactive
}
///
- /// Get an archive of a given repository's contents, in a specific format
+ /// Returns the contents of a file or directory in a repository.
///
- /// https://developer.github.com/v3/repos/contents/#get-archive-link
- /// The owner of the repository
- /// The name of the repository
- /// The format of the archive. Can be either tarball or zipball
- /// A valid Git reference.
- /// Time span until timeout
- /// The binary contents of the archive
- public IObservable GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference, TimeSpan timeout)
+ ///
+ /// If given a path to a single file, this method returns a collection containing only that file.
+ ///
+ /// The ID of the repository
+ /// The content path
+ public IObservable GetAllContents(int repositoryId, string path)
{
- Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
- Ensure.ArgumentNotNullOrEmptyString(name, "name");
- Ensure.GreaterThanZero(timeout, "timeout");
+ Ensure.ArgumentNotNullOrEmptyString(path, "path");
- return _client.Repository.Content.GetArchive(owner, name, archiveFormat, reference, timeout).ToObservable();
+ return _client
+ .Connection
+ .GetAndFlattenAllPages(ApiUrls.RepositoryContent(repositoryId, path));
}
///
@@ -134,9 +228,6 @@ namespace Octokit.Reactive
///
/// The owner of the repository
/// The name of the repository
- ///
- /// A collection of representing the content at the specified path
- ///
public IObservable GetAllContents(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -147,6 +238,17 @@ namespace Octokit.Reactive
.GetAndFlattenAllPages(ApiUrls.RepositoryContent(owner, name, string.Empty));
}
+ ///
+ /// Returns the contents of the root directory in a repository.
+ ///
+ /// The ID of the repository
+ public IObservable GetAllContents(int repositoryId)
+ {
+ return _client
+ .Connection
+ .GetAndFlattenAllPages(ApiUrls.RepositoryContent(repositoryId, string.Empty));
+ }
+
///
/// Returns the contents of a file or directory in a repository.
///
@@ -158,9 +260,6 @@ namespace Octokit.Reactive
/// The name of the repository
/// The name of the commit/branch/tag. Default: the repository’s default branch (usually master)
/// The content path
- ///
- /// A collection of representing the content at the specified path
- ///
public IObservable GetAllContentsByRef(string owner, string name, string reference, string path)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -171,15 +270,30 @@ namespace Octokit.Reactive
return _client.Connection.GetAndFlattenAllPages(ApiUrls.RepositoryContent(owner, name, path, reference));
}
+ ///
+ /// Returns the contents of a file or directory in a repository.
+ ///
+ ///
+ /// If given a path to a single file, this method returns a collection containing only that file.
+ /// See the API documentation for more information.
+ ///
+ /// The ID of the repository
+ /// The name of the commit/branch/tag. Default: the repository’s default branch (usually master)
+ /// The content path
+ public IObservable GetAllContentsByRef(int repositoryId, string reference, string path)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
+ Ensure.ArgumentNotNullOrEmptyString(path, "path");
+
+ return _client.Connection.GetAndFlattenAllPages(ApiUrls.RepositoryContent(repositoryId, path, reference));
+ }
+
///
/// Returns the contents of the home directory in a repository.
///
/// The owner of the repository
/// The name of the repository
/// The name of the commit/branch/tag. Default: the repository’s default branch (usually master)
- ///
- /// A collection of representing the content at the specified path
- ///
public IObservable GetAllContentsByRef(string owner, string name, string reference)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -189,6 +303,18 @@ namespace Octokit.Reactive
return _client.Connection.GetAndFlattenAllPages(ApiUrls.RepositoryContent(owner, name, string.Empty, reference));
}
+ ///
+ /// Returns the contents of the home directory in a repository.
+ ///
+ /// The ID of the repository
+ /// The name of the commit/branch/tag. Default: the repository’s default branch (usually master)
+ public IObservable GetAllContentsByRef(int repositoryId, string reference)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
+
+ return _client.Connection.GetAndFlattenAllPages(ApiUrls.RepositoryContent(repositoryId, string.Empty, reference));
+ }
+
///
/// Creates a commit that creates a new file in a repository.
///
@@ -196,7 +322,6 @@ namespace Octokit.Reactive
/// The name of the repository
/// The path to the file
/// Information about the file to create
- ///
public IObservable CreateFile(string owner, string name, string path, CreateFileRequest request)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -207,6 +332,20 @@ namespace Octokit.Reactive
return _client.Repository.Content.CreateFile(owner, name, path, request).ToObservable();
}
+ ///
+ /// Creates a commit that creates a new file in a repository.
+ ///
+ /// The ID of the repository
+ /// The path to the file
+ /// Information about the file to create
+ public IObservable CreateFile(int repositoryId, string path, CreateFileRequest request)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(path, "path");
+ Ensure.ArgumentNotNull(request, "request");
+
+ return _client.Repository.Content.CreateFile(repositoryId, path, request).ToObservable();
+ }
+
///
/// Creates a commit that updates the contents of a file in a repository.
///
@@ -214,7 +353,6 @@ namespace Octokit.Reactive
/// The name of the repository
/// The path to the file
/// Information about the file to update
- /// The updated content
public IObservable UpdateFile(string owner, string name, string path, UpdateFileRequest request)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -225,7 +363,28 @@ namespace Octokit.Reactive
return _client.Repository.Content.UpdateFile(owner, name, path, request).ToObservable();
}
- public IObservable DeleteFile(string owner, string name, string path, DeleteFileRequest request)
+ ///
+ /// Creates a commit that updates the contents of a file in a repository.
+ ///
+ /// The ID of the repository
+ /// The path to the file
+ /// Information about the file to update
+ public IObservable UpdateFile(int repositoryId, string path, UpdateFileRequest request)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(path, "path");
+ Ensure.ArgumentNotNull(request, "request");
+
+ return _client.Repository.Content.UpdateFile(repositoryId, path, request).ToObservable();
+ }
+
+ ///
+ /// Creates a commit that deletes a file in a repository.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The path to the file
+ /// Information about the file to delete
+ public IObservable DeleteFile(string owner, string name, string path, DeleteFileRequest request)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
@@ -234,5 +393,19 @@ namespace Octokit.Reactive
return _client.Repository.Content.DeleteFile(owner, name, path, request).ToObservable();
}
+
+ ///
+ /// Creates a commit that deletes a file in a repository.
+ ///
+ /// The ID of the repository
+ /// The path to the file
+ /// Information about the file to delete
+ public IObservable DeleteFile(int repositoryId, string path, DeleteFileRequest request)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(path, "path");
+ Ensure.ArgumentNotNull(request, "request");
+
+ return _client.Repository.Content.DeleteFile(repositoryId, path, request).ToObservable();
+ }
}
}
diff --git a/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs
index 91a7716f..2cc8cf70 100644
--- a/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs
@@ -23,6 +23,19 @@ namespace Octokit.Tests.Integration.Clients
Assert.Contains("Octokit - GitHub API Client Library for .NET", readMeHtml);
}
+ [IntegrationTest]
+ public async Task ReturnsReadmeForSeeGitWithRepositoryId()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var readme = await github.Repository.Content.GetReadme(7528679);
+ Assert.Equal("README.md", readme.Name);
+ string readMeHtml = await readme.GetHtmlContent();
+ Assert.True(readMeHtml.StartsWith("
2);
Assert.Equal(ContentType.Dir, contents.First().Type);
}
+
+ [IntegrationTest]
+ public async Task GetsDirectoryContentWithRepositoryId()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var contents = await github
+ .Repository
+ .Content
+ .GetAllContents(7528679, "Octokit");
+
+ Assert.True(contents.Count > 2);
+ Assert.Equal(ContentType.Dir, contents.First().Type);
+ }
+
+ [IntegrationTest]
+ public async Task GetsFileContentWholeRepo()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var contents = await github
+ .Repository
+ .Content
+ .GetAllContents("octocat", "Spoon-Knife");
+
+ Assert.Equal(3, contents.Count);
+ Assert.Equal(ContentType.File, contents.First().Type);
+ Assert.Equal(new Uri("https://github.com/octocat/Spoon-Knife/blob/master/README.md"), contents.First().HtmlUrl);
+ }
+
+ [IntegrationTest]
+ public async Task GetsFileContentWholeRepoWithRepositoryId()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var contents = await github
+ .Repository
+ .Content
+ .GetAllContents(1300192);
+
+ Assert.Equal(3, contents.Count);
+ Assert.Equal(ContentType.File, contents.First().Type);
+ Assert.Equal(new Uri("https://github.com/octocat/Spoon-Knife/blob/master/README.md"), contents.First().HtmlUrl);
+ }
+
+ [IntegrationTest]
+ public async Task GetsDirectoryContentWholeRepo()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var contents = await github
+ .Repository
+ .Content
+ .GetAllContents("octocat", "octocat.github.io");
+
+ Assert.NotEmpty(contents);
+ }
+
+ [IntegrationTest]
+ public async Task GetsDirectoryContentWholeRepoWithRepositoryId()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var contents = await github
+ .Repository
+ .Content
+ .GetAllContents(17881631);
+
+ Assert.NotEmpty(contents);
+ }
+ }
+
+ public class TheGetContentsByRefMethod
+ {
+ [IntegrationTest]
+ public async Task GetsFileContent()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var contents = await github
+ .Repository
+ .Content
+ .GetAllContentsByRef("octokit", "octokit.net", "Octokit.Reactive/ObservableGitHubClient.cs", "master");
+
+ Assert.Equal(1, contents.Count);
+ Assert.Equal(ContentType.File, contents.First().Type);
+ Assert.Equal(new Uri("https://github.com/octokit/octokit.net/blob/master/Octokit.Reactive/ObservableGitHubClient.cs"), contents.First().HtmlUrl);
+ }
+
+ [IntegrationTest]
+ public async Task GetsFileContentWithRepositoryId()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var contents = await github
+ .Repository
+ .Content
+ .GetAllContentsByRef(7528679, "Octokit.Reactive/ObservableGitHubClient.cs", "master");
+
+ Assert.Equal(1, contents.Count);
+ Assert.Equal(ContentType.File, contents.First().Type);
+ Assert.Equal(new Uri("https://github.com/octokit/octokit.net/blob/master/Octokit.Reactive/ObservableGitHubClient.cs"), contents.First().HtmlUrl);
+ }
+
+ [IntegrationTest]
+ public async Task GetsDirectoryContent()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var contents = await github
+ .Repository
+ .Content
+ .GetAllContentsByRef("octokit", "octokit.net", "Octokit", "master");
+
+ Assert.True(contents.Count > 2);
+ Assert.Equal(ContentType.Dir, contents.First().Type);
+ }
+
+ [IntegrationTest]
+ public async Task GetsDirectoryContentWithRepositoryId()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var contents = await github
+ .Repository
+ .Content
+ .GetAllContentsByRef(7528679, "Octokit", "master");
+
+ Assert.True(contents.Count > 2);
+ Assert.Equal(ContentType.Dir, contents.First().Type);
+ }
+
+ [IntegrationTest]
+ public async Task GetsFileContentWholeRepo()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var contents = await github
+ .Repository
+ .Content
+ .GetAllContentsByRef("octocat", "Spoon-Knife", "master");
+
+ Assert.Equal(3, contents.Count);
+ Assert.Equal(ContentType.File, contents.First().Type);
+ Assert.Equal(new Uri("https://github.com/octocat/Spoon-Knife/blob/master/README.md"), contents.First().HtmlUrl);
+ }
+
+ [IntegrationTest]
+ public async Task GetsFileContentWholeRepoWithRepositoryId()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var contents = await github
+ .Repository
+ .Content
+ .GetAllContentsByRef(1300192, "master");
+
+ Assert.Equal(3, contents.Count);
+ Assert.Equal(ContentType.File, contents.First().Type);
+ Assert.Equal(new Uri("https://github.com/octocat/Spoon-Knife/blob/master/README.md"), contents.First().HtmlUrl);
+ }
+
+ [IntegrationTest]
+ public async Task GetsDirectoryContentWholeRepo()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var contents = await github
+ .Repository
+ .Content
+ .GetAllContentsByRef("octocat", "octocat.github.io", "master");
+
+ Assert.NotEmpty(contents);
+ }
+
+ [IntegrationTest]
+ public async Task GetsDirectoryContentWholeRepoWithRepositoryId()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var contents = await github
+ .Repository
+ .Content
+ .GetAllContentsByRef(17881631, "master");
+
+ Assert.NotEmpty(contents);
+ }
}
[IntegrationTest]
@@ -111,6 +337,47 @@ namespace Octokit.Tests.Integration.Clients
}
}
+ [IntegrationTest]
+ public async Task CrudTestWithRepositoryId()
+ {
+ var client = Helper.GetAuthenticatedClient();
+ var fixture = client.Repository.Content;
+ var repoName = Helper.MakeNameWithTimestamp("source-repo");
+
+ using (var context = await client.CreateRepositoryContext(new NewRepository(repoName) { AutoInit = true }))
+ {
+ var repository = context.Repository;
+
+ var file = await fixture.CreateFile(
+ repository.Id,
+ "somefile.txt",
+ new CreateFileRequest("Test commit", "Some Content"));
+ Assert.Equal("somefile.txt", file.Content.Name);
+
+ var contents = await fixture.GetAllContents(repository.Owner.Login, repository.Name, "somefile.txt");
+ string fileSha = contents.First().Sha;
+ Assert.Equal("Some Content", contents.First().Content);
+
+ var update = await fixture.UpdateFile(
+ repository.Id,
+ "somefile.txt",
+ new UpdateFileRequest("Updating file", "New Content", fileSha));
+ Assert.Equal("somefile.txt", update.Content.Name);
+
+ contents = await fixture.GetAllContents(repository.Owner.Login, repository.Name, "somefile.txt");
+ Assert.Equal("New Content", contents.First().Content);
+ fileSha = contents.First().Sha;
+
+ await fixture.DeleteFile(
+ repository.Id,
+ "somefile.txt",
+ new DeleteFileRequest("Deleted file", fileSha));
+
+ await Assert.ThrowsAsync(
+ () => fixture.GetAllContents(repository.Owner.Login, repository.Name, "somefile.txt"));
+ }
+ }
+
[IntegrationTest]
public async Task CrudTestWithNamedBranch()
{
@@ -158,43 +425,155 @@ namespace Octokit.Tests.Integration.Clients
}
}
- [IntegrationTest(Skip = "this will probably take too long")]
- public async Task GetsArchiveAsTarball()
+ [IntegrationTest]
+ public async Task CrudTestWithNamedBranchWithRepositoryId()
{
- var github = Helper.GetAuthenticatedClient();
+ var client = Helper.GetAuthenticatedClient();
+ var fixture = client.Repository.Content;
+ var repoName = Helper.MakeNameWithTimestamp("source-repo");
+ var branchName = "other-branch";
- var archive = await github
- .Repository
- .Content
- .GetArchive("octokit", "octokit.net");
+ using (var context = await client.CreateRepositoryContext(new NewRepository(repoName) { AutoInit = true }))
+ {
+ var repository = context.Repository;
- Assert.NotEmpty(archive);
+ var master = await client.Git.Reference.Get(Helper.UserName, repository.Name, "heads/master");
+ await client.Git.Reference.Create(Helper.UserName, repository.Name, new NewReference("refs/heads/" + branchName, master.Object.Sha));
+ var file = await fixture.CreateFile(
+ repository.Id,
+ "somefile.txt",
+ new CreateFileRequest("Test commit", "Some Content", branchName));
+ Assert.Equal("somefile.txt", file.Content.Name);
+
+ var contents = await fixture.GetAllContentsByRef(repository.Owner.Login, repository.Name, "somefile.txt", branchName);
+ string fileSha = contents.First().Sha;
+ Assert.Equal("Some Content", contents.First().Content);
+
+ var update = await fixture.UpdateFile(
+ repository.Id,
+ "somefile.txt",
+ new UpdateFileRequest("Updating file", "New Content", fileSha, branchName));
+ Assert.Equal("somefile.txt", update.Content.Name);
+
+ contents = await fixture.GetAllContentsByRef(repository.Owner.Login, repository.Name, "somefile.txt", branchName);
+ Assert.Equal("New Content", contents.First().Content);
+ fileSha = contents.First().Sha;
+
+ await fixture.DeleteFile(
+ repository.Id,
+ "somefile.txt",
+ new DeleteFileRequest("Deleted file", fileSha, branchName));
+
+ await Assert.ThrowsAsync(
+ () => fixture.GetAllContents(repository.Owner.Login, repository.Name, "somefile.txt"));
+ }
}
- [IntegrationTest]
- public async Task GetsArchiveAsZipball()
+ public class TheGetArchiveMethod
{
- var github = Helper.GetAuthenticatedClient();
+ [IntegrationTest(Skip = "this will probably take too long")]
+ public async Task GetsArchiveAsTarball()
+ {
+ var github = Helper.GetAuthenticatedClient();
- var archive = await github
- .Repository
- .Content
- .GetArchive("shiftkey", "reactivegit", ArchiveFormat.Zipball);
+ var archive = await github
+ .Repository
+ .Content
+ .GetArchive("octokit", "octokit.net");
- Assert.NotEmpty(archive);
- }
+ Assert.NotEmpty(archive);
+ }
- [IntegrationTest]
- public async Task GetsArchiveForReleaseBranchAsTarball()
- {
- var github = Helper.GetAuthenticatedClient();
+ [IntegrationTest]
+ public async Task GetsArchiveAsTarballWithRepositoryId()
+ {
+ var github = Helper.GetAuthenticatedClient();
- var archive = await github
- .Repository
- .Content
- .GetArchive("alfhenrik", "ScriptCs.OctoKit", ArchiveFormat.Tarball, "master");
+ var archive = await github
+ .Repository
+ .Content
+ .GetArchive(1296269); // octocat/Hello-World repo
- Assert.NotEmpty(archive);
+ Assert.NotEmpty(archive);
+ }
+
+ [IntegrationTest]
+ public async Task GetsArchiveAsZipball()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var archive = await github
+ .Repository
+ .Content
+ .GetArchive("octocat", "Hello-World", ArchiveFormat.Zipball);
+
+ Assert.NotEmpty(archive);
+ }
+
+ [IntegrationTest]
+ public async Task GetsArchiveAsZipballWithRepositoryId()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var archive = await github
+ .Repository
+ .Content
+ .GetArchive(1296269, ArchiveFormat.Zipball); // octocat/Hello-World repo
+
+ Assert.NotEmpty(archive);
+ }
+
+ [IntegrationTest]
+ public async Task GetsArchiveForReleaseBranchAsTarball()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var archive = await github
+ .Repository
+ .Content
+ .GetArchive("octocat", "Hello-World", ArchiveFormat.Tarball, "master");
+
+ Assert.NotEmpty(archive);
+ }
+
+ [IntegrationTest]
+ public async Task GetsArchiveForReleaseBranchAsTarballWithRepositoryId()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var archive = await github
+ .Repository
+ .Content
+ .GetArchive(1296269, ArchiveFormat.Tarball, "master"); // octocat/Hello-World repo
+
+ Assert.NotEmpty(archive);
+ }
+
+ [IntegrationTest]
+ public async Task GetsArchiveForReleaseBranchAsTarballWithTimeout()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var archive = await github
+ .Repository
+ .Content
+ .GetArchive("octocat", "Hello-World", ArchiveFormat.Tarball, "master", TimeSpan.FromMinutes(60));
+
+ Assert.NotEmpty(archive);
+ }
+
+ [IntegrationTest]
+ public async Task GetsArchiveForReleaseBranchAsTarballWithTimeoutWithRepositoryId()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var archive = await github
+ .Repository
+ .Content
+ .GetArchive(1296269, ArchiveFormat.Tarball, "master", TimeSpan.FromMinutes(60)); // octocat/Hello-World repo
+
+ Assert.NotEmpty(archive);
+ }
}
}
}
\ No newline at end of file
diff --git a/Octokit.Tests/Clients/RepositoryContentsClientTests.cs b/Octokit.Tests/Clients/RepositoryContentsClientTests.cs
index 11648733..f04ca7da 100644
--- a/Octokit.Tests/Clients/RepositoryContentsClientTests.cs
+++ b/Octokit.Tests/Clients/RepositoryContentsClientTests.cs
@@ -47,6 +47,46 @@ namespace Octokit.Tests.Clients
Assert.Equal("README", htmlReadme);
connection.Received().GetHtml(Arg.Is(u => u.ToString() == "https://github.example.com/readme.md"), null);
}
+
+ [Fact]
+ public async Task ReturnsReadmeWithRepositoryId()
+ {
+ string encodedContent = Convert.ToBase64String(Encoding.UTF8.GetBytes("Hello world"));
+ var readmeInfo = new ReadmeResponse(
+ encodedContent,
+ "README.md",
+ "https://github.example.com/readme",
+ "https://github.example.com/readme.md",
+ "base64");
+ var connection = Substitute.For();
+ connection.Get(Args.Uri, null).Returns(Task.FromResult(readmeInfo));
+ connection.GetHtml(Args.Uri, null).Returns(Task.FromResult("README"));
+ var contentsClient = new RepositoryContentsClient(connection);
+
+ var readme = await contentsClient.GetReadme(1);
+
+ Assert.Equal("README.md", readme.Name);
+ connection.Received().Get(Arg.Is(u => u.ToString() == "repositories/1/readme"),
+ null);
+ connection.DidNotReceive().GetHtml(Arg.Is(u => u.ToString() == "https://github.example.com/readme"),
+ null);
+ var htmlReadme = await readme.GetHtmlContent();
+ Assert.Equal("README", htmlReadme);
+ connection.Received().GetHtml(Arg.Is(u => u.ToString() == "https://github.example.com/readme.md"), null);
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var connection = Substitute.For();
+ var client = new RepositoryContentsClient(connection);
+
+ await Assert.ThrowsAsync(() => client.GetReadme(null, "name"));
+ await Assert.ThrowsAsync(() => client.GetReadme("owner", null));
+
+ await Assert.ThrowsAsync(() => client.GetReadme("", "name"));
+ await Assert.ThrowsAsync(() => client.GetReadme("owner", ""));
+ }
}
public class TheGetReadmeHtmlMethod
@@ -63,14 +103,126 @@ namespace Octokit.Tests.Clients
connection.Received().GetHtml(Arg.Is(u => u.ToString() == "repos/fake/repo/readme"), null);
Assert.Equal("README", readme);
}
+
+ [Fact]
+ public async Task ReturnsReadmeHtmlWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ connection.GetHtml(Args.Uri, null).Returns(Task.FromResult("README"));
+ var contentsClient = new RepositoryContentsClient(connection);
+
+ var readme = await contentsClient.GetReadmeHtml(1);
+
+ connection.Received().GetHtml(Arg.Is(u => u.ToString() == "repositories/1/readme"), null);
+ Assert.Equal("README", readme);
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var connection = Substitute.For();
+ var client = new RepositoryContentsClient(connection);
+
+ await Assert.ThrowsAsync(() => client.GetReadmeHtml(null, "name"));
+ await Assert.ThrowsAsync(() => client.GetReadmeHtml("owner", null));
+
+ await Assert.ThrowsAsync(() => client.GetReadmeHtml("", "name"));
+ await Assert.ThrowsAsync(() => client.GetReadmeHtml("owner", ""));
+ }
}
public class TheGetContentsMethod
+ {
+ [Fact]
+ public async Task ReturnsContents()
+ {
+ var result = new List { new RepositoryContent() };
+
+ var connection = Substitute.For();
+ connection.GetAll(Args.Uri).Returns(Task.FromResult(result.AsReadOnly() as IReadOnlyList));
+ var contentsClient = new RepositoryContentsClient(connection);
+
+ var contents = await contentsClient.GetAllContents("fake", "repo", "readme.md");
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/contents/readme.md"));
+ Assert.Equal(1, contents.Count);
+ }
+
+ [Fact]
+ public async Task ReturnsContentsWithRepositoryId()
+ {
+ var result = new List { new RepositoryContent() };
+
+ var connection = Substitute.For();
+ connection.GetAll(Args.Uri).Returns(Task.FromResult(result.AsReadOnly() as IReadOnlyList));
+ var contentsClient = new RepositoryContentsClient(connection);
+
+ var contents = await contentsClient.GetAllContents(1, "readme.md");
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/contents/readme.md"));
+ Assert.Equal(1, contents.Count);
+ }
+
+ [Fact]
+ public async Task ReturnsAllContents()
+ {
+ var result = new List { new RepositoryContent() };
+
+ var connection = Substitute.For();
+ connection.GetAll(Args.Uri).Returns(Task.FromResult(result.AsReadOnly() as IReadOnlyList));
+ var contentsClient = new RepositoryContentsClient(connection);
+
+ var contents = await contentsClient.GetAllContents("fake", "repo");
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/contents/"));
+ Assert.Equal(1, contents.Count);
+ }
+
+ [Fact]
+ public async Task ReturnsAllContentsWithRepositoryId()
+ {
+ var result = new List { new RepositoryContent() };
+
+ var connection = Substitute.For();
+ connection.GetAll(Args.Uri).Returns(Task.FromResult(result.AsReadOnly() as IReadOnlyList));
+ var contentsClient = new RepositoryContentsClient(connection);
+
+ var contents = await contentsClient.GetAllContents(1);
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/contents/"));
+ Assert.Equal(1, contents.Count);
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var connection = Substitute.For();
+ var client = new RepositoryContentsClient(connection);
+
+ await Assert.ThrowsAsync(() => client.GetAllContents(null, "name"));
+ await Assert.ThrowsAsync(() => client.GetAllContents("owner", null));
+ await Assert.ThrowsAsync(() => client.GetAllContents(null, "name", "path"));
+ await Assert.ThrowsAsync(() => client.GetAllContents("owner", null, "path"));
+ await Assert.ThrowsAsync(() => client.GetAllContents("owner", "name", null));
+
+ await Assert.ThrowsAsync(() => client.GetAllContents(1, null));
+
+ await Assert.ThrowsAsync(() => client.GetAllContents("", "name"));
+ await Assert.ThrowsAsync(() => client.GetAllContents("owner", ""));
+ await Assert.ThrowsAsync(() => client.GetAllContents("", "name", "path"));
+ await Assert.ThrowsAsync(() => client.GetAllContents("owner", "", "path"));
+ await Assert.ThrowsAsync(() => client.GetAllContents("owner", "name", ""));
+
+ await Assert.ThrowsAsync(() => client.GetAllContents(1, ""));
+ }
+ }
+
+ public class TheGetContentsByRefMethod
{
[Fact]
public async Task ReturnsContentsByRef()
{
- List result = new List { new RepositoryContent() };
+ var result = new List { new RepositoryContent() };
var connection = Substitute.For();
connection.GetAll(Args.Uri).Returns(Task.FromResult(result.AsReadOnly() as IReadOnlyList));
@@ -82,44 +234,132 @@ namespace Octokit.Tests.Clients
Assert.Equal(1, contents.Count);
}
-
[Fact]
- public async Task ReturnsContents()
+ public async Task ReturnsContentsByRefWithRepositoryId()
{
- List result = new List { new RepositoryContent() };
+ var result = new List { new RepositoryContent() };
var connection = Substitute.For();
connection.GetAll(Args.Uri).Returns(Task.FromResult(result.AsReadOnly() as IReadOnlyList));
var contentsClient = new RepositoryContentsClient(connection);
- var contents = await contentsClient.GetAllContents("fake", "repo", "readme.md");
+ var contents = await contentsClient.GetAllContentsByRef(1, "readme.md", "master");
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/contents/readme.md"));
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/contents/readme.md?ref=master"));
Assert.Equal(1, contents.Count);
}
+
+ [Fact]
+ public async Task ReturnsAllContentsByRef()
+ {
+ var result = new List { new RepositoryContent() };
+
+ var connection = Substitute.For();
+ connection.GetAll(Args.Uri).Returns(Task.FromResult(result.AsReadOnly() as IReadOnlyList));
+ var contentsClient = new RepositoryContentsClient(connection);
+
+ var contents = await contentsClient.GetAllContentsByRef("fake", "repo", "master");
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/contents/?ref=master"));
+ Assert.Equal(1, contents.Count);
+ }
+
+ [Fact]
+ public async Task ReturnsAllContentsByRefWithRepositoryId()
+ {
+ var result = new List { new RepositoryContent() };
+
+ var connection = Substitute.For();
+ connection.GetAll(Args.Uri).Returns(Task.FromResult(result.AsReadOnly() as IReadOnlyList));
+ var contentsClient = new RepositoryContentsClient(connection);
+
+ var contents = await contentsClient.GetAllContentsByRef(1, "master");
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/contents/?ref=master"));
+ Assert.Equal(1, contents.Count);
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var connection = Substitute.For();
+ var client = new RepositoryContentsClient(connection);
+
+ await Assert.ThrowsAsync(() => client.GetAllContentsByRef(null, "name", "ref"));
+ await Assert.ThrowsAsync(() => client.GetAllContentsByRef("owner", null, "ref"));
+ await Assert.ThrowsAsync(() => client.GetAllContentsByRef("owner", "name", null));
+ await Assert.ThrowsAsync(() => client.GetAllContentsByRef(null, "name", "path", "reference"));
+ await Assert.ThrowsAsync(() => client.GetAllContentsByRef("owner", null, "path", "reference"));
+ await Assert.ThrowsAsync(() => client.GetAllContentsByRef("owner", "name", null, "reference"));
+ await Assert.ThrowsAsync(() => client.GetAllContentsByRef("owner", "name", "path", null));
+
+ await Assert.ThrowsAsync(() => client.GetAllContentsByRef(1, null, "reference"));
+ await Assert.ThrowsAsync(() => client.GetAllContentsByRef(1, "path", null));
+ await Assert.ThrowsAsync(() => client.GetAllContentsByRef(1, null));
+
+ await Assert.ThrowsAsync(() => client.GetAllContentsByRef("", "name", "ref"));
+ await Assert.ThrowsAsync(() => client.GetAllContentsByRef("owner", "", "ref"));
+ await Assert.ThrowsAsync(() => client.GetAllContentsByRef("owner", "name", ""));
+ await Assert.ThrowsAsync(() => client.GetAllContentsByRef("", "name", "path", "reference"));
+ await Assert.ThrowsAsync(() => client.GetAllContentsByRef("owner", "", "path", "reference"));
+ await Assert.ThrowsAsync(() => client.GetAllContentsByRef("owner", "name", "", "reference"));
+ await Assert.ThrowsAsync(() => client.GetAllContentsByRef("owner", "name", "path", ""));
+
+ await Assert.ThrowsAsync(() => client.GetAllContentsByRef(1, "", "reference"));
+ await Assert.ThrowsAsync(() => client.GetAllContentsByRef(1, "path", ""));
+ await Assert.ThrowsAsync(() => client.GetAllContentsByRef(1, ""));
+ }
}
public class TheCreateFileMethod
{
[Fact]
- public void RequestsCorrectUrl()
+ public async Task RequestsCorrectUrl()
{
var connection = Substitute.For();
var client = new RepositoryContentsClient(connection);
string expectedUri = "repos/org/repo/contents/path/to/file";
- client.CreateFile("org", "repo", "path/to/file", new CreateFileRequest("message", "myfilecontents", "mybranch"));
+ await client.CreateFile("org", "repo", "path/to/file", new CreateFileRequest("message", "myfilecontents", "mybranch"));
connection.Received().Put(Arg.Is(u => u.ToString() == expectedUri), Arg.Any