Test stats client get contributors

This commit is contained in:
Amy Palamountain
2014-01-11 10:33:39 +13:00
parent feb52c0a69
commit 29461db857
2 changed files with 54 additions and 0 deletions
@@ -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<ArgumentNullException>(() => 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<IConnection>();
var client = Substitute.For<IApiConnection>();
client.Connection.Returns(connection);
var statisticsClient = new StatisticsClient(client);
statisticsClient.Contributors("username","repositoryName");
connection.Received().GetAsync<IList<Contributor>>(expectedEndPoint);
}
[Fact]
public async Task ThrowsIfGivenNullOwner()
{
var statisticsClient = new StatisticsClient(Substitute.For<IApiConnection>());
await AssertEx.Throws<ArgumentNullException>(() => statisticsClient.Contributors(null,"repositoryName"));
}
[Fact]
public async Task ThrowsIfGivenNullRepositoryName()
{
var statisticsClient = new StatisticsClient(Substitute.For<IApiConnection>());
await AssertEx.Throws<ArgumentNullException>(() => statisticsClient.Contributors("owner", null));
}
}
}
}
+1
View File
@@ -75,6 +75,7 @@
<Compile Include="Clients\AssigneesClientTests.cs" />
<Compile Include="Clients\CommitsClientTests.cs" />
<Compile Include="Clients\CommitStatusClientTests.cs" />
<Compile Include="Clients\StatisticsClientTests.cs" />
<Compile Include="Clients\TeamsClientTests.cs" />
<Compile Include="Clients\GitDatabaseClientTests.cs" />
<Compile Include="Clients\OrganizationMembersClientTests.cs" />