diff --git a/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs
index ccc58d70ab..8b9eecb5a4 100644
--- a/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs
+++ b/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs
@@ -18,9 +18,17 @@ public interface IObservableRepositoryForksClient
///
/// The owner of the repository
/// The name of the repository
- /// A of s representing forks of specified repository.
IObservable GetAll(string owner, string name);
+ ///
+ /// Gets the list of forks defined for a repository
+ ///
+ ///
+ /// See API documentation for more information.
+ ///
+ /// The ID of the repository
+ IObservable GetAll(int repositoryId);
+
///
/// Gets the list of forks defined for a repository
///
@@ -30,9 +38,18 @@ public interface IObservableRepositoryForksClient
/// The owner of the repository
/// The name of the repository
/// Options for changing the API response
- /// A of s representing forks of specified repository.
IObservable GetAll(string owner, string name, ApiOptions options);
+ ///
+ /// Gets the list of forks defined for a repository
+ ///
+ ///
+ /// See API documentation for more information.
+ ///
+ /// The ID of the repository
+ /// Options for changing the API response
+ IObservable GetAll(int repositoryId, ApiOptions options);
+
///
/// Gets the list of forks defined for a repository
///
@@ -42,9 +59,18 @@ public interface IObservableRepositoryForksClient
/// The owner of the repository
/// The name of the repository
/// Used to request and filter a list of repository forks
- /// A of s representing forks of specified repository.
IObservable GetAll(string owner, string name, RepositoryForksListRequest request);
+ ///
+ /// Gets the list of forks defined for a repository
+ ///
+ ///
+ /// See API documentation for more information.
+ ///
+ /// The ID of the repository
+ /// Used to request and filter a list of repository forks
+ IObservable GetAll(int repositoryId, RepositoryForksListRequest request);
+
///
/// Gets the list of forks defined for a repository
///
@@ -55,9 +81,19 @@ public interface IObservableRepositoryForksClient
/// The name of the repository
/// Used to request and filter a list of repository forks
/// Options for changing the API response
- /// A of s representing forks of specified repository.
IObservable GetAll(string owner, string name, RepositoryForksListRequest request, ApiOptions options);
+ ///
+ /// Gets the list of forks defined for a repository
+ ///
+ ///
+ /// See API documentation for more information.
+ ///
+ /// The ID of the repository
+ /// Used to request and filter a list of repository forks
+ /// Options for changing the API response
+ IObservable GetAll(int repositoryId, RepositoryForksListRequest request, ApiOptions options);
+
///
/// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization.
///
@@ -67,7 +103,16 @@ public interface IObservableRepositoryForksClient
/// The owner of the repository
/// The name of the repository
/// Used to fork a repository
- /// A of representing the created fork of specified repository.
IObservable Create(string owner, string name, NewRepositoryFork fork);
+
+ ///
+ /// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization.
+ ///
+ ///
+ /// See API documentation for more information.
+ ///
+ /// The ID of the repository
+ /// Used to fork a repository
+ IObservable Create(int repositoryId, NewRepositoryFork fork);
}
}
diff --git a/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs
index 25b0b3257d..9d74de707b 100644
--- a/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs
+++ b/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs
@@ -35,7 +35,6 @@ public ObservableRepositoryForksClient(IGitHubClient client)
///
/// The owner of the repository
/// The name of the repository
- /// A of s representing forks of specified repository.
public IObservable GetAll(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -44,6 +43,18 @@ public IObservable GetAll(string owner, string name)
return GetAll(owner, name, ApiOptions.None);
}
+ ///
+ /// Gets the list of forks defined for a repository
+ ///
+ ///
+ /// See API documentation for more information.
+ ///
+ /// The ID of the repository
+ public IObservable GetAll(int repositoryId)
+ {
+ return GetAll(repositoryId, ApiOptions.None);
+ }
+
///
/// Gets the list of forks defined for a repository
///
@@ -53,7 +64,6 @@ public IObservable GetAll(string owner, string name)
/// The owner of the repository
/// The name of the repository
/// Options for changing the API response
- /// A of s representing forks of specified repository.
public IObservable GetAll(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -63,6 +73,21 @@ public IObservable GetAll(string owner, string name, ApiOptions opti
return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, name), options);
}
+ ///
+ /// Gets the list of forks defined for a repository
+ ///
+ ///
+ /// See API documentation for more information.
+ ///
+ /// The ID of the repository
+ /// Options for changing the API response
+ public IObservable GetAll(int repositoryId, ApiOptions options)
+ {
+ Ensure.ArgumentNotNull(options, "options");
+
+ return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(repositoryId), options);
+ }
+
///
/// Gets the list of forks defined for a repository
///
@@ -72,15 +97,30 @@ public IObservable GetAll(string owner, string name, ApiOptions opti
/// The owner of the repository
/// The name of the repository
/// Used to request and filter a list of repository forks
- /// A of s representing forks of specified repository.
public IObservable GetAll(string owner, string name, RepositoryForksListRequest request)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
+ Ensure.ArgumentNotNull(request, "request");
return GetAll(owner, name, request, ApiOptions.None);
}
+ ///
+ /// Gets the list of forks defined for a repository
+ ///
+ ///
+ /// See API documentation for more information.
+ ///
+ /// The ID of the repository
+ /// Used to request and filter a list of repository forks
+ public IObservable GetAll(int repositoryId, RepositoryForksListRequest request)
+ {
+ Ensure.ArgumentNotNull(request, "request");
+
+ return GetAll(repositoryId, request, ApiOptions.None);
+ }
+
///
/// Gets the list of forks defined for a repository
///
@@ -91,15 +131,31 @@ public IObservable GetAll(string owner, string name, RepositoryForks
/// The name of the repository
/// Used to request and filter a list of repository forks
/// Options for changing the API response
- /// A of s representing forks of specified repository.
public IObservable GetAll(string owner, string name, RepositoryForksListRequest request, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
+ Ensure.ArgumentNotNull(request, "request");
+ Ensure.ArgumentNotNull(options, "options");
+
+ return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, name), request.ToParametersDictionary(), options);
+ }
+
+ ///
+ /// Gets the list of forks defined for a repository
+ ///
+ ///
+ /// See API documentation for more information.
+ ///
+ /// The ID of the repository
+ /// Used to request and filter a list of repository forks
+ /// Options for changing the API response
+ public IObservable GetAll(int repositoryId, RepositoryForksListRequest request, ApiOptions options)
+ {
+ Ensure.ArgumentNotNull(request, "request");
Ensure.ArgumentNotNull(options, "options");
- return request == null ? _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, name), options) :
- _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, name), request.ToParametersDictionary(), options);
+ return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(repositoryId), request.ToParametersDictionary(), options);
}
///
@@ -111,7 +167,6 @@ public IObservable GetAll(string owner, string name, RepositoryForks
/// The owner of the repository
/// The name of the repository
/// Used to fork a repository
- /// A of representing the created fork of specified repository.
public IObservable Create(string owner, string name, NewRepositoryFork fork)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -120,5 +175,20 @@ public IObservable Create(string owner, string name, NewRepositoryFo
return _client.Create(owner, name, fork).ToObservable();
}
+
+ ///
+ /// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization.
+ ///
+ ///
+ /// See API documentation for more information.
+ ///
+ /// The ID of the repository
+ /// Used to fork a repository
+ public IObservable Create(int repositoryId, NewRepositoryFork fork)
+ {
+ Ensure.ArgumentNotNull(fork, "fork");
+
+ return _client.Create(repositoryId, fork).ToObservable();
+ }
}
}
\ No newline at end of file
diff --git a/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs
index 1898f397de..243dbfefca 100644
--- a/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs
@@ -20,6 +20,18 @@ public async Task ReturnsForksForRepository()
Assert.Equal("TeamBinary", masterFork.Owner.Login);
}
+ [IntegrationTest]
+ public async Task ReturnsForksForRepositoryWithRepositoryId()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var forks = await github.Repository.Forks.GetAll(7528679);
+
+ var masterFork = forks.FirstOrDefault(fork => fork.FullName == "TeamBinary/octokit.net");
+ Assert.NotNull(masterFork);
+ Assert.Equal("TeamBinary", masterFork.Owner.Login);
+ }
+
[IntegrationTest]
public async Task ReturnsCorrectCountOfForksWithoutStart()
{
@@ -36,6 +48,22 @@ public async Task ReturnsCorrectCountOfForksWithoutStart()
Assert.Equal(1, forks.Count);
}
+ [IntegrationTest]
+ public async Task ReturnsCorrectCountOfForksWithoutStartWithRepositoryId()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var options = new ApiOptions
+ {
+ PageCount = 1,
+ PageSize = 1
+ };
+
+ var forks = await github.Repository.Forks.GetAll(7528679, options);
+
+ Assert.Equal(1, forks.Count);
+ }
+
[IntegrationTest]
public async Task ReturnsCorrectCountOfForksWithStart()
{
@@ -53,6 +81,23 @@ public async Task ReturnsCorrectCountOfForksWithStart()
Assert.Equal(1, forks.Count);
}
+ [IntegrationTest]
+ public async Task ReturnsCorrectCountOfForksWithStartWithRepositoryId()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var options = new ApiOptions
+ {
+ PageCount = 1,
+ PageSize = 1,
+ StartPage = 1
+ };
+
+ var forks = await github.Repository.Forks.GetAll(7528679, options);
+
+ Assert.Equal(1, forks.Count);
+ }
+
[IntegrationTest]
public async Task ReturnsDistinctForksBasedOnStartPage()
{
@@ -83,6 +128,36 @@ public async Task ReturnsDistinctForksBasedOnStartPage()
Assert.NotEqual(firstPage[2].Id, secondPage[2].Id);
}
+ [IntegrationTest]
+ public async Task ReturnsDistinctForksBasedOnStartPageWithRepositoryId()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var startOptions = new ApiOptions
+ {
+ PageCount = 1,
+ PageSize = 3,
+ StartPage = 1
+ };
+
+ var firstPage = await github.Repository.Forks.GetAll(7528679, startOptions);
+
+ var skipStartOptions = new ApiOptions
+ {
+ PageCount = 1,
+ PageSize = 3,
+ StartPage = 2
+ };
+
+ var secondPage = await github.Repository.Forks.GetAll(7528679, skipStartOptions);
+
+ Assert.Equal(3, firstPage.Count);
+ Assert.Equal(3, secondPage.Count);
+ Assert.NotEqual(firstPage[0].Id, secondPage[0].Id);
+ Assert.NotEqual(firstPage[1].Id, secondPage[1].Id);
+ Assert.NotEqual(firstPage[2].Id, secondPage[2].Id);
+ }
+
[IntegrationTest]
public async Task ReturnsCorrectCountOfForksWithoutStartParameterized()
{
@@ -101,6 +176,24 @@ public async Task ReturnsCorrectCountOfForksWithoutStartParameterized()
Assert.Equal(1, forks.Count);
}
+ [IntegrationTest]
+ public async Task ReturnsCorrectCountOfForksWithoutStartParameterizedWithRepositoryId()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var options = new ApiOptions
+ {
+ PageCount = 1,
+ PageSize = 1
+ };
+
+ var repositoryForksListRequest = new RepositoryForksListRequest { Sort = Sort.Newest };
+
+ var forks = await github.Repository.Forks.GetAll(7528679, repositoryForksListRequest, options);
+
+ Assert.Equal(1, forks.Count);
+ }
+
[IntegrationTest]
public async Task ReturnsCorrectCountOfForksWithStartParameterized()
{
@@ -120,6 +213,25 @@ public async Task ReturnsCorrectCountOfForksWithStartParameterized()
Assert.Equal(1, forks.Count);
}
+ [IntegrationTest]
+ public async Task ReturnsCorrectCountOfForksWithStartParameterizedWithRepositoryId()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var options = new ApiOptions
+ {
+ PageCount = 1,
+ PageSize = 1,
+ StartPage = 1
+ };
+
+ var repositoryForksListRequest = new RepositoryForksListRequest { Sort = Sort.Newest };
+
+ var forks = await github.Repository.Forks.GetAll(7528679, repositoryForksListRequest, options);
+
+ Assert.Equal(1, forks.Count);
+ }
+
[IntegrationTest]
public async Task ReturnsDistinctForksBasedOnStartPageParameterized()
{
@@ -152,6 +264,38 @@ public async Task ReturnsDistinctForksBasedOnStartPageParameterized()
Assert.NotEqual(firstPage[2].Id, secondPage[2].Id);
}
+ [IntegrationTest]
+ public async Task ReturnsDistinctForksBasedOnStartPageParameterizedWithRepositoryId()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var repositoryForksListRequest = new RepositoryForksListRequest { Sort = Sort.Newest };
+
+ var startOptions = new ApiOptions
+ {
+ PageCount = 1,
+ PageSize = 3,
+ StartPage = 1
+ };
+
+ var firstPage = await github.Repository.Forks.GetAll(7528679, repositoryForksListRequest, startOptions);
+
+ var skipStartOptions = new ApiOptions
+ {
+ PageCount = 1,
+ PageSize = 3,
+ StartPage = 2
+ };
+
+ var secondPage = await github.Repository.Forks.GetAll(7528679, repositoryForksListRequest, skipStartOptions);
+
+ Assert.Equal(3, firstPage.Count);
+ Assert.Equal(3, secondPage.Count);
+ Assert.NotEqual(firstPage[0].Id, secondPage[0].Id);
+ Assert.NotEqual(firstPage[1].Id, secondPage[1].Id);
+ Assert.NotEqual(firstPage[2].Id, secondPage[2].Id);
+ }
+
[IntegrationTest]
public async Task ReturnsForksForRepositorySortingTheResultWithOldestFirstWithApiOptions()
{
@@ -190,6 +334,44 @@ public async Task ReturnsForksForRepositorySortingTheResultWithOldestFirstWithAp
}
}
+ [IntegrationTest]
+ public async Task ReturnsForksForRepositorySortingTheResultWithOldestFirstWithApiOptionsWithRepositoryId()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var repositoryForksListRequest = new RepositoryForksListRequest { Sort = Sort.Oldest };
+
+ var startOptions = new ApiOptions
+ {
+ PageCount = 1,
+ PageSize = 3,
+ StartPage = 1
+ };
+
+ var firstPage = await github.Repository.Forks.GetAll(7528679, repositoryForksListRequest, startOptions);
+ var firstPageOrdered = firstPage.OrderBy(r => r.CreatedAt).ToList();
+
+ var skipStartOptions = new ApiOptions
+ {
+ PageCount = 1,
+ PageSize = 3,
+ StartPage = 1
+ };
+
+ var secondPage = await github.Repository.Forks.GetAll(7528679, repositoryForksListRequest, skipStartOptions);
+ var secondPageOrdered = secondPage.OrderBy(r => r.CreatedAt).ToList();
+
+ for (var index = 0; index < firstPage.Count; index++)
+ {
+ Assert.Equal(firstPageOrdered[index].FullName, firstPage[index].FullName);
+ }
+
+ for (var index = 0; index < firstPage.Count; index++)
+ {
+ Assert.Equal(secondPageOrdered[index].FullName, secondPage[index].FullName);
+ }
+ }
+
[IntegrationTest]
public async Task ReturnsForksForRepositorySortingTheResultWithOldestFirst()
{
@@ -203,6 +385,20 @@ public async Task ReturnsForksForRepositorySortingTheResultWithOldestFirst()
Assert.Equal(sortedForks[index].FullName, actualForks[index].FullName);
}
}
+
+ [IntegrationTest]
+ public async Task ReturnsForksForRepositorySortingTheResultWithOldestFirstWithRepositoryId()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var actualForks = (await github.Repository.Forks.GetAll(7528679, new RepositoryForksListRequest { Sort = Sort.Oldest })).ToArray();
+ var sortedForks = actualForks.OrderBy(fork => fork.CreatedAt).ToArray();
+
+ for (var index = 0; index < actualForks.Length; index++)
+ {
+ Assert.Equal(sortedForks[index].FullName, actualForks[index].FullName);
+ }
+ }
}
public class TheCreateMethod
@@ -224,6 +420,23 @@ public async Task ForkCreatedForUserLoggedIn()
Assert.Equal(true, forkCreated.Fork);
}
+ [IntegrationTest]
+ public async Task ForkCreatedForUserLoggedInWithRepositoryId()
+ {
+ // The fork is created asynchronously by github and therefore it cannot
+ // be certain that the repo exists when the test ends. It is therefore deleted
+ // before the test starts instead of after.
+ Helper.DeleteRepo(Helper.GetAuthenticatedClient().Connection, Helper.Credentials.Login, "octokit.net");
+
+ var github = Helper.GetAuthenticatedClient();
+
+ var forkCreated = await github.Repository.Forks.Create(7528679, new NewRepositoryFork());
+
+ Assert.NotNull(forkCreated);
+ Assert.Equal(string.Format("{0}/octokit.net", Helper.UserName), forkCreated.FullName);
+ Assert.Equal(true, forkCreated.Fork);
+ }
+
[OrganizationTest]
public async Task ForkCreatedForOrganization()
{
@@ -240,6 +453,23 @@ public async Task ForkCreatedForOrganization()
Assert.Equal(string.Format("{0}/octokit.net", Helper.Organization), forkCreated.FullName);
Assert.Equal(true, forkCreated.Fork);
}
+
+ [OrganizationTest]
+ public async Task ForkCreatedForOrganizationWithRepositoryId()
+ {
+ // The fork is created asynchronously by github and therefore it cannot
+ // be certain that the repo exists when the test ends. It is therefore deleted
+ // before the test starts.
+ Helper.DeleteRepo(Helper.GetAuthenticatedClient().Connection, Helper.Organization, "octokit.net");
+
+ var github = Helper.GetAuthenticatedClient();
+
+ var forkCreated = await github.Repository.Forks.Create(7528679, new NewRepositoryFork { Organization = Helper.Organization });
+
+ Assert.NotNull(forkCreated);
+ Assert.Equal(string.Format("{0}/octokit.net", Helper.Organization), forkCreated.FullName);
+ Assert.Equal(true, forkCreated.Fork);
+ }
}
}
}
diff --git a/Octokit.Tests/Clients/RepositoryForksClientTests.cs b/Octokit.Tests/Clients/RepositoryForksClientTests.cs
index 32d8bccbaf..6f4b5b928b 100644
--- a/Octokit.Tests/Clients/RepositoryForksClientTests.cs
+++ b/Octokit.Tests/Clients/RepositoryForksClientTests.cs
@@ -31,6 +31,17 @@ public async Task RequestsCorrectUrl()
connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/forks"), Args.ApiOptions);
}
+ [Fact]
+ public async Task RequestsCorrectUrlWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new RepositoryForksClient(connection);
+
+ await client.GetAll(1);
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/forks"), Args.ApiOptions);
+ }
+
[Fact]
public async Task RequestsCorrectUrlWithApiOptions()
{
@@ -49,6 +60,24 @@ public async Task RequestsCorrectUrlWithApiOptions()
connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/forks"), options);
}
+ [Fact]
+ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()
+ {
+ var connection = Substitute.For();
+ var client = new RepositoryForksClient(connection);
+
+ var options = new ApiOptions
+ {
+ PageCount = 1,
+ StartPage = 1,
+ PageSize = 1
+ };
+
+ await client.GetAll(1, options);
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/forks"), options);
+ }
+
[Fact]
public async Task RequestsCorrectUrlWithRequestParameters()
{
@@ -62,6 +91,19 @@ public async Task RequestsCorrectUrlWithRequestParameters()
Arg.Is>(d => d["sort"] == "stargazers"), Args.ApiOptions);
}
+ [Fact]
+ public async Task RequestsCorrectUrlWithRepositoryIdWithRequestParameters()
+ {
+ var connection = Substitute.For();
+ var client = new RepositoryForksClient(connection);
+
+ await client.GetAll(1, new RepositoryForksListRequest { Sort = Sort.Stargazers });
+
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "repositories/1/forks"),
+ Arg.Is>(d => d["sort"] == "stargazers"), Args.ApiOptions);
+ }
+
[Fact]
public async Task RequestsCorrectUrlWithRequestParametersWithApiOptions()
{
@@ -82,6 +124,26 @@ public async Task RequestsCorrectUrlWithRequestParametersWithApiOptions()
Arg.Is>(d => d["sort"] == "stargazers"), options);
}
+ [Fact]
+ public async Task RequestsCorrectUrlWithRepositoryIdWithRequestParametersWithApiOptions()
+ {
+ var connection = Substitute.For();
+ 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(
+ Arg.Is(u => u.ToString() == "repositories/1/forks"),
+ Arg.Is>(d => d["sort"] == "stargazers"), options);
+ }
+
[Fact]
public async Task EnsuresNonNullArguments()
{
@@ -94,10 +156,16 @@ public async Task EnsuresNonNullArguments()
await Assert.ThrowsAsync(() => client.GetAll("owner", "name", (ApiOptions)null));
await Assert.ThrowsAsync(() => client.GetAll(null, "name", new RepositoryForksListRequest()));
await Assert.ThrowsAsync(() => client.GetAll("owner", null, new RepositoryForksListRequest()));
+ await Assert.ThrowsAsync(() => client.GetAll("owner", "name", (RepositoryForksListRequest)null));
await Assert.ThrowsAsync(() => client.GetAll(null, "name", new RepositoryForksListRequest(), ApiOptions.None));
await Assert.ThrowsAsync(() => client.GetAll("owner", null, new RepositoryForksListRequest(), ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAll("owner", "name", null, ApiOptions.None));
await Assert.ThrowsAsync(() => client.GetAll("owner", "name", new RepositoryForksListRequest(), null));
+ await Assert.ThrowsAsync(() => client.GetAll(1, (ApiOptions)null));
+ await Assert.ThrowsAsync(() => client.GetAll(1, (RepositoryForksListRequest)null));
+ await Assert.ThrowsAsync(() => client.GetAll(1, new RepositoryForksListRequest(), null));
+
await Assert.ThrowsAsync(() => client.GetAll("", "name"));
await Assert.ThrowsAsync(() => client.GetAll("owner", ""));
await Assert.ThrowsAsync(() => client.GetAll("", "name", ApiOptions.None));
@@ -124,6 +192,19 @@ public void RequestsCorrectUrl()
connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/forks"), newRepositoryFork);
}
+ [Fact]
+ public void RequestsCorrectUrlWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new RepositoryForksClient(connection);
+
+ var newRepositoryFork = new NewRepositoryFork();
+
+ client.Create(1, newRepositoryFork);
+
+ connection.Received().Post(Arg.Is(u => u.ToString() == "repositories/1/forks"), newRepositoryFork);
+ }
+
[Fact]
public async Task EnsuresNonNullArguments()
{
@@ -133,6 +214,8 @@ public async Task EnsuresNonNullArguments()
await Assert.ThrowsAsync(() => client.Create("owner", null, new NewRepositoryFork()));
await Assert.ThrowsAsync(() => client.Create("owner", "name", null));
+ await Assert.ThrowsAsync(() => client.Create(1, null));
+
await Assert.ThrowsAsync(() => client.Create("", "name", new NewRepositoryFork()));
await Assert.ThrowsAsync(() => client.Create("owner", "", new NewRepositoryFork()));
}
diff --git a/Octokit.Tests/Reactive/ObservableRepositoryForksClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryForksClientTests.cs
index 77acb6603e..49e7cedf30 100644
--- a/Octokit.Tests/Reactive/ObservableRepositoryForksClientTests.cs
+++ b/Octokit.Tests/Reactive/ObservableRepositoryForksClientTests.cs
@@ -30,6 +30,17 @@ public void RequestsCorrectUrl()
gitHubClient.Received().Repository.Forks.GetAll("fake", "repo");
}
+ [Fact]
+ public void RequestsCorrectUrlWithRepositoryId()
+ {
+ var gitHubClient = Substitute.For();
+ var client = new ObservableRepositoryForksClient(gitHubClient);
+
+ client.GetAll(1);
+
+ gitHubClient.Received().Repository.Forks.GetAll(1);
+ }
+
[Fact]
public void RequestsCorrectUrlWithApiOptions()
{
@@ -48,6 +59,24 @@ public void RequestsCorrectUrlWithApiOptions()
gitHubClient.Received().Repository.Forks.GetAll("fake", "repo", options);
}
+ [Fact]
+ public void RequestsCorrectUrlWithRepositoryIdWithApiOptions()
+ {
+ var gitHubClient = Substitute.For();
+ var client = new ObservableRepositoryForksClient(gitHubClient);
+
+ var options = new ApiOptions
+ {
+ PageCount = 1,
+ StartPage = 1,
+ PageSize = 1
+ };
+
+ client.GetAll(1, options);
+
+ gitHubClient.Received().Repository.Forks.GetAll(1, options);
+ }
+
[Fact]
public void RequestsCorrectUrlWithRequestParameters()
{
@@ -62,6 +91,20 @@ public void RequestsCorrectUrlWithRequestParameters()
"fake", "repo", repositoryForksListRequest);
}
+ [Fact]
+ public void RequestsCorrectUrlWithRepositoryIdWithRequestParameters()
+ {
+ var gitHubClient = Substitute.For();
+ var client = new ObservableRepositoryForksClient(gitHubClient);
+
+ var repositoryForksListRequest = new RepositoryForksListRequest { Sort = Sort.Stargazers };
+
+ client.GetAll(1, repositoryForksListRequest);
+
+ gitHubClient.Received().Repository.Forks.GetAll(
+ 1, repositoryForksListRequest);
+ }
+
[Fact]
public void RequestsCorrectUrlWithRequestParametersWithApiOptions()
{
@@ -82,6 +125,26 @@ public void RequestsCorrectUrlWithRequestParametersWithApiOptions()
gitHubClient.Received().Repository.Forks.GetAll("fake", "name", repositoryForksListRequest, options);
}
+ [Fact]
+ public void RequestsCorrectUrlWithRepositoryIdWithRequestParametersWithApiOptions()
+ {
+ var gitHubClient = Substitute.For();
+ var client = new ObservableRepositoryForksClient(gitHubClient);
+
+ var options = new ApiOptions
+ {
+ PageCount = 1,
+ StartPage = 1,
+ PageSize = 1
+ };
+
+ var repositoryForksListRequest = new RepositoryForksListRequest { Sort = Sort.Stargazers };
+
+ client.GetAll(1, repositoryForksListRequest, options);
+
+ gitHubClient.Received().Repository.Forks.GetAll(1, repositoryForksListRequest, options);
+ }
+
[Fact]
public void EnsuresNonNullArguments()
{
@@ -94,10 +157,16 @@ public void EnsuresNonNullArguments()
Assert.Throws(() => client.GetAll("owner", "name", (ApiOptions)null));
Assert.Throws(() => client.GetAll(null, "name", new RepositoryForksListRequest()));
Assert.Throws(() => client.GetAll("owner", null, new RepositoryForksListRequest()));
+ Assert.Throws(() => client.GetAll("owner", "name", (RepositoryForksListRequest)null));
Assert.Throws(() => client.GetAll(null, "name", new RepositoryForksListRequest(), ApiOptions.None));
Assert.Throws(() => client.GetAll("owner", null, new RepositoryForksListRequest(), ApiOptions.None));
+ Assert.Throws(() => client.GetAll("owner", "name", null, ApiOptions.None));
Assert.Throws(() => client.GetAll("owner", "name", new RepositoryForksListRequest(), null));
+ Assert.Throws(() => client.GetAll(1, (ApiOptions)null));
+ Assert.Throws(() => client.GetAll(1, (RepositoryForksListRequest)null));
+ Assert.Throws(() => client.GetAll(1, new RepositoryForksListRequest(), null));
+
Assert.Throws(() => client.GetAll("", "name"));
Assert.Throws(() => client.GetAll("owner", ""));
Assert.Throws(() => client.GetAll("", "name", ApiOptions.None));
@@ -124,6 +193,19 @@ public void RequestsCorrectUrl()
gitHubClient.Received().Repository.Forks.Create("fake", "repo", newRepositoryFork);
}
+ [Fact]
+ public void RequestsCorrectUrlWithRepositoryId()
+ {
+ var gitHubClient = Substitute.For();
+ var client = new ObservableRepositoryForksClient(gitHubClient);
+
+ var newRepositoryFork = new NewRepositoryFork();
+
+ client.Create(1, newRepositoryFork);
+
+ gitHubClient.Received().Repository.Forks.Create(1, newRepositoryFork);
+ }
+
[Fact]
public void EnsuresNonNullArguments()
{
@@ -133,6 +215,8 @@ public void EnsuresNonNullArguments()
Assert.Throws(() => client.Create("owner", null, new NewRepositoryFork()));
Assert.Throws(() => client.Create("owner", "name", null));
+ Assert.Throws(() => client.Create(1, null));
+
Assert.Throws(() => client.Create("", "name", new NewRepositoryFork()));
Assert.Throws(() => client.Create("owner", "", new NewRepositoryFork()));
}
diff --git a/Octokit/Clients/IRepositoryForksClient.cs b/Octokit/Clients/IRepositoryForksClient.cs
index 742b38d0b1..ea6018c460 100644
--- a/Octokit/Clients/IRepositoryForksClient.cs
+++ b/Octokit/Clients/IRepositoryForksClient.cs
@@ -19,9 +19,17 @@ public interface IRepositoryForksClient
///
/// The owner of the repository
/// The name of the repository
- /// A of s representing forks of specified repository.
Task> GetAll(string owner, string name);
+ ///
+ /// Gets the list of forks defined for a repository
+ ///
+ ///
+ /// See API documentation for more information.
+ ///
+ /// The ID of the repository
+ Task> GetAll(int repositoryId);
+
///
/// Gets the list of forks defined for a repository
///
@@ -31,9 +39,18 @@ public interface IRepositoryForksClient
/// The owner of the repository
/// The name of the repository
/// Options for changing the API response
- /// A of s representing forks of specified repository.
Task> GetAll(string owner, string name, ApiOptions options);
+ ///
+ /// Gets the list of forks defined for a repository
+ ///
+ ///
+ /// See API documentation for more information.
+ ///
+ /// The ID of the repository
+ /// Options for changing the API response
+ Task> GetAll(int repositoryId, ApiOptions options);
+
///
/// Gets the list of forks defined for a repository
///
@@ -43,9 +60,18 @@ public interface IRepositoryForksClient
/// The owner of the repository
/// The name of the repository
/// Used to request and filter a list of repository forks
- /// A of s representing forks of specified repository.
Task> GetAll(string owner, string name, RepositoryForksListRequest request);
+ ///
+ /// Gets the list of forks defined for a repository
+ ///
+ ///
+ /// See API documentation for more information.
+ ///
+ /// The ID of the repository
+ /// Used to request and filter a list of repository forks
+ Task> GetAll(int repositoryId, RepositoryForksListRequest request);
+
///
/// Gets the list of forks defined for a repository
///
@@ -56,9 +82,19 @@ public interface IRepositoryForksClient
/// The name of the repository
/// Used to request and filter a list of repository forks
/// Options for changing the API response
- /// A of s representing forks of specified repository.
Task> GetAll(string owner, string name, RepositoryForksListRequest request, ApiOptions options);
+ ///
+ /// Gets the list of forks defined for a repository
+ ///
+ ///
+ /// See API documentation for more information.
+ ///
+ /// The ID of the repository
+ /// Used to request and filter a list of repository forks
+ /// Options for changing the API response
+ Task> GetAll(int repositoryId, RepositoryForksListRequest request, ApiOptions options);
+
///
/// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization.
///
@@ -68,7 +104,16 @@ public interface IRepositoryForksClient
/// The owner of the repository
/// The name of the repository
/// Used to fork a repository
- /// A representing the created fork of specified repository.
Task Create(string owner, string name, NewRepositoryFork fork);
+
+ ///
+ /// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization.
+ ///
+ ///
+ /// See API documentation for more information.
+ ///
+ /// The ID of the repository
+ /// Used to fork a repository
+ Task Create(int repositoryId, NewRepositoryFork fork);
}
}
diff --git a/Octokit/Clients/RepositoryForksClient.cs b/Octokit/Clients/RepositoryForksClient.cs
index 0915cde32e..827da5f5e7 100644
--- a/Octokit/Clients/RepositoryForksClient.cs
+++ b/Octokit/Clients/RepositoryForksClient.cs
@@ -28,7 +28,6 @@ public RepositoryForksClient(IApiConnection apiConnection)
///
/// The owner of the repository
/// The name of the repository
- /// A of s representing forks of specified repository.
public Task> GetAll(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -37,6 +36,18 @@ public Task> GetAll(string owner, string name)
return GetAll(owner, name, ApiOptions.None);
}
+ ///
+ /// Gets the list of forks defined for a repository
+ ///
+ ///
+ /// See API documentation for more information.
+ ///
+ /// The ID of the repository
+ public Task> GetAll(int repositoryId)
+ {
+ return GetAll(repositoryId, ApiOptions.None);
+ }
+
///
/// Gets the list of forks defined for a repository
///
@@ -46,7 +57,6 @@ public Task> GetAll(string owner, string name)
/// The owner of the repository
/// The name of the repository
/// Options for changing the API response
- /// A of s representing forks of specified repository.
public Task> GetAll(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -56,6 +66,21 @@ public Task> GetAll(string owner, string name, ApiOpti
return ApiConnection.GetAll(ApiUrls.RepositoryForks(owner, name), options);
}
+ ///
+ /// Gets the list of forks defined for a repository
+ ///
+ ///
+ /// See API documentation for more information.
+ ///
+ /// The ID of the repository
+ /// Options for changing the API response
+ public Task> GetAll(int repositoryId, ApiOptions options)
+ {
+ Ensure.ArgumentNotNull(options, "options");
+
+ return ApiConnection.GetAll(ApiUrls.RepositoryForks(repositoryId), options);
+ }
+
///
/// Gets the list of forks defined for a repository
///
@@ -65,15 +90,30 @@ public Task> GetAll(string owner, string name, ApiOpti
/// The owner of the repository
/// The name of the repository
/// Used to request and filter a list of repository forks
- /// A of s representing forks of specified repository.
public Task> GetAll(string owner, string name, RepositoryForksListRequest request)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
+ Ensure.ArgumentNotNull(request, "request");
return GetAll(owner, name, request, ApiOptions.None);
}
+ ///
+ /// Gets the list of forks defined for a repository
+ ///
+ ///
+ /// See API documentation for more information.
+ ///
+ /// The ID of the repository
+ /// Used to request and filter a list of repository forks
+ public Task> GetAll(int repositoryId, RepositoryForksListRequest request)
+ {
+ Ensure.ArgumentNotNull(request, "request");
+
+ return GetAll(repositoryId, request, ApiOptions.None);
+ }
+
///
/// Gets the list of forks defined for a repository
///
@@ -84,16 +124,31 @@ public Task> GetAll(string owner, string name, Reposit
/// The name of the repository
/// Used to request and filter a list of repository forks
/// Options for changing the API response
- /// A of s representing forks of specified repository.
public Task> GetAll(string owner, string name, RepositoryForksListRequest request, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
+ Ensure.ArgumentNotNull(request, "request");
+ Ensure.ArgumentNotNull(options, "options");
+
+ return ApiConnection.GetAll(ApiUrls.RepositoryForks(owner, name), request.ToParametersDictionary(), options);
+ }
+
+ ///
+ /// Gets the list of forks defined for a repository
+ ///
+ ///
+ /// See API documentation for more information.
+ ///
+ /// The ID of the repository
+ /// Used to request and filter a list of repository forks
+ /// Options for changing the API response
+ public Task> GetAll(int repositoryId, RepositoryForksListRequest request, ApiOptions options)
+ {
+ Ensure.ArgumentNotNull(request, "request");
Ensure.ArgumentNotNull(options, "options");
- return request == null
- ? ApiConnection.GetAll(ApiUrls.RepositoryForks(owner, name), options) :
- ApiConnection.GetAll(ApiUrls.RepositoryForks(owner, name), request.ToParametersDictionary(), options);
+ return ApiConnection.GetAll(ApiUrls.RepositoryForks(repositoryId), request.ToParametersDictionary(), options);
}
///
@@ -105,7 +160,6 @@ public Task> GetAll(string owner, string name, Reposit
/// The owner of the repository
/// The name of the repository
/// Used to fork a repository
- /// A representing the created fork of specified repository.
public Task Create(string owner, string name, NewRepositoryFork fork)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -114,5 +168,20 @@ public Task Create(string owner, string name, NewRepositoryFork fork
return ApiConnection.Post(ApiUrls.RepositoryForks(owner, name), fork);
}
+
+ ///
+ /// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization.
+ ///
+ ///
+ /// See API documentation for more information.
+ ///
+ /// The ID of the repository
+ /// Used to fork a repository
+ public Task Create(int repositoryId, NewRepositoryFork fork)
+ {
+ Ensure.ArgumentNotNull(fork, "fork");
+
+ return ApiConnection.Post(ApiUrls.RepositoryForks(repositoryId), fork);
+ }
}
}