mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-22 15:15:19 +00:00
Add Reactive versions of organization API and unit/integration tests
This commit is contained in:
@@ -23,5 +23,13 @@
|
|||||||
/// See the <a href="https://developer.github.com/v3/enterprise/license/">Enterprise License API documentation</a> for more information.
|
/// See the <a href="https://developer.github.com/v3/enterprise/license/">Enterprise License API documentation</a> for more information.
|
||||||
///</remarks>
|
///</remarks>
|
||||||
IObservableEnterpriseLicenseClient License { get; }
|
IObservableEnterpriseLicenseClient License { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A client for GitHub's Enterprise Organization API
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://developer.github.com/v3/enterprise/orgs/">Enterprise Organization API documentation</a> for more information.
|
||||||
|
///</remarks>
|
||||||
|
IObservableEnterpriseOrganizationClient Organization { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Reactive.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Octokit.Reactive
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A client for GitHub's Enterprise Organization API
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://developer.github.com/v3/enterprise/orgs/">Enterprise Organization API documentation</a> for more information.
|
||||||
|
///</remarks>
|
||||||
|
public interface IObservableEnterpriseOrganizationClient
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Creates an Organization on a GitHub Enterprise appliance (must be Site Admin user).
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// https://developer.github.com/v3/enterprise/orgs/#create-an-organization
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="newOrganization">A <see cref="NewOrganization"/> instance describing the organization to be created</param>
|
||||||
|
/// <returns>The <see cref="Organization"/> created.</returns>
|
||||||
|
IObservable<Organization> Create(NewOrganization newOrganization);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
AdminStats = new ObservableEnterpriseAdminStatsClient(client);
|
AdminStats = new ObservableEnterpriseAdminStatsClient(client);
|
||||||
License = new ObservableEnterpriseLicenseClient(client);
|
License = new ObservableEnterpriseLicenseClient(client);
|
||||||
|
Organization = new ObservableEnterpriseOrganizationClient(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -31,5 +32,13 @@
|
|||||||
/// See the <a href="https://developer.github.com/v3/enterprise/license/">Enterprise License API documentation</a> for more information.
|
/// See the <a href="https://developer.github.com/v3/enterprise/license/">Enterprise License API documentation</a> for more information.
|
||||||
///</remarks>
|
///</remarks>
|
||||||
public IObservableEnterpriseLicenseClient License { get; private set; }
|
public IObservableEnterpriseLicenseClient License { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A client for GitHub's Enterprise Organization API
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://developer.github.com/v3/enterprise/orgs/">Enterprise Organization API documentation</a> for more information.
|
||||||
|
///</remarks>
|
||||||
|
public IObservableEnterpriseOrganizationClient Organization { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using System.Reactive.Threading.Tasks;
|
||||||
|
using Octokit;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Octokit.Reactive
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A client for GitHub's Enterprise Organization API
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://developer.github.com/v3/enterprise/orgs/">Enterprise Organization API documentation</a> for more information.
|
||||||
|
///</remarks>
|
||||||
|
public class ObservableEnterpriseOrganizationClient : IObservableEnterpriseOrganizationClient
|
||||||
|
{
|
||||||
|
readonly IEnterpriseOrganizationClient _client;
|
||||||
|
|
||||||
|
public ObservableEnterpriseOrganizationClient(IGitHubClient client)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNull(client, "client");
|
||||||
|
|
||||||
|
_client = client.Enterprise.Organization;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates an Organization on a GitHub Enterprise appliance (must be Site Admin user).
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// https://developer.github.com/v3/enterprise/orgs/#create-an-organization
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="newOrganization">A <see cref="NewOrganization"/> instance describing the organization to be created</param>
|
||||||
|
/// <returns>The <see cref="Organization"/> created.</returns>
|
||||||
|
public IObservable<Organization> Create(NewOrganization newOrganization)
|
||||||
|
{
|
||||||
|
return _client.Create(newOrganization).ToObservable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -75,11 +75,13 @@
|
|||||||
<Compile Include="..\SolutionInfo.cs">
|
<Compile Include="..\SolutionInfo.cs">
|
||||||
<Link>Properties\SolutionInfo.cs</Link>
|
<Link>Properties\SolutionInfo.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Clients\Enterprise\IObservableEnterpriseOrganizationClient.cs" />
|
||||||
<Compile Include="Clients\Enterprise\IObservableEnterpriseLicenseClient.cs" />
|
<Compile Include="Clients\Enterprise\IObservableEnterpriseLicenseClient.cs" />
|
||||||
<Compile Include="Clients\Enterprise\ObservableEnterpriseAdminStatsClient.cs" />
|
<Compile Include="Clients\Enterprise\ObservableEnterpriseAdminStatsClient.cs" />
|
||||||
<Compile Include="Clients\Enterprise\IObservableEnterpriseAdminStatsClient.cs" />
|
<Compile Include="Clients\Enterprise\IObservableEnterpriseAdminStatsClient.cs" />
|
||||||
<Compile Include="Clients\Enterprise\IObservableEnterpriseClient.cs" />
|
<Compile Include="Clients\Enterprise\IObservableEnterpriseClient.cs" />
|
||||||
<Compile Include="Clients\Enterprise\ObservableEnterpriseClient.cs" />
|
<Compile Include="Clients\Enterprise\ObservableEnterpriseClient.cs" />
|
||||||
|
<Compile Include="Clients\Enterprise\ObservableEnterpriseOrganizationClient.cs" />
|
||||||
<Compile Include="Clients\Enterprise\ObservableEnterpriseLicenseClient.cs" />
|
<Compile Include="Clients\Enterprise\ObservableEnterpriseLicenseClient.cs" />
|
||||||
<Compile Include="Clients\IObservableMergingClient.cs" />
|
<Compile Include="Clients\IObservableMergingClient.cs" />
|
||||||
<Compile Include="Clients\IObservableOauthClient.cs" />
|
<Compile Include="Clients\IObservableOauthClient.cs" />
|
||||||
|
|||||||
@@ -124,8 +124,9 @@
|
|||||||
<Compile Include="Clients\IssuesClientTests.cs" />
|
<Compile Include="Clients\IssuesClientTests.cs" />
|
||||||
<Compile Include="Clients\MiscellaneousClientTests.cs" />
|
<Compile Include="Clients\MiscellaneousClientTests.cs" />
|
||||||
<Compile Include="Helpers\OrganizationTestAttribute.cs" />
|
<Compile Include="Helpers\OrganizationTestAttribute.cs" />
|
||||||
<Compile Include="Reactive\Enterprise\ObservableEnterpriseLicenseClientTests.cs" />
|
|
||||||
<Compile Include="Reactive\Enterprise\ObservableEnterpriseAdminStatsClientTests.cs" />
|
<Compile Include="Reactive\Enterprise\ObservableEnterpriseAdminStatsClientTests.cs" />
|
||||||
|
<Compile Include="Reactive\Enterprise\ObservableEnterpriseLicenseClientTests.cs" />
|
||||||
|
<Compile Include="Reactive\Enterprise\ObservableEnterpriseOrganizationClientTests.cs" />
|
||||||
<Compile Include="Reactive\ObservableIssuesClientTests.cs" />
|
<Compile Include="Reactive\ObservableIssuesClientTests.cs" />
|
||||||
<Compile Include="Reactive\ObservableMilestonesClientTests.cs" />
|
<Compile Include="Reactive\ObservableMilestonesClientTests.cs" />
|
||||||
<Compile Include="Reactive\ObservableRepositoriesClientTests.cs" />
|
<Compile Include="Reactive\ObservableRepositoriesClientTests.cs" />
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using System.Reactive.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Octokit.Reactive;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Octokit.Tests.Integration
|
||||||
|
{
|
||||||
|
public class ObservableEnterpriseOrganizationClientTests
|
||||||
|
{
|
||||||
|
readonly IObservableGitHubClient _github;
|
||||||
|
|
||||||
|
public ObservableEnterpriseOrganizationClientTests()
|
||||||
|
{
|
||||||
|
_github = new ObservableGitHubClient(EnterpriseHelper.GetAuthenticatedClient());
|
||||||
|
}
|
||||||
|
|
||||||
|
[GitHubEnterpriseTest]
|
||||||
|
public async Task CanCreateOrganization()
|
||||||
|
{
|
||||||
|
string orgLogin = Helper.MakeNameWithTimestamp("MyOrganization");
|
||||||
|
string orgName = String.Concat(orgLogin, " Display Name");
|
||||||
|
|
||||||
|
var newOrganization = new NewOrganization(orgLogin, EnterpriseHelper.GHEUserName, orgName);
|
||||||
|
var observable = _github.Enterprise.Organization.Create(newOrganization);
|
||||||
|
var organization = await observable;
|
||||||
|
|
||||||
|
Assert.NotNull(organization);
|
||||||
|
|
||||||
|
// Get organization and check login/name
|
||||||
|
var checkOrg = await _github.Organization.Get(orgLogin);
|
||||||
|
Assert.Equal(checkOrg.Login, orgLogin);
|
||||||
|
Assert.Equal(checkOrg.Name, orgName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -189,6 +189,7 @@
|
|||||||
<Compile Include="Helpers\StringExtensionsTests.cs" />
|
<Compile Include="Helpers\StringExtensionsTests.cs" />
|
||||||
<Compile Include="Clients\RepositoriesClientTests.cs" />
|
<Compile Include="Clients\RepositoriesClientTests.cs" />
|
||||||
<Compile Include="Reactive\AuthorizationExtensionsTests.cs" />
|
<Compile Include="Reactive\AuthorizationExtensionsTests.cs" />
|
||||||
|
<Compile Include="Reactive\Enterprise\ObservableEnterpriseOrganizationClientTests.cs" />
|
||||||
<Compile Include="Reactive\Enterprise\ObservableEnterpriseLicenseClientTests.cs" />
|
<Compile Include="Reactive\Enterprise\ObservableEnterpriseLicenseClientTests.cs" />
|
||||||
<Compile Include="Reactive\ObservableBlobClientTests.cs" />
|
<Compile Include="Reactive\ObservableBlobClientTests.cs" />
|
||||||
<Compile Include="Reactive\ObservableCommitsClientTests.cs" />
|
<Compile Include="Reactive\ObservableCommitsClientTests.cs" />
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using NSubstitute;
|
||||||
|
using Octokit.Reactive;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Octokit.Tests
|
||||||
|
{
|
||||||
|
public class ObservableEnterpriseOrganizationClientTests
|
||||||
|
{
|
||||||
|
public class TheCreateMethod
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void CallsIntoClient()
|
||||||
|
{
|
||||||
|
|
||||||
|
var github = Substitute.For<IGitHubClient>();
|
||||||
|
var client = new ObservableEnterpriseOrganizationClient(github);
|
||||||
|
|
||||||
|
client.Create(new NewOrganization("org", "admin", "org name"));
|
||||||
|
github.Enterprise.Organization.Received(1).Create(
|
||||||
|
Arg.Is<NewOrganization>(a =>
|
||||||
|
a.Login == "org"
|
||||||
|
&& a.Admin == "admin"
|
||||||
|
&& a.ProfileName == "org name"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user