mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-02 02:45:32 +00:00
Add unit test for ObservableMiscellaneousClient
Fix observable's constructor (obsoleting old constructor) to make it consistent with the other API clients
This commit is contained in:
@@ -9,6 +9,7 @@ namespace Octokit.Reactive
|
||||
{
|
||||
readonly IMiscellaneousClient _client;
|
||||
|
||||
[Obsolete("Please use another constructor")]
|
||||
public ObservableMiscellaneousClient(IMiscellaneousClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
@@ -16,6 +17,13 @@ namespace Octokit.Reactive
|
||||
_client = client;
|
||||
}
|
||||
|
||||
public ObservableMiscellaneousClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_client = client.Miscellaneous;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the emojis available to use on GitHub.
|
||||
/// </summary>
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Octokit.Reactive
|
||||
Authorization = new ObservableAuthorizationsClient(gitHubClient);
|
||||
Activity = new ObservableActivitiesClient(gitHubClient);
|
||||
Issue = new ObservableIssuesClient(gitHubClient);
|
||||
Miscellaneous = new ObservableMiscellaneousClient(gitHubClient.Miscellaneous);
|
||||
Miscellaneous = new ObservableMiscellaneousClient(gitHubClient);
|
||||
Notification = new ObservableNotificationsClient(gitHubClient);
|
||||
Oauth = new ObservableOauthClient(gitHubClient);
|
||||
Organization = new ObservableOrganizationsClient(gitHubClient);
|
||||
|
||||
@@ -209,6 +209,7 @@
|
||||
<Compile Include="Reactive\ObservableIssueCommentsClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableIssuesClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableMilestonesClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableMiscellaneousClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableOrganizationMembersClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservablePullRequestsClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableReleasesClientTests.cs" />
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
using System;
|
||||
using NSubstitute;
|
||||
using Octokit.Reactive;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Reactive
|
||||
{
|
||||
public class ObservableMiscellaneousClientTests
|
||||
{
|
||||
public class TheGetAllEmojisMethod
|
||||
{
|
||||
[Fact]
|
||||
public void CallsIntoClient()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableMiscellaneousClient(gitHubClient);
|
||||
|
||||
client.GetAllEmojis();
|
||||
|
||||
gitHubClient.Miscellaneous.Received(1).GetAllEmojis();
|
||||
}
|
||||
}
|
||||
|
||||
public class TheRenderArbitraryMarkdownMethod
|
||||
{
|
||||
[Fact]
|
||||
public void CallsIntoClient()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableMiscellaneousClient(gitHubClient);
|
||||
|
||||
client.RenderArbitraryMarkdown(new NewArbitraryMarkdown("# test"));
|
||||
|
||||
gitHubClient.Miscellaneous.Received(1).RenderArbitraryMarkdown(Arg.Is<NewArbitraryMarkdown>(a => a.Text == "# test"));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheRenderRawMarkdownMethod
|
||||
{
|
||||
[Fact]
|
||||
public void CallsIntoClient()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableMiscellaneousClient(gitHubClient);
|
||||
|
||||
client.RenderRawMarkdown("# test");
|
||||
|
||||
gitHubClient.Miscellaneous.Received(1).RenderRawMarkdown("# test");
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllGitIgnoreTemplatesMethod
|
||||
{
|
||||
[Fact]
|
||||
public void CallsIntoClient()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableMiscellaneousClient(gitHubClient);
|
||||
|
||||
client.GetAllGitIgnoreTemplates();
|
||||
|
||||
gitHubClient.Miscellaneous.Received(1).GetAllGitIgnoreTemplates();
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetGitIgnoreTemplate
|
||||
{
|
||||
[Fact]
|
||||
public void CallsIntoClient()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableMiscellaneousClient(gitHubClient);
|
||||
|
||||
client.GetGitIgnoreTemplate("template");
|
||||
|
||||
gitHubClient.Miscellaneous.Received(1).GetGitIgnoreTemplate("template");
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllLicensesMethod
|
||||
{
|
||||
[Fact]
|
||||
public void CallsIntoClient()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableMiscellaneousClient(gitHubClient);
|
||||
|
||||
client.GetAllLicenses();
|
||||
|
||||
gitHubClient.Miscellaneous.Received(1).GetAllLicenses();
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetLicenseMethod
|
||||
{
|
||||
[Fact]
|
||||
public void CallsIntoClient()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableMiscellaneousClient(gitHubClient);
|
||||
|
||||
client.GetLicense("key");
|
||||
|
||||
gitHubClient.Miscellaneous.Received(1).GetLicense("key");
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetRateLimitsMethod
|
||||
{
|
||||
[Fact]
|
||||
public void CallsIntoClient()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableMiscellaneousClient(gitHubClient);
|
||||
|
||||
client.GetRateLimits();
|
||||
|
||||
gitHubClient.Miscellaneous.Received(1).GetRateLimits();
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetMetadataMethod
|
||||
{
|
||||
[Fact]
|
||||
public void CallsIntoClient()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableMiscellaneousClient(gitHubClient);
|
||||
|
||||
client.GetMetadata();
|
||||
|
||||
gitHubClient.Miscellaneous.Received(1).GetMetadata();
|
||||
}
|
||||
}
|
||||
|
||||
public class TheCtor
|
||||
{
|
||||
[Fact]
|
||||
public void EnsuresArgument()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new ObservableMiscellaneousClient((IGitHubClient)null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user