Fix async tests (#1631)

* Fix up Assert.ThrowsAsync tests to actually await the call

* ... and it even picked up a missing null check... pay day!
This commit is contained in:
Ryan Gribble
2017-07-23 09:03:10 +10:00
committed by GitHub
parent 329ef960ed
commit db74c3b4ad
12 changed files with 80 additions and 73 deletions
@@ -4,6 +4,7 @@ using System.Threading.Tasks;
using NSubstitute;
using Octokit.Reactive;
using Xunit;
using System.Reactive.Linq;
namespace Octokit.Tests.Reactive
{
@@ -21,29 +22,29 @@ namespace Octokit.Tests.Reactive
public class TheGetAllMethod
{
[Fact]
public void EnsuresNonEmptyArguments()
public async Task EnsuresNonEmptyArguments()
{
var githubClient = Substitute.For<IGitHubClient>();
var client = new ObservableRepositoryCommitsClient(githubClient);
var options = new ApiOptions();
var request = new CommitRequest();
Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "name", request, options).ToTask());
Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "", request, options).ToTask());
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "name", request, options).ToTask());
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "", request, options).ToTask());
}
[Fact]
public void EnsuresNonNullArguments()
public async Task EnsuresNonNullArguments()
{
var githubClient = Substitute.For<IGitHubClient>();
var client = new ObservableRepositoryCommitsClient(githubClient);
var options = new ApiOptions();
var request = new CommitRequest();
Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "name", request, options).ToTask());
Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null, request, options).ToTask());
Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "name", null, options).ToTask());
Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "name", request, null).ToTask());
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "name", request, options).ToTask());
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null, request, options).ToTask());
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "name", null, options).ToTask());
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "name", request, null).ToTask());
}
[Fact]
@@ -62,13 +63,13 @@ namespace Octokit.Tests.Reactive
public class TheGetSha1Method
{
[Fact]
public void EnsuresNonEmptyArguments()
public async Task 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());
await Assert.ThrowsAsync<ArgumentException>(() => client.GetSha1("", "name", "reference").ToTask());
await Assert.ThrowsAsync<ArgumentException>(() => client.GetSha1("owner", "", "reference").ToTask());
await Assert.ThrowsAsync<ArgumentException>(() => client.GetSha1("owner", "name", "").ToTask());
}
[Fact]
@@ -82,18 +83,19 @@ namespace Octokit.Tests.Reactive
}
[Fact]
public void GetsCorrectUrl()
public async Task GetsCorrectUrl()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableRepositoryCommitsClient(gitHubClient);
client.GetSha1("owner", "name", "reference");
await client.GetSha1("owner", "name", "reference");
gitHubClient
.Received()
.Received(1)
.Repository
.Commit
.GetSha1("owner", "name", "reference");
//.GetSha1("owner1", "name", "reference");
.GetAll(1);
}
}
}