mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-20 14:15:12 +00:00
missing test changes & correct tests which were calling Repositories.Get
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
57
Octokit.Tests/Clients/RepositoryHooksClientTest.cs
Normal file
57
Octokit.Tests/Clients/RepositoryHooksClientTest.cs
Normal 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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" />
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user