mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-20 14:15:12 +00:00
51 lines
1.8 KiB
C#
51 lines
1.8 KiB
C#
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 TheGetSha1Method
|
|
{
|
|
[Fact]
|
|
public void EnsuresNonNullArguments()
|
|
{
|
|
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 EnsuresNonEmptyArguments()
|
|
{
|
|
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");
|
|
}
|
|
}
|
|
}
|
|
}
|