diff --git a/Octokit.Tests/Clients/RepositoryHooksClientTest.cs b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs index 5b750bed..4a3027f9 100644 --- a/Octokit.Tests/Clients/RepositoryHooksClientTest.cs +++ b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs @@ -21,22 +21,34 @@ namespace Octokit.Tests.Clients public class TheGetAllMethod { [Fact] - public void RequestsCorrectUrl() + public async Task RequestsCorrectUrl() { var connection = Substitute.For(); - var client = new RepositoriesClient(connection); + var client = new RepositoryHooksClient(connection); - client.Hooks.GetAll("fake", "repo"); + await client.GetAll("fake", "repo"); connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks"), Args.ApiOptions); } [Fact] - public void RequestsCorrectUrlWithApiOptions() + public async Task RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For(); - var client = new RepositoriesClient(connection); + var client = new RepositoryHooksClient(connection); + + await client.GetAll(1); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/hooks"), + Args.ApiOptions); + } + + [Fact] + public async Task RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new RepositoryHooksClient(connection); var options = new ApiOptions { @@ -45,43 +57,87 @@ namespace Octokit.Tests.Clients StartPage = 1 }; - client.Hooks.GetAll("fake", "repo", options); + await client.GetAll("fake", "repo", options); connection.Received(1) .GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks"), options); } + [Fact] + public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions() + { + var connection = Substitute.For(); + var client = new RepositoryHooksClient(connection); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + + await client.GetAll(1, options); + + connection.Received(1) + .GetAll(Arg.Is(u => u.ToString() == "repositories/1/hooks"), + options); + } + [Fact] public async Task EnsuresNonNullArguments() { - var client = new RepositoriesClient(Substitute.For()); + var client = new RepositoryHooksClient(Substitute.For()); - await Assert.ThrowsAsync(() => client.Hooks.GetAll(null, "name")); - await Assert.ThrowsAsync(() => client.Hooks.GetAll("owner", null)); + await Assert.ThrowsAsync(() => client.GetAll(null, "name")); + await Assert.ThrowsAsync(() => client.GetAll("owner", null)); + await Assert.ThrowsAsync(() => client.GetAll(null, "name", ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAll("owner", null, ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAll("owner", "name", null)); + + await Assert.ThrowsAsync(() => client.GetAll(1, null)); + + await Assert.ThrowsAsync(() => client.GetAll("", "name")); + await Assert.ThrowsAsync(() => client.GetAll("owner", "")); + await Assert.ThrowsAsync(() => client.GetAll("", "name", ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAll("owner", "", ApiOptions.None)); } } public class TheGetMethod { [Fact] - public void RequestsCorrectUrl() + public async Task RequestsCorrectUrl() { var connection = Substitute.For(); - var client = new RepositoriesClient(connection); + var client = new RepositoryHooksClient(connection); - client.Hooks.Get("fake", "repo", 12345678); + await client.Get("fake", "repo", 12345678); connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks/12345678")); } + [Fact] + public async Task RequestsCorrectUrlWithRepositoryId() + { + var connection = Substitute.For(); + var client = new RepositoryHooksClient(connection); + + await client.Get(1, 12345678); + + connection.Received().Get(Arg.Is(u => u.ToString() == "repositories/1/hooks/12345678")); + } + [Fact] public async Task EnsuresNonNullArguments() { - var client = new RepositoriesClient(Substitute.For()); + var client = new RepositoryHooksClient(Substitute.For()); - await Assert.ThrowsAsync(() => client.Hooks.Get(null, "name", 123)); - await Assert.ThrowsAsync(() => client.Hooks.Get("owner", null, 123)); + await Assert.ThrowsAsync(() => client.Get(null, "name", 123)); + await Assert.ThrowsAsync(() => client.Get("owner", null, 123)); + + await Assert.ThrowsAsync(() => client.Get("", "name", 123)); + await Assert.ThrowsAsync(() => client.Get("owner", "", 123)); } } @@ -91,35 +147,43 @@ namespace Octokit.Tests.Clients public void RequestsCorrectUrl() { var connection = Substitute.For(); - var client = new RepositoriesClient(connection); + var client = new RepositoryHooksClient(connection); + var hook = new NewRepositoryHook("name", new Dictionary { { "config", "" } }); - client.Hooks.Create("fake", "repo", hook); + client.Create("fake", "repo", hook); connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks"), hook); } [Fact] - public async Task EnsuresNonNullArguments() + public void RequestsCorrectUrlWithRepositoryId() { - var client = new RepositoriesClient(Substitute.For()); + var connection = Substitute.For(); + var client = new RepositoryHooksClient(connection); - var config = new Dictionary { { "config", "" } }; - await Assert.ThrowsAsync(() => client.Hooks.Create(null, "name", new NewRepositoryHook("name", config))); - await Assert.ThrowsAsync(() => client.Hooks.Create("owner", null, new NewRepositoryHook("name", config))); - await Assert.ThrowsAsync(() => client.Hooks.Create("owner", "name", null)); + var hook = new NewRepositoryHook("name", new Dictionary { { "config", "" } }); + + client.Create(1, hook); + + connection.Received().Post(Arg.Is(u => u.ToString() == "repositories/1/hooks"), hook); } [Fact] - public void UsesTheSuppliedHook() + public async Task EnsuresNonNullArguments() { - var connection = Substitute.For(); - var client = new RepositoriesClient(connection); - var newRepositoryHook = new NewRepositoryHook("name", new Dictionary { { "config", "" } }); + var client = new RepositoryHooksClient(Substitute.For()); - client.Hooks.Create("owner", "repo", newRepositoryHook); + var config = new Dictionary { { "config", "" } }; - connection.Received().Post(Arg.Any(), newRepositoryHook); + await Assert.ThrowsAsync(() => client.Create(null, "name", new NewRepositoryHook("name", config))); + await Assert.ThrowsAsync(() => client.Create("owner", null, new NewRepositoryHook("name", config))); + await Assert.ThrowsAsync(() => client.Create("owner", "name", null)); + + await Assert.ThrowsAsync(() => client.Create(1, null)); + + await Assert.ThrowsAsync(() => client.Create("", "name", new NewRepositoryHook("name", config))); + await Assert.ThrowsAsync(() => client.Create("owner", "", new NewRepositoryHook("name", config))); } } @@ -129,34 +193,41 @@ namespace Octokit.Tests.Clients public void RequestsCorrectUrl() { var connection = Substitute.For(); - var client = new RepositoriesClient(connection); + var client = new RepositoryHooksClient(connection); + var hook = new EditRepositoryHook(); - client.Hooks.Edit("fake", "repo", 12345678, hook); + client.Edit("fake", "repo", 12345678, hook); connection.Received().Patch(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks/12345678"), hook); } [Fact] - public async Task EnsuresNonNullArguments() + public void RequestsCorrectUrlWithRepositoryId() { - var client = new RepositoriesClient(Substitute.For()); + var connection = Substitute.For(); + var client = new RepositoryHooksClient(connection); - await Assert.ThrowsAsync(() => client.Hooks.Edit(null, "name", 12345678, new EditRepositoryHook())); - await Assert.ThrowsAsync(() => client.Hooks.Edit("owner", null, 12345678, new EditRepositoryHook())); - await Assert.ThrowsAsync(() => client.Hooks.Edit("owner", "name", 12345678, null)); + var hook = new EditRepositoryHook(); + + client.Edit(1, 12345678, hook); + + connection.Received().Patch(Arg.Is(u => u.ToString() == "repositories/1/hooks/12345678"), hook); } [Fact] - public void UsesTheSuppliedHook() + public async Task EnsuresNonNullArguments() { - var connection = Substitute.For(); - var client = new RepositoriesClient(connection); - var editRepositoryHook = new EditRepositoryHook { Active = false }; + var client = new RepositoryHooksClient(Substitute.For()); - client.Hooks.Edit("owner", "repo", 12345678, editRepositoryHook); + await Assert.ThrowsAsync(() => client.Edit(null, "name", 12345678, new EditRepositoryHook())); + await Assert.ThrowsAsync(() => client.Edit("owner", null, 12345678, new EditRepositoryHook())); + await Assert.ThrowsAsync(() => client.Edit("owner", "name", 12345678, null)); - connection.Received().Patch(Arg.Any(), editRepositoryHook); + await Assert.ThrowsAsync(() => client.Edit(1, 12345678, null)); + + await Assert.ThrowsAsync(() => client.Edit("", "name", 12345678, new EditRepositoryHook())); + await Assert.ThrowsAsync(() => client.Edit("owner", "", 12345678, new EditRepositoryHook())); } } @@ -166,44 +237,72 @@ namespace Octokit.Tests.Clients public void RequestsCorrectUrl() { var connection = Substitute.For(); - var client = new RepositoriesClient(connection); + var client = new RepositoryHooksClient(connection); - client.Hooks.Test("fake", "repo", 12345678); + client.Test("fake", "repo", 12345678); connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks/12345678/tests")); } + [Fact] + public void RequestsCorrectUrlWithRepositoryId() + { + var connection = Substitute.For(); + var client = new RepositoryHooksClient(connection); + + client.Test(1, 12345678); + + connection.Received().Post(Arg.Is(u => u.ToString() == "repositories/1/hooks/12345678/tests")); + } + [Fact] public async Task EnsuresNonNullArguments() { - var client = new RepositoriesClient(Substitute.For()); + var client = new RepositoryHooksClient(Substitute.For()); - await Assert.ThrowsAsync(() => client.Hooks.Test(null, "name", 12345678)); - await Assert.ThrowsAsync(() => client.Hooks.Test("owner", null, 12345678)); + await Assert.ThrowsAsync(() => client.Test(null, "name", 12345678)); + await Assert.ThrowsAsync(() => client.Test("owner", null, 12345678)); + + await Assert.ThrowsAsync(() => client.Test("", "name", 12345678)); + await Assert.ThrowsAsync(() => client.Test("owner", "", 12345678)); } } public class ThePingMethod { - [Fact] - public async Task EnsuresNonNullArguments() - { - var client = new RepositoriesClient(Substitute.For()); - - await Assert.ThrowsAsync(() => client.Hooks.Ping(null, "name", 12345678)); - await Assert.ThrowsAsync(() => client.Hooks.Ping("owner", null, 12345678)); - } - [Fact] public void RequestsCorrectUrl() { var connection = Substitute.For(); - var client = new RepositoriesClient(connection); + var client = new RepositoryHooksClient(connection); - client.Hooks.Ping("fake", "repo", 12345678); + client.Ping("fake", "repo", 12345678); connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks/12345678/pings")); } + + [Fact] + public void RequestsCorrectUrlWithRepositoryId() + { + var connection = Substitute.For(); + var client = new RepositoryHooksClient(connection); + + client.Ping(1, 12345678); + + connection.Received().Post(Arg.Is(u => u.ToString() == "repositories/1/hooks/12345678/pings")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new RepositoryHooksClient(Substitute.For()); + + await Assert.ThrowsAsync(() => client.Ping(null, "name", 12345678)); + await Assert.ThrowsAsync(() => client.Ping("owner", null, 12345678)); + + await Assert.ThrowsAsync(() => client.Ping("", "name", 12345678)); + await Assert.ThrowsAsync(() => client.Ping("owner", "", 12345678)); + } } public class TheDeleteMethod @@ -212,20 +311,34 @@ namespace Octokit.Tests.Clients public void RequestsCorrectUrl() { var connection = Substitute.For(); - var client = new RepositoriesClient(connection); + var client = new RepositoryHooksClient(connection); - client.Hooks.Delete("fake", "repo", 12345678); + client.Delete("fake", "repo", 12345678); connection.Received().Delete(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks/12345678")); } + [Fact] + public void RequestsCorrectUrlWithRepositoryId() + { + var connection = Substitute.For(); + var client = new RepositoryHooksClient(connection); + + client.Delete(1, 12345678); + + connection.Received().Delete(Arg.Is(u => u.ToString() == "repositories/1/hooks/12345678")); + } + [Fact] public async Task EnsuresNonNullArguments() { - var client = new RepositoriesClient(Substitute.For()); + var client = new RepositoryHooksClient(Substitute.For()); - await Assert.ThrowsAsync(() => client.Hooks.Delete(null, "name", 12345678)); - await Assert.ThrowsAsync(() => client.Hooks.Delete("owner", null, 12345678)); + await Assert.ThrowsAsync(() => client.Delete(null, "name", 12345678)); + await Assert.ThrowsAsync(() => client.Delete("owner", null, 12345678)); + + await Assert.ThrowsAsync(() => client.Delete("", "name", 12345678)); + await Assert.ThrowsAsync(() => client.Delete("owner", "", 12345678)); } } } diff --git a/Octokit.Tests/Reactive/ObservableRepositoryHooksClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryHooksClientTests.cs index f3c7961c..e5d529bf 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryHooksClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryHooksClientTests.cs @@ -8,82 +8,332 @@ namespace Octokit.Tests.Reactive { public class ObservableRepositoryHooksClientTests { - public class ObservableAuthorizationsClientTests - { - const string owner = "owner"; - const string repositoryName = "name"; - - public class TheGetAllMethod - { - [Fact] - public void GetsCorrectUrl() - { - var client = Substitute.For(); - var authEndpoint = new ObservableRepositoryHooksClient(client); - var expectedUrl = string.Format("repos/{0}/{1}/hooks", owner, repositoryName); - - authEndpoint.GetAll(owner, repositoryName); - - client.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == expectedUrl), - Arg.Is>(dictionary => dictionary.Count == 0), null); - } - - [Fact] - public void GetsCorrectUrlWithApiOption() - { - var gitHubClient = Substitute.For(); - var hooksClient = new ObservableRepositoryHooksClient(gitHubClient); - var expectedUrl = string.Format("repos/{0}/{1}/hooks", owner, repositoryName); - - // all properties are setted => only 2 options (StartPage, PageSize) in dictionary - var options = new ApiOptions - { - StartPage = 1, - PageCount = 1, - PageSize = 1 - }; - - hooksClient.GetAll(owner, repositoryName, options); - gitHubClient.Connection.Received(1) - .Get>(Arg.Is(u => u.ToString() == expectedUrl), - Arg.Is>(dictionary => dictionary.Count == 2), - null); - - // StartPage is setted => only 1 option (StartPage) in dictionary - options = new ApiOptions - { - StartPage = 1 - }; - - hooksClient.GetAll(owner, repositoryName, options); - gitHubClient.Connection.Received(1) - .Get>(Arg.Is(u => u.ToString() == expectedUrl), - Arg.Is>(dictionary => dictionary.Count == 1), - null); - - // PageCount is setted => none of options in dictionary - options = new ApiOptions - { - PageCount = 1 - }; - - hooksClient.GetAll(owner, repositoryName, options); - gitHubClient.Connection.Received(1) - .Get>(Arg.Is(u => u.ToString() == expectedUrl), - Arg.Is>(dictionary => dictionary.Count == 0), - null); - } - } - } - public class TheCtor { [Fact] public void EnsuresNonNullArguments() { Assert.Throws( - () => new ObservableRepositoryHooksClient(null)); + () => new ObservableRepositoryHooksClient(null)); + } + } + + public class TheGetAllMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableRepositoryHooksClient(gitHubClient); + + client.GetAll("fake", "repo"); + + gitHubClient.Received().Repository.Hooks.GetAll("fake", "repo"); + } + + [Fact] + public void RequestsCorrectUrlWithRepositoryId() + { + var gitHubClient = Substitute.For(); + var client = new ObservableRepositoryHooksClient(gitHubClient); + + client.GetAll(1); + + gitHubClient.Received().Repository.Hooks.GetAll(1); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableRepositoryHooksClient(gitHubClient); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + + client.GetAll("fake", "repo", options); + + gitHubClient.Received(1).Repository.Hooks.GetAll("fake", "repo", options); + } + + [Fact] + public void RequestsCorrectUrlWithRepositoryIdWithApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableRepositoryHooksClient(gitHubClient); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + + client.GetAll(1, options); + + gitHubClient.Received(1).Repository.Hooks.GetAll(1, options); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservableRepositoryHooksClient(Substitute.For()); + + Assert.Throws(() => client.GetAll(null, "name")); + Assert.Throws(() => client.GetAll("owner", null)); + Assert.Throws(() => client.GetAll(null, "name", ApiOptions.None)); + Assert.Throws(() => client.GetAll("owner", null, ApiOptions.None)); + Assert.Throws(() => client.GetAll("owner", "name", null)); + + Assert.Throws(() => client.GetAll(1, null)); + + Assert.Throws(() => client.GetAll("", "name")); + Assert.Throws(() => client.GetAll("owner", "")); + Assert.Throws(() => client.GetAll("", "name", ApiOptions.None)); + Assert.Throws(() => client.GetAll("owner", "", ApiOptions.None)); + } + } + + public class TheGetMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableRepositoryHooksClient(gitHubClient); + + client.Get("fake", "repo", 12345678); + + gitHubClient.Received().Repository.Hooks.Get("fake", "repo", 12345678); + } + + [Fact] + public void RequestsCorrectUrlWithRepositoryId() + { + var gitHubClient = Substitute.For(); + var client = new ObservableRepositoryHooksClient(gitHubClient); + + client.Get(1, 12345678); + + gitHubClient.Received().Repository.Hooks.Get(1, 12345678); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservableRepositoryHooksClient(Substitute.For()); + + Assert.Throws(() => client.Get(null, "name", 123)); + Assert.Throws(() => client.Get("owner", null, 123)); + + Assert.Throws(() => client.Get("", "name", 123)); + Assert.Throws(() => client.Get("owner", "", 123)); + } + } + + public class TheCreateMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableRepositoryHooksClient(gitHubClient); + + var hook = new NewRepositoryHook("name", new Dictionary { { "config", "" } }); + + client.Create("fake", "repo", hook); + + gitHubClient.Received().Repository.Hooks.Create("fake", "repo", hook); + } + + [Fact] + public void RequestsCorrectUrlWithRepositoryId() + { + var gitHubClient = Substitute.For(); + var client = new ObservableRepositoryHooksClient(gitHubClient); + + var hook = new NewRepositoryHook("name", new Dictionary { { "config", "" } }); + + client.Create(1, hook); + + gitHubClient.Received().Repository.Hooks.Create(1, hook); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservableRepositoryHooksClient(Substitute.For()); + + var config = new Dictionary { { "config", "" } }; + + Assert.Throws(() => client.Create(null, "name", new NewRepositoryHook("name", config))); + Assert.Throws(() => client.Create("owner", null, new NewRepositoryHook("name", config))); + Assert.Throws(() => client.Create("owner", "name", null)); + + Assert.Throws(() => client.Create(1, null)); + + Assert.Throws(() => client.Create("", "name", new NewRepositoryHook("name", config))); + Assert.Throws(() => client.Create("owner", "", new NewRepositoryHook("name", config))); + } + } + + public class TheEditMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableRepositoryHooksClient(gitHubClient); + + var hook = new EditRepositoryHook(); + + client.Edit("fake", "repo", 12345678, hook); + + gitHubClient.Received().Repository.Hooks.Edit("fake", "repo", 12345678, hook); + } + + [Fact] + public void RequestsCorrectUrlWithRepositoryId() + { + var gitHubClient = Substitute.For(); + var client = new ObservableRepositoryHooksClient(gitHubClient); + + var hook = new EditRepositoryHook(); + + client.Edit(1, 12345678, hook); + + gitHubClient.Received().Repository.Hooks.Edit(1, 12345678, hook); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservableRepositoryHooksClient(Substitute.For()); + + Assert.Throws(() => client.Edit(null, "name", 12345678, new EditRepositoryHook())); + Assert.Throws(() => client.Edit("owner", null, 12345678, new EditRepositoryHook())); + Assert.Throws(() => client.Edit("owner", "name", 12345678, null)); + + Assert.Throws(() => client.Edit(1, 12345678, null)); + + Assert.Throws(() => client.Edit("", "name", 12345678, new EditRepositoryHook())); + Assert.Throws(() => client.Edit("owner", "", 12345678, new EditRepositoryHook())); + } + } + + public class TheTestMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableRepositoryHooksClient(gitHubClient); + + client.Test("fake", "repo", 12345678); + + gitHubClient.Received().Repository.Hooks.Test("fake", "repo", 12345678); + } + + [Fact] + public void RequestsCorrectUrlWithRepositoryId() + { + var gitHubClient = Substitute.For(); + var client = new ObservableRepositoryHooksClient(gitHubClient); + + client.Test(1, 12345678); + + gitHubClient.Received().Repository.Hooks.Test(1, 12345678); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservableRepositoryHooksClient(Substitute.For()); + + Assert.Throws(() => client.Test(null, "name", 12345678)); + Assert.Throws(() => client.Test("owner", null, 12345678)); + + Assert.Throws(() => client.Test("", "name", 12345678)); + Assert.Throws(() => client.Test("owner", "", 12345678)); + } + } + + public class ThePingMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableRepositoryHooksClient(gitHubClient); + + client.Ping("fake", "repo", 12345678); + + gitHubClient.Received().Repository.Hooks.Ping("fake", "repo", 12345678); + } + + [Fact] + public void RequestsCorrectUrlWithRepositoryId() + { + var gitHubClient = Substitute.For(); + var client = new ObservableRepositoryHooksClient(gitHubClient); + + client.Ping(1, 12345678); + + gitHubClient.Received().Repository.Hooks.Ping(1, 12345678); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservableRepositoryHooksClient(Substitute.For()); + + Assert.Throws(() => client.Ping(null, "name", 12345678)); + Assert.Throws(() => client.Ping("owner", null, 12345678)); + + Assert.Throws(() => client.Ping("", "name", 12345678)); + Assert.Throws(() => client.Ping("owner", "", 12345678)); + } + } + + public class TheDeleteMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableRepositoryHooksClient(gitHubClient); + + client.Delete("fake", "repo", 12345678); + + gitHubClient.Received().Repository.Hooks.Delete("fake", "repo", 12345678); + } + + [Fact] + public void RequestsCorrectUrlWithRepositoryId() + { + var gitHubClient = Substitute.For(); + var client = new ObservableRepositoryHooksClient(gitHubClient); + + client.Delete(1, 12345678); + + gitHubClient.Received().Repository.Hooks.Delete(1, 12345678); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservableRepositoryHooksClient(Substitute.For()); + + Assert.Throws(() => client.Delete(null, "name", 12345678)); + Assert.Throws(() => client.Delete("owner", null, 12345678)); + + Assert.Throws(() => client.Delete("", "name", 12345678)); + Assert.Throws(() => client.Delete("owner", "", 12345678)); } } } -} \ No newline at end of file +}