Files
octokit.net/Octokit.Tests.Integration/Clients/RepositoryTrafficClientTests.cs
Ryan Gribble 1e474f8556 Enable pagination convention tests (#1659)
* Unskip pagination convention tests and rework exclusion property names
Also exclude Obsolete methods from pagination convention tests

* Reaction APIs appear to support pagination, flag to exclude for now and mark a TODO that they need implementing

* Repository invitation APIs need pagination implemented

* Exclude methods that use an alternative pagination approach

* Migrations, Licenses and References all need pagination implemented

* Pagination not supported for these methods (determined by API doc and poking the API) so exclude them from convention tests

* These methods need renaming to GetAll

* Rename offending RepositoryTrafficClient GetReferrers and GetPaths to GetAllReferrers and GetAllPaths

* Rename offending RepositoryBranchesClient methods from Get to GetAll
2017-09-03 11:50:02 +10:00

112 lines
3.8 KiB
C#

using Octokit;
using Octokit.Tests.Integration;
using System.Threading.Tasks;
using Xunit;
public class RepositoryTrafficClientTests
{
readonly IRepositoryTrafficClient _fixture;
readonly IGitHubClient _github;
readonly string _owner;
readonly string _repo;
readonly long _repoId;
public RepositoryTrafficClientTests()
{
_github = Helper.GetAuthenticatedClient();
_fixture = _github.Repository.Traffic;
_owner = "octokit";
_repo = "octokit.net";
_repoId = _github.Repository.Get(_owner, _repo).Result.Id;
}
public class TheGetAllReferrersMethod : RepositoryTrafficClientTests
{
[IntegrationTest(Skip = "This test needs to be an administrator of the Octokit.net repository")]
public async Task GetsReferrers()
{
var referrers = await _fixture.GetAllReferrers(_owner, _repo);
Assert.True(referrers.Count > 0);
}
[IntegrationTest(Skip = "This test needs to be an administrator of the Octokit.net repository")]
public async Task GetsReferrersWithRepositoryId()
{
var referrers = await _fixture.GetAllReferrers(_repoId);
Assert.True(referrers.Count > 0);
}
}
public class TheGetAllPathsMethod : RepositoryTrafficClientTests
{
[IntegrationTest(Skip = "This test needs to be an administrator of the Octokit.net repository")]
public async Task GetsPaths()
{
var paths = await _fixture.GetAllPaths(_owner, _repo);
Assert.True(paths.Count > 0);
}
[IntegrationTest(Skip = "This test needs to be an administrator of the Octokit.net repository")]
public async Task GetsPathsWithRepositoryId()
{
var paths = await _fixture.GetAllPaths(_repoId);
Assert.True(paths.Count > 0);
}
}
public class TheGetClonesMethod : RepositoryTrafficClientTests
{
[IntegrationTest(Skip = "This test needs to be an administrator of the Octokit.net repository")]
public async Task GetsClones()
{
var request = new RepositoryTrafficRequest(TrafficDayOrWeek.Day);
var clones = await _fixture.GetClones(_owner, _repo, request);
Assert.True(clones.Count > 0);
Assert.True(clones.Clones.Count > 0);
Assert.True(clones.Uniques > 0);
}
[IntegrationTest(Skip = "This test needs to be an administrator of the Octokit.net repository")]
public async Task GetsClonesWithRepositoryId()
{
var request = new RepositoryTrafficRequest(TrafficDayOrWeek.Day);
var clones = await _fixture.GetClones(_repoId, request);
Assert.True(clones.Count > 0);
Assert.True(clones.Clones.Count > 0);
Assert.True(clones.Uniques > 0);
}
}
public class TheGetViewsMethod : RepositoryTrafficClientTests
{
[IntegrationTest(Skip = "This test needs to be an administrator of the Octokit.net repository")]
public async Task GetsViews()
{
var request = new RepositoryTrafficRequest(TrafficDayOrWeek.Day);
var views = await _fixture.GetViews(_owner, _repo, request);
Assert.True(views.Count > 0);
Assert.True(views.Views.Count > 0);
Assert.True(views.Uniques > 0);
}
[IntegrationTest(Skip = "This test needs to be an administrator of the Octokit.net repository")]
public async Task GetsViewsWithRepositoryId()
{
var request = new RepositoryTrafficRequest(TrafficDayOrWeek.Day);
var views = await _fixture.GetViews(_repoId, request);
Assert.True(views.Count > 0);
Assert.True(views.Views.Count > 0);
Assert.True(views.Uniques > 0);
}
}
}