From 8222fd92462d65af0569cdb85708519f30daaae7 Mon Sep 17 00:00:00 2001 From: Andy Cross Date: Mon, 20 Jan 2014 15:07:38 +0000 Subject: [PATCH] missing test changes & correct tests which were calling Repositories.Get --- .../Clients/RepositoriesClientTests.cs | 29 +--------- .../Clients/RepositoryHooksClientTest.cs | 57 +++++++++++++++++++ Octokit.Tests/Octokit.Tests.csproj | 1 + Octokit/Clients/RepositoryHooksClient.cs | 1 - 4 files changed, 61 insertions(+), 27 deletions(-) create mode 100644 Octokit.Tests/Clients/RepositoryHooksClientTest.cs diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index c3f9e4ee..b3e2f28a 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -32,7 +32,7 @@ namespace Octokit.Tests.Clients await AssertEx.Throws(async () => await client.Create(null)); await AssertEx.Throws(async () => await client.Create(new NewRepository { Name = null })); } - + [Fact] public void UsesTheUserReposUrl() { @@ -224,9 +224,9 @@ namespace Octokit.Tests.Clients var readme = await reposEndpoint.GetReadme("fake", "repo"); Assert.Equal("README.md", readme.Name); - connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/readme"), + connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/readme"), null); - connection.DidNotReceive().GetHtml(Arg.Is(u => u.ToString() == "https://github.example.com/readme"), + connection.DidNotReceive().GetHtml(Arg.Is(u => u.ToString() == "https://github.example.com/readme"), null); var htmlReadme = await readme.GetHtmlContent(); Assert.Equal("README", htmlReadme); @@ -249,28 +249,5 @@ namespace Octokit.Tests.Clients Assert.Equal("README", readme); } } - - public class TheGetMethodForRepositoryHooks - { - [Fact] - public void RequestsCorrectUrl() - { - var connection = Substitute.For(); - var client = new RepositoriesClient(connection); - - client.Hooks.GetHooks("fake", "repo"); - - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks")); - } - - [Fact] - public async Task EnsuresNonNullArguments() - { - var client = new RepositoriesClient(Substitute.For()); - - await AssertEx.Throws(async () => await client.Get(null, "name")); - await AssertEx.Throws(async () => await client.Get("owner", null)); - } - } } } diff --git a/Octokit.Tests/Clients/RepositoryHooksClientTest.cs b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs new file mode 100644 index 00000000..8f74631c --- /dev/null +++ b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs @@ -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(); + var client = new RepositoriesClient(connection); + + client.Hooks.GetHooks("fake", "repo"); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new RepositoriesClient(Substitute.For()); + + await AssertEx.Throws(async () => await client.Hooks.GetHooks(null, "name")); + await AssertEx.Throws(async () => await client.Hooks.GetHooks("owner", null)); + } + } + + public class TheGetByIdMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + + client.Hooks.GetHookById("fake", "repo", 12345678); + + connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks/12345678"), null); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new RepositoriesClient(Substitute.For()); + + await AssertEx.Throws(async () => await client.Hooks.GetHookById(null, "name", 123)); + await AssertEx.Throws(async () => await client.Hooks.GetHookById("owner", null, 123)); + } + } + } +} diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 2e399b78..fbfe1789 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -66,6 +66,7 @@ + diff --git a/Octokit/Clients/RepositoryHooksClient.cs b/Octokit/Clients/RepositoryHooksClient.cs index 2279284c..d41965e1 100644 --- a/Octokit/Clients/RepositoryHooksClient.cs +++ b/Octokit/Clients/RepositoryHooksClient.cs @@ -38,7 +38,6 @@ namespace Octokit { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - Ensure.ArgumentNotNull(hookId, "hookId"); return ApiConnection.Get(ApiUrls.RepositoryHooksById(owner, repositoryName, hookId)); }