-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1195 from rogertinsley/issue-1189
New method on RepositoryCommits client - Get the sha1 of a commit reference
- Loading branch information
Showing
9 changed files
with
167 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
Octokit.Tests/Reactive/ObservableRepositoryCommitsClientTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System; | ||
using System.Reactive.Threading.Tasks; | ||
using System.Threading.Tasks; | ||
using NSubstitute; | ||
using Octokit.Reactive; | ||
using Xunit; | ||
|
||
namespace Octokit.Tests.Reactive | ||
{ | ||
public class ObservableRepositoryCommitsClientTests | ||
{ | ||
public class TheCtor | ||
{ | ||
[Fact] | ||
public void EnsuresArgument() | ||
{ | ||
Assert.Throws<ArgumentNullException>(() => new ObservableRepositoryCommitsClient(null)); | ||
} | ||
} | ||
|
||
public class TheGetSha1Method | ||
{ | ||
[Fact] | ||
public void EnsuresNonEmptyArguments() | ||
{ | ||
var client = new ObservableRepositoryCommitsClient(Substitute.For<IGitHubClient>()); | ||
|
||
Assert.ThrowsAsync<ArgumentException>(() => client.GetSha1("", "name", "reference").ToTask()); | ||
Assert.ThrowsAsync<ArgumentException>(() => client.GetSha1("owner", "", "reference").ToTask()); | ||
Assert.ThrowsAsync<ArgumentException>(() => client.GetSha1("owner", "name", "").ToTask()); | ||
} | ||
|
||
[Fact] | ||
public async Task EnsuresNonNullArguments() | ||
{ | ||
var client = new ObservableRepositoryCommitsClient(Substitute.For<IGitHubClient>()); | ||
|
||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetSha1(null, "name", "reference").ToTask()); | ||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetSha1("owner", null, "reference").ToTask()); | ||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetSha1("owner", "name", null).ToTask()); | ||
} | ||
|
||
[Fact] | ||
public void GetsCorrectUrl() | ||
{ | ||
var gitHubClient = Substitute.For<IGitHubClient>(); | ||
var client = new ObservableRepositoryCommitsClient(gitHubClient); | ||
|
||
client.GetSha1("owner", "name", "reference"); | ||
|
||
gitHubClient | ||
.Received() | ||
.Repository | ||
.Commit | ||
.GetSha1("owner", "name", "reference"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters