Skip to content

Commit

Permalink
[WIP] unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
martinscholz83 committed Sep 5, 2016
1 parent fb3b226 commit c9a1302
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
46 changes: 46 additions & 0 deletions Octokit.Tests/Clients/RepositoryTrafficClientTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using NSubstitute;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xunit;

namespace Octokit.Tests.Clients
{
public class RepositoryTrafficClientTests
{
public class TheCtor
{
[Fact]
public void EnsuresNonNullArguments()
{
Assert.Throws<ArgumentNullException>(
() => new RepositoryTrafficClient(null));
}
}

public class TheGetAllRefererrsMethod
{
[Fact]
public async Task RequestsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoryTrafficClient(connection);

await client.GetAllReferrers("fake", "repo");

connection.Received().GetAll<RepositoryTrafficReferrer>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/traffic/popular/referrers"), "application/vnd.github.spiderman-preview");
}

[Fact]
public async Task RequestsCorrectUrlWithRepositoryId()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoryTrafficClient(connection);

await client.GetAllReferrers(1);

connection.Received().GetAll<RepositoryTrafficReferrer>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/traffic/popular/referrers"), "application/vnd.github.spiderman-preview");
}
}
}
}
1 change: 1 addition & 0 deletions Octokit.Tests/Octokit.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<Compile Include="Clients\RepositoryContentsClientTests.cs" />
<Compile Include="Clients\RepositoryInvitationsClientTests.cs" />
<Compile Include="Clients\RepositoryPagesClientTests.cs" />
<Compile Include="Clients\RepositoryTrafficClientTests.cs" />
<Compile Include="Clients\RespositoryCommitsClientTests.cs" />
<Compile Include="Clients\SearchClientTests.cs" />
<Compile Include="Clients\GistCommentsClientTests.cs" />
Expand Down

0 comments on commit c9a1302

Please sign in to comment.