-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb3b226
commit c9a1302
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters