From 60fc710b736bcb3560c8e1fc240110d28f0ce69e Mon Sep 17 00:00:00 2001 From: Amy Palamountain Date: Mon, 27 Jan 2014 21:32:29 +1300 Subject: [PATCH] Added intergration tests for contributors api --- .../Clients/StatisticsClientTests.cs | 66 +++++++++++++++++++ .../Octokit.Tests.Integration.csproj | 1 + 2 files changed, 67 insertions(+) create mode 100644 Octokit.Tests.Integration/Clients/StatisticsClientTests.cs diff --git a/Octokit.Tests.Integration/Clients/StatisticsClientTests.cs b/Octokit.Tests.Integration/Clients/StatisticsClientTests.cs new file mode 100644 index 00000000..c12e8396 --- /dev/null +++ b/Octokit.Tests.Integration/Clients/StatisticsClientTests.cs @@ -0,0 +1,66 @@ +using System.Net.Http.Headers; +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Integration.Clients +{ + public class StatisticsClientTests + { + public class TheContributorStatistics + { + readonly IGitHubClient _client; + readonly Repository _repository; + readonly ICommitsClient _fixture; + readonly string _owner; + readonly string _repoName; + + public TheContributorStatistics() + { + _client = new GitHubClient(new ProductHeaderValue("OctokitTests")) + { + Credentials = Helper.Credentials + }; + + _repoName = Helper.MakeNameWithTimestamp("public-repo"); + _fixture = _client.GitDatabase.Commit; + _repository = _client.Repository.Create(new NewRepository { Name = _repoName, AutoInit = true }).Result; + _owner = _repository.Owner.Login; + } + + + [IntegrationTest] + public async Task CanCreateAndRetrieveCommit() + { + await SeedRepository(); + var contributors = await _client.Statistics.GetContributors(_owner, _repoName); + Assert.NotNull(contributors); + } + + async Task SeedRepository() + { + var blob = new NewBlob + { + Content = "Hello World!", + Encoding = EncodingType.Utf8 + }; + var blobResult = await _client.GitDatabase.Blob.Create(_owner, _repository.Name, blob); + + var newTree = new NewTree(); + newTree.Tree.Add(new NewTreeItem + { + Type = TreeType.Blob, + Mode = FileMode.File, + Path = "README.md", + Sha = blobResult.Sha + }); + + var treeResult = await _client.GitDatabase.Tree.Create(_owner, _repository.Name, newTree); + + var newCommit = new NewCommit("test-commit", treeResult.Sha); + + var commit = await _fixture.Create(_owner, _repository.Name, newCommit); + return commit; + } + } + } +} diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index c1c26ff3..a16d1bff 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -70,6 +70,7 @@ +