missing test changes & correct tests which were calling Repositories.Get

This commit is contained in:
Andy Cross
2014-01-20 15:07:38 +00:00
parent a13c9fa3cc
commit 8222fd9246
4 changed files with 61 additions and 27 deletions

View File

@@ -249,28 +249,5 @@ namespace Octokit.Tests.Clients
Assert.Equal("<html>README</html>", readme);
}
}
public class TheGetMethodForRepositoryHooks
{
[Fact]
public void RequestsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoriesClient(connection);
client.Hooks.GetHooks("fake", "repo");
connection.Received().GetAll<RepositoryHook>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/hooks"));
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var client = new RepositoriesClient(Substitute.For<IApiConnection>());
await AssertEx.Throws<ArgumentNullException>(async () => await client.Get(null, "name"));
await AssertEx.Throws<ArgumentNullException>(async () => await client.Get("owner", null));
}
}
}
}

View File

@@ -0,0 +1,57 @@
using System;
using System.Threading.Tasks;
using NSubstitute;
using Octokit.Tests.Helpers;
using Xunit;
namespace Octokit.Tests.Clients
{
public class RepositoryHooksClientTests
{
public class TheGetMethod
{
[Fact]
public void RequestsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoriesClient(connection);
client.Hooks.GetHooks("fake", "repo");
connection.Received().GetAll<RepositoryHook>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/hooks"));
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var client = new RepositoriesClient(Substitute.For<IApiConnection>());
await AssertEx.Throws<ArgumentNullException>(async () => await client.Hooks.GetHooks(null, "name"));
await AssertEx.Throws<ArgumentNullException>(async () => await client.Hooks.GetHooks("owner", null));
}
}
public class TheGetByIdMethod
{
[Fact]
public void RequestsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoriesClient(connection);
client.Hooks.GetHookById("fake", "repo", 12345678);
connection.Received().Get<RepositoryHook>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/hooks/12345678"), null);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var client = new RepositoriesClient(Substitute.For<IApiConnection>());
await AssertEx.Throws<ArgumentNullException>(async () => await client.Hooks.GetHookById(null, "name", 123));
await AssertEx.Throws<ArgumentNullException>(async () => await client.Hooks.GetHookById("owner", null, 123));
}
}
}
}

View File

@@ -66,6 +66,7 @@
<Compile Include="Clients\IssuesClientTests.cs" />
<Compile Include="Clients\NotificationsClientTests.cs" />
<Compile Include="Clients\ReleasesClientTests.cs" />
<Compile Include="Clients\RepositoryHooksClientTest.cs" />
<Compile Include="Clients\SshKeysClientTests.cs" />
<Compile Include="Exceptions\ApiExceptionTests.cs" />
<Compile Include="Exceptions\ApiValidationExceptionTests.cs" />

View File

@@ -38,7 +38,6 @@ namespace Octokit
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
Ensure.ArgumentNotNull(hookId, "hookId");
return ApiConnection.Get<RepositoryHook>(ApiUrls.RepositoryHooksById(owner, repositoryName, hookId));
}