diff --git a/Octokit.Tests/Clients/StatisticsClientTests.cs b/Octokit.Tests/Clients/StatisticsClientTests.cs new file mode 100644 index 00000000..1dae35c3 --- /dev/null +++ b/Octokit.Tests/Clients/StatisticsClientTests.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using NSubstitute; +using Octokit.Tests.Helpers; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class StatisticsClientTests + { + public class TheConstructor + { + [Fact] + public void DoesThrowOnBadArguments() + { + Assert.Throws(() => new StatisticsClient(null)); + } + } + + public class TheGetContributorsMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var expectedEndPoint = new Uri("/repos/username/repositoryName/stats/contributors", UriKind.Relative); + + var connection = Substitute.For(); + var client = Substitute.For(); + client.Connection.Returns(connection); + var statisticsClient = new StatisticsClient(client); + + statisticsClient.Contributors("username","repositoryName"); + + connection.Received().GetAsync>(expectedEndPoint); + } + + [Fact] + public async Task ThrowsIfGivenNullOwner() + { + var statisticsClient = new StatisticsClient(Substitute.For()); + await AssertEx.Throws(() => statisticsClient.Contributors(null,"repositoryName")); + } + + [Fact] + public async Task ThrowsIfGivenNullRepositoryName() + { + var statisticsClient = new StatisticsClient(Substitute.For()); + await AssertEx.Throws(() => statisticsClient.Contributors("owner", null)); + } + } + } +} \ No newline at end of file diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index a558ecfa..05307427 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -75,6 +75,7 @@ +