create unit tests for CommitCommentReactionClient

This commit is contained in:
lrz-hal
2016-05-30 17:01:45 +02:00
parent c536b85ebf
commit 10fe3cd7c9
4 changed files with 69 additions and 61 deletions
@@ -1,14 +1,21 @@
using NSubstitute;
using Octokit;
using Octokit.Tests;
using System;
using System.Threading.Tasks;
using Xunit;
public class ReactionsClientTests
namespace Octokit.Tests.Clients
{
public class CommitComments
public class CommitCommentReactionClientTests
{
public class TheCtor
{
[Fact]
public void EnsuresNonNullArguments()
{
Assert.Throws<ArgumentNullException>(() => new CommitCommentReactionClient(null));
}
}
public class TheGetAllMethod
{
[Fact]
@@ -53,4 +60,3 @@ public class ReactionsClientTests
}
}
}
+2 -2
View File
@@ -85,6 +85,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Authentication\CredentialsTests.cs" />
<Compile Include="Clients\CommitCommentReactionClientTests.cs" />
<Compile Include="Clients\MigrationsClientTests.cs" />
<Compile Include="Clients\Enterprise\EnterpriseAdminStatsClientTests.cs" />
<Compile Include="Clients\Enterprise\EnterpriseLdapClientTests.cs" />
@@ -93,7 +94,6 @@
<Compile Include="Clients\Enterprise\EnterpriseSearchIndexingClientTests.cs" />
<Compile Include="Clients\MergingClientTests.cs" />
<Compile Include="Clients\OauthClientTests.cs" />
<Compile Include="Clients\ReactionsClientTests.cs" />
<Compile Include="Clients\RepositoryCommentsClientTests.cs" />
<Compile Include="Clients\DeploymentsClientTests.cs" />
<Compile Include="Clients\DeploymentStatusClientTests.cs" />
@@ -207,9 +207,9 @@
<Compile Include="Reactive\ObservableAssigneesClientTests.cs" />
<Compile Include="Reactive\ObservableAuthorizationsClientTests.cs" />
<Compile Include="Reactive\ObservableBlobClientTests.cs" />
<Compile Include="Reactive\ObservableCommitCommentReactionClientTests.cs" />
<Compile Include="Reactive\ObservableCommitsClientTests.cs" />
<Compile Include="Reactive\ObservableIssuesLabelsClientTests.cs" />
<Compile Include="Reactive\ObservableReactionsClientTests.cs" />
<Compile Include="Reactive\ObservableRepoCollaboratorsClientTests.cs" />
<Compile Include="Reactive\ObservableDeploymentsClientTests.cs" />
<Compile Include="Reactive\ObservableDeploymentStatusClientTests.cs" />
@@ -0,0 +1,56 @@
using NSubstitute;
using Octokit.Reactive;
using System;
using Xunit;
namespace Octokit.Tests.Reactive
{
public class ObservableCommitCommentReactionClientTests
{
public class TheGetAllMethod
{
private readonly IGitHubClient _githubClient;
private readonly IObservableReactionsClient _client;
private const string owner = "owner";
private const string name = "name";
public TheGetAllMethod()
{
_githubClient = Substitute.For<IGitHubClient>();
_client = new ObservableReactionsClient(_githubClient);
}
[Fact]
public void RequestsCorrectUrl()
{
_client.CommitComments.GetAll("fake", "repo", 42);
_githubClient.Received().Reaction.CommitComments.GetAll("fake", "repo", 42);
}
[Fact]
public void EnsuresArgumentsNotNull()
{
Assert.Throws<ArgumentNullException>(() => _client.CommitComments.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart)));
Assert.Throws<ArgumentException>(() => _client.CommitComments.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart)));
Assert.Throws<ArgumentNullException>(() => _client.CommitComments.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart)));
Assert.Throws<ArgumentException>(() => _client.CommitComments.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart)));
Assert.Throws<ArgumentException>(() => _client.CommitComments.CreateReaction("owner", "name", 1, null));
}
}
public class TheCreateMethod
{
[Fact]
public void RequestsCorrectUrl()
{
var githubClient = Substitute.For<IGitHubClient>();
var client = new ObservableReactionsClient(githubClient);
var newReaction = new NewReaction(ReactionType.Confused);
client.CommitComments.CreateReaction("fake", "repo", 1, newReaction);
githubClient.Received().Reaction.CommitComments.CreateReaction("fake", "repo", 1, newReaction);
}
}
}
}
@@ -1,54 +0,0 @@
using NSubstitute;
using Octokit.Reactive;
using System;
using Xunit;
namespace Octokit.Tests.Reactive
{
public class ObservableReactionsClientTests
{
public class CommitComments
{
public class TheGetMethod
{
[Fact]
public void RequestsCorrectUrl()
{
var githubClient = Substitute.For<IGitHubClient>();
var client = new ObservableReactionsClient(githubClient);
client.CommitComments.GetAll("fake", "repo", 42);
githubClient.Received().Reaction.CommitComments.GetAll("fake", "repo", 42);
}
[Fact]
public void EnsuresArgumentsNotNull()
{
var githubClient = Substitute.For<IGitHubClient>();
var client = new ObservableReactionsClient(githubClient);
Assert.Throws<ArgumentNullException>(() => client.CommitComments.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart)));
Assert.Throws<ArgumentException>(() => client.CommitComments.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart)));
Assert.Throws<ArgumentNullException>(() => client.CommitComments.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart)));
Assert.Throws<ArgumentException>(() => client.CommitComments.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart)));
Assert.Throws<ArgumentException>(() => client.CommitComments.CreateReaction("owner", "name", 1, null));
}
}
public class TheCreateMethod
{
[Fact]
public void RequestsCorrectUrl()
{
var githubClient = Substitute.For<IGitHubClient>();
var client = new ObservableReactionsClient(githubClient);
var newReaction = new NewReaction(ReactionType.Confused);
client.CommitComments.CreateReaction("fake", "repo", 1, newReaction);
githubClient.Received().Reaction.CommitComments.CreateReaction("fake", "repo", 1, newReaction);
}
}
}
}
}