mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-08 04:40:54 +00:00
Merge branch 'master' of https://github.com/octokit/octokit.net into issue1182
This commit is contained in:
@@ -12,6 +12,15 @@ namespace Octokit.Reactive
|
||||
/// <returns></returns>
|
||||
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>
|
||||
/// Checks to see if a user is an assignee for a repository.
|
||||
/// </summary>
|
||||
|
||||
@@ -31,6 +31,22 @@ namespace Octokit.Reactive
|
||||
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>
|
||||
/// <param name="options">The options to change API's behaviour</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>
|
||||
/// Checks to see if a user is an assignee for a repository.
|
||||
/// </summary>
|
||||
|
||||
@@ -137,6 +137,7 @@
|
||||
<Compile Include="Reactive\Enterprise\ObservableEnterpriseLicenseClientTests.cs" />
|
||||
<Compile Include="Reactive\Enterprise\ObservableEnterpriseSearchIndexingClientTests.cs" />
|
||||
<Compile Include="Reactive\Enterprise\ObservableEnterpriseOrganizationClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableAssigneesClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableIssuesClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableMilestonesClientTests.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,11 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
client.GetAllForRepository("fake", "repo");
|
||||
|
||||
connection.Received().GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/assignees"));
|
||||
connection.Received().GetAll<User>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/assignees"),
|
||||
null,
|
||||
AcceptHeaders.StableVersion,
|
||||
Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -30,7 +30,25 @@ namespace Octokit
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return ApiConnection.GetAll<User>(ApiUrls.Assignees(owner, name));
|
||||
return GetAllForRepository(owner, name, ApiOptions.None);
|
||||
}
|
||||
|
||||
/// <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 response.</param>
|
||||
/// <returns></returns>
|
||||
public Task<IReadOnlyList<User>> GetAllForRepository(string owner, string name, ApiOptions options)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNull(options, "options");
|
||||
|
||||
var endpoint = ApiUrls.Assignees(owner, name);
|
||||
|
||||
return ApiConnection.GetAll<User>(endpoint, null, AcceptHeaders.StableVersion, options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -19,6 +19,15 @@ namespace Octokit
|
||||
/// <returns></returns>
|
||||
Task<IReadOnlyList<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 chagne API's response.</param>
|
||||
/// <returns></returns>
|
||||
Task<IReadOnlyList<User>> GetAllForRepository(string owner, string name, ApiOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if a user is an assignee for a repository.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
@echo off
|
||||
|
||||
"tools\nuget\nuget.exe" "install" "xunit.runner.console" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.1.0"
|
||||
"tools\nuget\nuget.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.4.2"
|
||||
"tools\nuget\nuget.exe" "install" "SourceLink.Fake" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.1.0"
|
||||
"tools\nuget\nuget.exe" "install" "Octokit.CodeFormatter" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.0.0-preview" -Pre
|
||||
"tools\nuget\nuget.exe" "install" "xunit.runner.console" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.1.0" -verbosity quiet
|
||||
"tools\nuget\nuget.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.22.2" -verbosity quiet
|
||||
"tools\nuget\nuget.exe" "install" "SourceLink.Fake" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.1.0" -verbosity quiet
|
||||
"tools\nuget\nuget.exe" "install" "Octokit.CodeFormatter" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.0.0-preview" -Pre -verbosity quiet
|
||||
|
||||
:Build
|
||||
cls
|
||||
|
||||
@@ -3,16 +3,18 @@ if test "$OS" = "Windows_NT"
|
||||
then
|
||||
# use .Net
|
||||
|
||||
"./tools/nuget/nuget.exe" "install" "xunit.runner.console" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.0.0"
|
||||
"./tools/nuget/nuget.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.4.2"
|
||||
"./tools/nuget/nuget.exe" "install" "SourceLink.Fake" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.1.0"
|
||||
packages/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx
|
||||
"./tools/nuget/nuget.exe" "install" "xunit.runner.console" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.0.0" -verbosity quiet
|
||||
"./tools/nuget/nuget.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.22.2" -verbosity quiet
|
||||
"./tools/nuget/nuget.exe" "install" "SourceLink.Fake" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.1.0" -verbosity quiet
|
||||
"./tools/nuget/nuget.exe" "install" "Octokit.CodeFormatter" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.0.0-preview" -Pre -verbosity quiet
|
||||
packages/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx
|
||||
else
|
||||
# use mono
|
||||
mono "./tools/nuget/NuGet.exe" "install" "xunit.runner.console" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.0.0"
|
||||
mono "./tools/nuget/NuGet.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.4.2"
|
||||
mono "./tools/nuget/NuGet.exe" "install" "SourceLink.Fake" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.1.0"
|
||||
mono "./tools/nuget/NuGet.exe" "install" "System.Net.Http" "-OutputDirectory" "tools"
|
||||
mono "./tools/nuget/NuGet.exe" "install" "Microsoft.Net.Http" "-OutputDirectory" "tools"
|
||||
mono ./tools/FAKE.Core/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx
|
||||
mono "./tools/nuget/NuGet.exe" "install" "xunit.runner.console" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.0.0" -verbosity quiet
|
||||
mono "./tools/nuget/NuGet.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.22.2" -verbosity quiet
|
||||
mono "./tools/nuget/NuGet.exe" "install" "SourceLink.Fake" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.1.0" -verbosity quiet
|
||||
mono "./tools/nuget/NuGet.exe" "install" "Octokit.CodeFormatter" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.0.0-preview" -Pre -verbosity quiet
|
||||
mono "./tools/nuget/NuGet.exe" "install" "System.Net.Http" "-OutputDirectory" "tools" -verbosity quiet
|
||||
mono "./tools/nuget/NuGet.exe" "install" "Microsoft.Net.Http" "-OutputDirectory" "tools" -verbosity quiet
|
||||
mono ./tools/FAKE.Core/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user