mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-20 14:15:12 +00:00
Add reactive overloads for ApiOptions in Assignees API.
This commit is contained in:
@@ -12,6 +12,15 @@ namespace Octokit.Reactive
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
IObservable<User> GetAllForRepository(string owner, string name);
|
IObservable<User> GetAllForRepository(string owner, string name);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets all the available assignees (owner + collaborators) to which issues may be assigned.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="owner">The owner of the repository</param>
|
||||||
|
/// <param name="name">The name of the repository</param>
|
||||||
|
/// <param name="options">The options to change API's behaviour.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
IObservable<User> GetAllForRepository(string owner, string name, ApiOptions options);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks to see if a user is an assignee for a repository.
|
/// Checks to see if a user is an assignee for a repository.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -31,6 +31,21 @@ namespace Octokit.Reactive
|
|||||||
return _connection.GetAndFlattenAllPages<User>(ApiUrls.Assignees(owner, name));
|
return _connection.GetAndFlattenAllPages<User>(ApiUrls.Assignees(owner, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets all the available assignees (owner + collaborators) to which issues may be assigned.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="owner">The owner of the repository</param>
|
||||||
|
/// <param name="name">The name of the repository</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public IObservable<User> GetAllForRepository(string owner, string name, ApiOptions options)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||||
|
Ensure.ArgumentNotNull(options, "options");
|
||||||
|
|
||||||
|
return _connection.GetAndFlattenAllPages<User>(ApiUrls.Assignees(owner, name), options);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks to see if a user is an assignee for a repository.
|
/// Checks to see if a user is an assignee for a repository.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -137,6 +137,7 @@
|
|||||||
<Compile Include="Reactive\Enterprise\ObservableEnterpriseLicenseClientTests.cs" />
|
<Compile Include="Reactive\Enterprise\ObservableEnterpriseLicenseClientTests.cs" />
|
||||||
<Compile Include="Reactive\Enterprise\ObservableEnterpriseSearchIndexingClientTests.cs" />
|
<Compile Include="Reactive\Enterprise\ObservableEnterpriseSearchIndexingClientTests.cs" />
|
||||||
<Compile Include="Reactive\Enterprise\ObservableEnterpriseOrganizationClientTests.cs" />
|
<Compile Include="Reactive\Enterprise\ObservableEnterpriseOrganizationClientTests.cs" />
|
||||||
|
<Compile Include="Reactive\ObservableAssigneesClientTests.cs" />
|
||||||
<Compile Include="Reactive\ObservableIssuesClientTests.cs" />
|
<Compile Include="Reactive\ObservableIssuesClientTests.cs" />
|
||||||
<Compile Include="Reactive\ObservableMilestonesClientTests.cs" />
|
<Compile Include="Reactive\ObservableMilestonesClientTests.cs" />
|
||||||
<Compile Include="Reactive\ObservableReleaseClientTests.cs" />
|
<Compile Include="Reactive\ObservableReleaseClientTests.cs" />
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
using System.Reactive.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Octokit.Reactive;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Octokit.Tests.Integration.Reactive
|
||||||
|
{
|
||||||
|
public class ObservableAssigneesClientTests
|
||||||
|
{
|
||||||
|
public class TheGetAllMethod
|
||||||
|
{
|
||||||
|
readonly ObservableAssigneesClient _assigneesClient;
|
||||||
|
const string owner = "octokit";
|
||||||
|
const string name = "octokit.net";
|
||||||
|
|
||||||
|
public TheGetAllMethod()
|
||||||
|
{
|
||||||
|
var github = Helper.GetAuthenticatedClient();
|
||||||
|
|
||||||
|
_assigneesClient = new ObservableAssigneesClient(github);
|
||||||
|
}
|
||||||
|
|
||||||
|
[IntegrationTest]
|
||||||
|
public async Task ReturnsAssignees()
|
||||||
|
{
|
||||||
|
var assignees = await _assigneesClient.GetAllForRepository(owner, name).ToList();
|
||||||
|
|
||||||
|
Assert.NotEmpty(assignees);
|
||||||
|
}
|
||||||
|
|
||||||
|
[IntegrationTest]
|
||||||
|
public async Task ReturnsCorrectCountOfAssigneesWithoutStart()
|
||||||
|
{
|
||||||
|
var options = new ApiOptions
|
||||||
|
{
|
||||||
|
PageSize = 5,
|
||||||
|
PageCount = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
var assignees = await _assigneesClient.GetAllForRepository(owner, name, options).ToList();
|
||||||
|
|
||||||
|
Assert.Equal(5, assignees.Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
[IntegrationTest]
|
||||||
|
public async Task ReturnsCorrectCountOfAssigneesWithStart()
|
||||||
|
{
|
||||||
|
var options = new ApiOptions
|
||||||
|
{
|
||||||
|
PageSize = 5,
|
||||||
|
PageCount = 1,
|
||||||
|
StartPage = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
var releases = await _assigneesClient.GetAllForRepository(owner, name, options).ToList();
|
||||||
|
|
||||||
|
Assert.Equal(5, releases.Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
[IntegrationTest]
|
||||||
|
public async Task ReturnsDistinctResultsBasedOnStartPage()
|
||||||
|
{
|
||||||
|
var startOptions = new ApiOptions
|
||||||
|
{
|
||||||
|
PageSize = 5,
|
||||||
|
PageCount = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
var firstPage = await _assigneesClient.GetAllForRepository(owner, name, startOptions).ToList();
|
||||||
|
|
||||||
|
var skipStartOptions = new ApiOptions
|
||||||
|
{
|
||||||
|
PageSize = 5,
|
||||||
|
PageCount = 1,
|
||||||
|
StartPage = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
var secondPage = await _assigneesClient.GetAllForRepository(owner, name, skipStartOptions).ToList();
|
||||||
|
|
||||||
|
Assert.NotEqual(firstPage[0].Id, secondPage[0].Id);
|
||||||
|
Assert.NotEqual(firstPage[1].Id, secondPage[1].Id);
|
||||||
|
Assert.NotEqual(firstPage[2].Id, secondPage[2].Id);
|
||||||
|
Assert.NotEqual(firstPage[3].Id, secondPage[3].Id);
|
||||||
|
Assert.NotEqual(firstPage[4].Id, secondPage[4].Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user