From fd9565d4fdaba3082b6c76eb4bcf2a138b7f968e Mon Sep 17 00:00:00 2001 From: Kyle Nunery Date: Sat, 2 Nov 2013 14:24:38 -0500 Subject: [PATCH] Add 'correct url' tests for issue events client --- .../Clients/IssuesEventsClientTests.cs | 82 +++++++++++++++++++ Octokit.Tests/OctoKit.Tests-NetCore45.csproj | 1 + Octokit.Tests/Octokit.Tests.csproj | 1 + 3 files changed, 84 insertions(+) create mode 100644 Octokit.Tests/Clients/IssuesEventsClientTests.cs diff --git a/Octokit.Tests/Clients/IssuesEventsClientTests.cs b/Octokit.Tests/Clients/IssuesEventsClientTests.cs new file mode 100644 index 00000000..2d3a1555 --- /dev/null +++ b/Octokit.Tests/Clients/IssuesEventsClientTests.cs @@ -0,0 +1,82 @@ +using System; +using System.Threading.Tasks; +using NSubstitute; +using Octokit.Tests.Helpers; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class IssuesEventsClientTests + { + public class TheGetForIssueMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new IssuesEventsClient(connection); + + await client.GetForIssue("fake", "repo", 42); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/events")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new IssuesEventsClient(Substitute.For()); + + await AssertEx.Throws(async () => await client.Get(null, "name", 1)); + await AssertEx.Throws(async () => await client.Get("owner", null, 1)); + } + } + + public class TheGetForRepositoryMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new IssuesEventsClient(connection); + + await client.GetForRepository("fake", "repo"); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/events")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new IssuesEventsClient(Substitute.For()); + + await AssertEx.Throws(async () => await client.Get(null, "name", 1)); + await AssertEx.Throws(async () => await client.Get("owner", null, 1)); + } + } + + public class TheGetMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new IssuesEventsClient(connection); + + client.Get("fake", "repo", 42); + + connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/events/42"), + null); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new IssuesEventsClient(Substitute.For()); + + await AssertEx.Throws(async () => await client.Get(null, "name", 1)); + await AssertEx.Throws(async () => await client.Get("owner", null, 1)); + } + + } + } +} \ No newline at end of file diff --git a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj b/Octokit.Tests/OctoKit.Tests-NetCore45.csproj index ece5c192..c60f3747 100644 --- a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj +++ b/Octokit.Tests/OctoKit.Tests-NetCore45.csproj @@ -56,6 +56,7 @@ + diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 7434fab8..3e800293 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -64,6 +64,7 @@ +