mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-19 21:55:12 +00:00
* Add response models * Supress message * correct spelling Timestamp * implement traffic client * add reactive client * [WIP] unit tests * add argument check * finish unit tests * add integration tests * Change repositoryId from int to long Remove GetAll naming of endpoints and add to PaginationTest exclusions Rename View and Clone classes to be more specific Add handling of TimeStamp fields being UtcUnix time Add integration tests for repositoryId methods
112 lines
3.2 KiB
C#
112 lines
3.2 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 TheGetReferrersMethod : RepositoryTrafficClientTests
|
|
{
|
|
[IntegrationTest]
|
|
public async Task GetsReferrers()
|
|
{
|
|
var referrers = await _fixture.GetReferrers(_owner, _repo);
|
|
|
|
Assert.True(referrers.Count > 0);
|
|
}
|
|
|
|
[IntegrationTest]
|
|
public async Task GetsReferrersWithRepositoryId()
|
|
{
|
|
var referrers = await _fixture.GetReferrers(_repoId);
|
|
|
|
Assert.True(referrers.Count > 0);
|
|
}
|
|
}
|
|
|
|
public class TheGetPathsMethod : RepositoryTrafficClientTests
|
|
{
|
|
[IntegrationTest]
|
|
public async Task GetsPaths()
|
|
{
|
|
var paths = await _fixture.GetPaths(_owner, _repo);
|
|
|
|
Assert.True(paths.Count > 0);
|
|
}
|
|
|
|
[IntegrationTest]
|
|
public async Task GetsPathsWithRepositoryId()
|
|
{
|
|
var paths = await _fixture.GetPaths(_repoId);
|
|
|
|
Assert.True(paths.Count > 0);
|
|
}
|
|
}
|
|
|
|
public class TheGetClonesMethod : RepositoryTrafficClientTests
|
|
{
|
|
[IntegrationTest]
|
|
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]
|
|
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]
|
|
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]
|
|
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);
|
|
}
|
|
}
|
|
}
|