From 3580c1362377e93bbb5091ec4ff3bc9f407f8f79 Mon Sep 17 00:00:00 2001 From: Amy Palamountain Date: Sun, 2 Feb 2014 14:29:00 +1300 Subject: [PATCH] Basic unit tests for hourly commits --- .../Clients/StatisticsClientTests.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Octokit.Tests/Clients/StatisticsClientTests.cs b/Octokit.Tests/Clients/StatisticsClientTests.cs index e2236be9..38c86616 100644 --- a/Octokit.Tests/Clients/StatisticsClientTests.cs +++ b/Octokit.Tests/Clients/StatisticsClientTests.cs @@ -145,5 +145,37 @@ namespace Octokit.Tests.Clients await AssertEx.Throws(() => statisticsClient.GetCommitCountsPerWeek("owner", null)); } } + + public class TheGetHourlyCommitCountsMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var expectedEndPoint = new Uri("/repos/username/repositoryName/stats/punch_card", UriKind.Relative); + + var connection = Substitute.For(); + var client = Substitute.For(); + client.Connection.Returns(connection); + var statisticsClient = new StatisticsClient(client); + + statisticsClient.GetCommitPerHour("username", "repositoryName"); + + connection.Received().GetAsync>(expectedEndPoint); + } + + [Fact] + public async Task ThrowsIfGivenNullOwner() + { + var statisticsClient = new StatisticsClient(Substitute.For()); + await AssertEx.Throws(() => statisticsClient.GetCommitPerHour(null, "repositoryName")); + } + + [Fact] + public async Task ThrowsIfGivenNullRepositoryName() + { + var statisticsClient = new StatisticsClient(Substitute.For()); + await AssertEx.Throws(() => statisticsClient.GetCommitPerHour("owner", null)); + } + } } } \ No newline at end of file