From ce1cd2e3659f6132cd82f2690ddfe8b40c376fac Mon Sep 17 00:00:00 2001 From: John Nye Date: Wed, 6 Nov 2013 21:17:36 +0000 Subject: [PATCH] Create integration tests --- .../CommitsClientTests.cs | 52 +++++++++++++++++++ .../Octokit.Tests.Integration.csproj | 1 + 2 files changed, 53 insertions(+) create mode 100644 Octokit.Tests.Integration/CommitsClientTests.cs diff --git a/Octokit.Tests.Integration/CommitsClientTests.cs b/Octokit.Tests.Integration/CommitsClientTests.cs new file mode 100644 index 00000000..e19977ac --- /dev/null +++ b/Octokit.Tests.Integration/CommitsClientTests.cs @@ -0,0 +1,52 @@ +using System; +using System.Linq; +using System.Net.Http.Headers; +using System.Threading.Tasks; +using Octokit; +using Octokit.Tests.Integration; +using Xunit; + +public class CommitsClientTests : IDisposable +{ + readonly IGitHubClient _gitHubClient; + readonly Repository _repository; + readonly ICommitsClient _commitsClient; + + public CommitsClientTests() + { + this._gitHubClient = new GitHubClient(new ProductHeaderValue("OctokitTests")) + { + Credentials = Helper.Credentials + }; + + var repoName = Helper.MakeNameWithTimestamp("public-repo"); + this._commitsClient = this._gitHubClient.GitDatabase.Commit; + this._repository = this._gitHubClient.Repository.Create(new NewRepository { Name = repoName }).Result; + } + + [IntegrationTest] + public async Task CanCreateAndRetrieveCommit() + { + string owner = this._repository.Owner.Login; + + var author = new UserAction { Name = "author", Email = "test-author@example.com", Date = DateTime.UtcNow }; + var commiter = new UserAction { Name = "commiter", Email = "test-commiter@example.com", Date = DateTime.Today }; + var newCommit = new NewCommit("test-commit", "tree", Enumerable.Empty()) + { + Author = author, + Committer = commiter + }; + + var commit = await this._commitsClient.Create(owner, this._repository.Name, newCommit); + + Assert.NotNull(commit); + var retrieved = await this._commitsClient.Get(owner, this._repository.Name, commit.Sha); + Assert.NotNull(retrieved); + } + + + public void Dispose() + { + Helper.DeleteRepo(this._repository); + } +} \ No newline at end of file diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 4f11acc3..205f8a4e 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -58,6 +58,7 @@ +