mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
Added Observable classes and got started on observable tests
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
<Word>Submodule</Word>
|
||||
<Word>Forkee</Word>
|
||||
<Word>Tarball</Word>
|
||||
<Word>Unsuspend</Word>
|
||||
<Word>Zipball</Word>
|
||||
</Recognized>
|
||||
</Words>
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Reactive;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public interface IObservableUserAdministrationClient
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's User Administration API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/users/administration/">Administration API documentation</a> for more details.
|
||||
/// </remarks>
|
||||
IObservable<Unit> Promote(string login);
|
||||
|
||||
/// <summary>
|
||||
/// A client for GitHub's User Administration API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/users/administration/">Administration API documentation</a> for more details.
|
||||
/// </remarks>
|
||||
IObservable<Unit> Demote(string login);
|
||||
|
||||
/// <summary>
|
||||
/// A client for GitHub's User Administration API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/users/administration/">Administration API documentation</a> for more details.
|
||||
/// </remarks>
|
||||
IObservable<Unit> Suspend(string login);
|
||||
|
||||
/// <summary>
|
||||
/// A client for GitHub's User Administration API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/users/administration/">Administration API documentation</a> for more details.
|
||||
/// </remarks>
|
||||
IObservable<Unit> Unsuspend(string login);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using Octokit.Reactive.Internal;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableUserAdministrationClient : IObservableUserAdministrationClient
|
||||
{
|
||||
public IObservable<Unit> Demote(string login)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IObservable<Unit> Promote(string login)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(login, "login");
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IObservable<Unit> Suspend(string login)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IObservable<Unit> Unsuspend(string login)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,7 @@
|
||||
<Compile Include="Clients\IObservableRepositoryCommitsClients.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryDeployKeysClient.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryPagesClient.cs" />
|
||||
<Compile Include="Clients\IObservableUserAdministrationClient.cs" />
|
||||
<Compile Include="Clients\IObservableUserKeysClient.cs" />
|
||||
<Compile Include="Clients\ObservableMergingClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryDeployKeysClient.cs" />
|
||||
@@ -157,6 +158,7 @@
|
||||
<Compile Include="Clients\ObservableTagsClient.cs" />
|
||||
<Compile Include="Clients\ObservableTreesClient.cs" />
|
||||
<Compile Include="Clients\ObservableFollowersClient.cs" />
|
||||
<Compile Include="Clients\ObservableUserAdministrationClient.cs" />
|
||||
<Compile Include="Clients\ObservableUserEmailsClient.cs" />
|
||||
<Compile Include="Clients\ObservableUserKeysClient.cs" />
|
||||
<Compile Include="Clients\ObservableUsersClient.cs" />
|
||||
|
||||
42
Octokit.Tests/Clients/UserAdministrationClientTests.cs
Normal file
42
Octokit.Tests/Clients/UserAdministrationClientTests.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Octokit.Tests.Helpers;
|
||||
using Xunit;
|
||||
using Octokit.Clients;
|
||||
|
||||
namespace Octokit.Tests.Clients
|
||||
{
|
||||
public class UserAdministrationClientTests
|
||||
{
|
||||
public class ThePromoteMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new UserAdministrationClient(Substitute.For<IApiConnection>());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Promote(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyString()
|
||||
{
|
||||
var client = new UserAdministrationClient(Substitute.For<IApiConnection>());
|
||||
var exception = await Assert.ThrowsAsync<ArgumentException>(() => client.Promote(""));
|
||||
Assert.Equal("login", exception.ParamName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestsTheCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new UserAdministrationClient(connection);
|
||||
|
||||
client.Promote("auser");
|
||||
|
||||
connection.Received().Put(Arg.Is<Uri>(u => u.ToString() == "/users/auser/site_admin"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,6 +101,7 @@
|
||||
<Compile Include="Clients\StatisticsClientTests.cs" />
|
||||
<Compile Include="Clients\TagsClientTests.cs" />
|
||||
<Compile Include="Clients\TreesClientTests.cs" />
|
||||
<Compile Include="Clients\UserAdministrationClientTests.cs" />
|
||||
<Compile Include="Clients\UserEmailsClientTests.cs" />
|
||||
<Compile Include="Clients\WatchedClientTests.cs" />
|
||||
<Compile Include="Exceptions\ApiErrorTests.cs" />
|
||||
|
||||
@@ -110,6 +110,7 @@
|
||||
<Compile Include="Clients\StatisticsClientTests.cs" />
|
||||
<Compile Include="Clients\TagsClientTests.cs" />
|
||||
<Compile Include="Clients\TreesClientTests.cs" />
|
||||
<Compile Include="Clients\UserAdministrationClientTests.cs" />
|
||||
<Compile Include="Clients\UserEmailsClientTests.cs" />
|
||||
<Compile Include="Clients\WatchedClientTests.cs" />
|
||||
<Compile Include="Exceptions\ApiErrorTests.cs" />
|
||||
|
||||
@@ -123,6 +123,7 @@
|
||||
<Compile Include="Clients\RepositoryHooksClientTest.cs" />
|
||||
<Compile Include="Clients\SshKeysClientTests.cs" />
|
||||
<Compile Include="Clients\TreesClientTests.cs" />
|
||||
<Compile Include="Clients\UserAdministrationClientTests.cs" />
|
||||
<Compile Include="Clients\UserEmailsClientTests.cs" />
|
||||
<Compile Include="Clients\WatchedClientTests.cs" />
|
||||
<Compile Include="Clients\FollowersClientTests.cs" />
|
||||
@@ -206,6 +207,7 @@
|
||||
<Compile Include="Reactive\ObservableStatisticsClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableTreesClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableFollowersTest.cs" />
|
||||
<Compile Include="Reactive\ObservableUserAdministrationClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableUserEmailsClientTests.cs" />
|
||||
<Compile Include="SelfTests.cs" />
|
||||
<Compile Include="SimpleJsonSerializerTests.cs" />
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using NSubstitute;
|
||||
using Octokit.Reactive;
|
||||
using Xunit;
|
||||
using System.Reactive.Linq;
|
||||
|
||||
namespace Octokit.Tests.Reactive
|
||||
{
|
||||
public class ObservableUserAdministrationClientTests
|
||||
{
|
||||
public class ThePromoteMethod
|
||||
{
|
||||
[Fact]
|
||||
public void EnsuresArgumentIsNotNull()
|
||||
{
|
||||
var client = new ObservableUserAdministrationClient();
|
||||
Assert.Throws<ArgumentNullException>(() => client.Promote(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ namespace Octokit
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/users/administration/">Administration API documentation</a> for more details.
|
||||
/// </remarks>
|
||||
interface IUserAdministrationClient
|
||||
public interface IUserAdministrationClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Promotes ordinary user to a site administrator.
|
||||
@@ -23,5 +23,35 @@ namespace Octokit
|
||||
/// <returns></returns>
|
||||
Task Promote(string login);
|
||||
|
||||
/// <summary>
|
||||
/// Demotes a site administrator to an ordinary user.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/users/administration/#demote-a-site-administrator-to-an-ordinary-user
|
||||
/// </remarks>
|
||||
/// <param name="login">The user to demote from administrator.</param>
|
||||
/// <returns></returns>
|
||||
Task Demote(string login);
|
||||
|
||||
/// <summary>
|
||||
/// Suspends a user.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/users/administration/#suspend-a-user
|
||||
/// </remarks>
|
||||
/// <param name="login">The user to suspend.</param>
|
||||
/// <returns></returns>
|
||||
Task Suspend(string login);
|
||||
|
||||
/// <summary>
|
||||
/// Unsuspends a user
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/users/administration/#unsuspend-a-user
|
||||
/// </remarks>
|
||||
/// <param name="login">The user to unsuspend.</param>
|
||||
/// <returns></returns>
|
||||
Task Unsuspend(string login);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,5 +57,13 @@ namespace Octokit
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/">Followers API documentation</a> for more information.
|
||||
///</remarks>
|
||||
IFollowersClient Followers { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A client for GitHub's User Administration API
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/users/administration/">User Administrator API documentation</a> for more information.
|
||||
///</remarks>
|
||||
IUserAdministrationClient Administration { get; }
|
||||
}
|
||||
}
|
||||
|
||||
39
Octokit/Clients/UserAdministrationClient.cs
Normal file
39
Octokit/Clients/UserAdministrationClient.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Clients
|
||||
{
|
||||
public class UserAdministrationClient : ApiClient, IUserAdministrationClient
|
||||
{
|
||||
public UserAdministrationClient(IApiConnection apiConnection)
|
||||
: base(apiConnection)
|
||||
{
|
||||
}
|
||||
|
||||
public Task Demote(string login)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task Promote(string login)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(login, "login");
|
||||
var endpoint = ApiUrls.UserAdministration(login);
|
||||
|
||||
return ApiConnection.Put(endpoint);
|
||||
}
|
||||
|
||||
public Task Suspend(string login)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task Unsuspend(string login)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,5 +82,14 @@ namespace Octokit
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/">Followers API documentation</a> for more information.
|
||||
///</remarks>
|
||||
public IFollowersClient Followers { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// A client for GitHub's User Administration API
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/users/administration/">User Administration API documentation</a> for more information.
|
||||
///</remarks>
|
||||
public IUserAdministrationClient Administration { get; private set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1569,5 +1569,11 @@ namespace Octokit
|
||||
{
|
||||
return "repos/{0}/{1}/pages/builds/latest".FormatUri(owner, name);
|
||||
}
|
||||
|
||||
public static Uri UserAdministration(string login)
|
||||
{
|
||||
return "/users/{0}/site_admin".FormatUri(login);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
<Compile Include="Clients\IssuesClient.cs" />
|
||||
<Compile Include="Clients\IssuesEventsClient.cs" />
|
||||
<Compile Include="Clients\IssuesLabelsClient.cs" />
|
||||
<Compile Include="Clients\IUserAdministrationClient.cs" />
|
||||
<Compile Include="Clients\MergingClient.cs" />
|
||||
<Compile Include="Clients\IStarredClient.cs" />
|
||||
<Compile Include="Clients\IStatisticsClient.cs" />
|
||||
@@ -93,6 +94,7 @@
|
||||
<Compile Include="Clients\TagsClient.cs" />
|
||||
<Compile Include="Clients\TreesClient.cs" />
|
||||
<Compile Include="Clients\TeamsClient.cs" />
|
||||
<Compile Include="Clients\UserAdministrationClient.cs" />
|
||||
<Compile Include="Clients\WatchedClient.cs" />
|
||||
<Compile Include="Exceptions\NotFoundException.cs" />
|
||||
<Compile Include="Clients\IAssigneesClient.cs" />
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
<Compile Include="Clients\BlobsClient.cs" />
|
||||
<Compile Include="Clients\CommitsClient.cs" />
|
||||
<Compile Include="Clients\IRepositoryPagesClient.cs" />
|
||||
<Compile Include="Clients\IUserAdministrationClient.cs" />
|
||||
<Compile Include="Clients\MergingClient.cs" />
|
||||
<Compile Include="Clients\CommitStatusClient.cs" />
|
||||
<Compile Include="Clients\EventsClient.cs" />
|
||||
@@ -124,6 +125,7 @@
|
||||
<Compile Include="Clients\TagsClient.cs" />
|
||||
<Compile Include="Clients\TreesClient.cs" />
|
||||
<Compile Include="Clients\TeamsClient.cs" />
|
||||
<Compile Include="Clients\UserAdministrationClient.cs" />
|
||||
<Compile Include="Clients\UsersClient.cs" />
|
||||
<Compile Include="Clients\WatchedClient.cs" />
|
||||
<Compile Include="Exceptions\ApiException.cs" />
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
<Compile Include="Clients\IPullRequestReviewCommentsClient.cs" />
|
||||
<Compile Include="Clients\IPullRequestsClient.cs" />
|
||||
<Compile Include="Clients\IRepositoryPagesClient.cs" />
|
||||
<Compile Include="Clients\IUserAdministrationClient.cs" />
|
||||
<Compile Include="Clients\PullRequestReviewCommentsClient.cs" />
|
||||
<Compile Include="Clients\PullRequestsClient.cs" />
|
||||
<Compile Include="Clients\IAssigneesClient.cs" />
|
||||
@@ -131,6 +132,7 @@
|
||||
<Compile Include="Clients\TagsClient.cs" />
|
||||
<Compile Include="Clients\TreesClient.cs" />
|
||||
<Compile Include="Clients\TeamsClient.cs" />
|
||||
<Compile Include="Clients\UserAdministrationClient.cs" />
|
||||
<Compile Include="Clients\UsersClient.cs" />
|
||||
<Compile Include="Clients\WatchedClient.cs" />
|
||||
<Compile Include="Exceptions\ApiException.cs" />
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
<Compile Include="Clients\RepositoryCommitsClient.cs" />
|
||||
<Compile Include="Clients\RepositoryDeployKeysClient.cs" />
|
||||
<Compile Include="Clients\RepositoryPagesClient.cs" />
|
||||
<Compile Include="Clients\UserAdministrationClient.cs" />
|
||||
<Compile Include="Clients\UserKeysClient.cs" />
|
||||
<Compile Include="Clients\RepositoryContentsClient.cs" />
|
||||
<Compile Include="Exceptions\InvalidGitIgnoreTemplateException.cs" />
|
||||
|
||||
Reference in New Issue
Block a user