mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-09 21:09:51 +00:00
added integration tests
This commit is contained in:
@@ -37,6 +37,27 @@ namespace Octokit.Tests.Integration.Clients
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanCreateAndRetrieveContributorsWithRepositoryId()
|
||||
{
|
||||
using (var context = await _client.CreateRepositoryContext("public-repo"))
|
||||
{
|
||||
var repository = new RepositorySummary(context);
|
||||
await CommitToRepository(repository);
|
||||
var contributors = await _client.Repository.Statistics.GetContributors(context.Repository.Id);
|
||||
|
||||
Assert.NotNull(contributors);
|
||||
Assert.Equal(1, contributors.Count);
|
||||
|
||||
var soleContributor = contributors.First();
|
||||
Assert.NotNull(soleContributor.Author);
|
||||
Assert.True(soleContributor.Author.Login == repository.Owner);
|
||||
|
||||
Assert.Equal(1, soleContributor.Weeks.Count);
|
||||
Assert.Equal(1, soleContributor.Total);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanCreateAndRetrieveEmptyContributors()
|
||||
{
|
||||
@@ -51,6 +72,19 @@ namespace Octokit.Tests.Integration.Clients
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanCreateAndRetrieveEmptyContributorsWithRepositoryId()
|
||||
{
|
||||
var newRepository = new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = false };
|
||||
using (var context = await _client.CreateRepositoryContext(newRepository))
|
||||
{
|
||||
var contributors = await _client.Repository.Statistics.GetContributors(context.Repository.Id);
|
||||
|
||||
Assert.NotNull(contributors);
|
||||
Assert.Empty(contributors);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetCommitActivityForTheLastYear()
|
||||
{
|
||||
@@ -58,6 +92,7 @@ namespace Octokit.Tests.Integration.Clients
|
||||
{
|
||||
var repository = new RepositorySummary(context);
|
||||
await CommitToRepository(repository);
|
||||
|
||||
var commitActivities = await _client.Repository.Statistics.GetCommitActivity(repository.Owner, repository.Name);
|
||||
Assert.NotNull(commitActivities);
|
||||
Assert.Equal(52, commitActivities.Activity.Count);
|
||||
@@ -68,6 +103,24 @@ namespace Octokit.Tests.Integration.Clients
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetCommitActivityForTheLastYearWithRepositoryId()
|
||||
{
|
||||
using (var context = await _client.CreateRepositoryContext("public-repo"))
|
||||
{
|
||||
var repository = new RepositorySummary(context);
|
||||
await CommitToRepository(repository);
|
||||
|
||||
var commitActivities = await _client.Repository.Statistics.GetCommitActivity(context.Repository.Id);
|
||||
Assert.NotNull(commitActivities);
|
||||
Assert.Equal(52, commitActivities.Activity.Count);
|
||||
|
||||
var thisWeek = commitActivities.Activity.Last();
|
||||
Assert.Equal(1, thisWeek.Total);
|
||||
Assert.NotNull(thisWeek.Days);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetAdditionsAndDeletionsPerWeek()
|
||||
{
|
||||
@@ -81,6 +134,20 @@ namespace Octokit.Tests.Integration.Clients
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetAdditionsAndDeletionsPerWeekWithRepositoryId()
|
||||
{
|
||||
using (var context = await _client.CreateRepositoryContext("public-repo"))
|
||||
{
|
||||
var repository = new RepositorySummary(context);
|
||||
await CommitToRepository(repository);
|
||||
|
||||
var commitActivities = await _client.Repository.Statistics.GetCodeFrequency(context.Repository.Id);
|
||||
Assert.NotNull(commitActivities);
|
||||
Assert.True(commitActivities.AdditionsAndDeletionsByWeek.Any());
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetParticipationStatistics()
|
||||
{
|
||||
@@ -93,6 +160,18 @@ namespace Octokit.Tests.Integration.Clients
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetParticipationStatisticsWithRepositoryId()
|
||||
{
|
||||
using (var context = await _client.CreateRepositoryContext("public-repo"))
|
||||
{
|
||||
var repository = new RepositorySummary(context);
|
||||
await CommitToRepository(repository);
|
||||
var weeklyCommitCounts = await _client.Repository.Statistics.GetParticipation(context.Repository.Id);
|
||||
Assert.Equal(52, weeklyCommitCounts.All.Count);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetPunchCardForRepository()
|
||||
{
|
||||
@@ -106,6 +185,20 @@ namespace Octokit.Tests.Integration.Clients
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetPunchCardForRepositoryWithRepositoryId()
|
||||
{
|
||||
using (var context = await _client.CreateRepositoryContext("public-repo"))
|
||||
{
|
||||
var repository = new RepositorySummary(context);
|
||||
await CommitToRepository(repository);
|
||||
|
||||
var punchCard = await _client.Repository.Statistics.GetPunchCard(context.Repository.Id);
|
||||
Assert.NotNull(punchCard);
|
||||
Assert.NotNull(punchCard.PunchPoints);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<Commit> CommitToRepository(RepositorySummary repositorySummary)
|
||||
{
|
||||
var owner = repositorySummary.Owner;
|
||||
|
||||
Reference in New Issue
Block a user