mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-08 20:45:51 +00:00
added new unit tests
This commit is contained in:
@@ -13,16 +13,27 @@ namespace Octokit.Tests.Clients
|
||||
public class TheGetMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsCorrectUrl()
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
client.Get("fake", "repo", 42);
|
||||
await client.Get("fake", "repo", 42);
|
||||
|
||||
connection.Received().Get<Issue>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
await client.Get(1, 42);
|
||||
|
||||
connection.Received().Get<Issue>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
@@ -30,6 +41,9 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "name", 1));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null, 1));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", "name", 1));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "", 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,24 +61,24 @@ namespace Octokit.Tests.Clients
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestsCorrectUrl()
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
client.GetAllForCurrent();
|
||||
await client.GetAllForCurrent();
|
||||
|
||||
connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "issues"),
|
||||
Arg.Any<Dictionary<string, string>>(), Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SendsAppropriateParameters()
|
||||
public async Task SendsAppropriateParameters()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
client.GetAllForCurrent(new IssueRequest { SortDirection = SortDirection.Ascending });
|
||||
await client.GetAllForCurrent(new IssueRequest { SortDirection = SortDirection.Ascending });
|
||||
|
||||
connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d.Count == 4
|
||||
@@ -90,12 +104,12 @@ namespace Octokit.Tests.Clients
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestsCorrectUrl()
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
client.GetAllForOwnedAndMemberRepositories();
|
||||
await client.GetAllForOwnedAndMemberRepositories();
|
||||
|
||||
connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "user/issues"),
|
||||
Arg.Any<Dictionary<string, string>>(),
|
||||
@@ -106,7 +120,7 @@ namespace Octokit.Tests.Clients
|
||||
public class TheGetAllForOrganizationMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresArgumentsNotNull()
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new IssuesClient(Substitute.For<IApiConnection>());
|
||||
|
||||
@@ -131,12 +145,12 @@ namespace Octokit.Tests.Clients
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestsCorrectUrl()
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
client.GetAllForOrganization("fake");
|
||||
await client.GetAllForOrganization("fake");
|
||||
|
||||
connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "orgs/fake/issues"),
|
||||
Arg.Any<Dictionary<string, string>>(),
|
||||
@@ -167,7 +181,7 @@ namespace Octokit.Tests.Clients
|
||||
public class TheGetAllForRepositoryMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresArgumentsNotNull()
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new IssuesClient(Substitute.For<IApiConnection>());
|
||||
|
||||
@@ -175,39 +189,40 @@ namespace Octokit.Tests.Clients
|
||||
var request = new RepositoryIssueRequest();
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", options));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", request));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", request, options));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", options));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", request));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", request, options));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", options));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, options));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, request));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, request, options));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", ""));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", options));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", request));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", request, options));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (ApiOptions)null));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", request));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, request));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (RepositoryIssueRequest)null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", request, options));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, request, options));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null, options));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", request, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(1, (ApiOptions)null));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(1, (RepositoryIssueRequest)null));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(1, null, options));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(1, request, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", ""));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", options));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", options));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", request));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", request));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", request, options));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", request, options));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestsCorrectUrl()
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
client.GetAllForRepository("fake", "repo");
|
||||
await client.GetAllForRepository("fake", "repo");
|
||||
|
||||
connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues"),
|
||||
Arg.Any<Dictionary<string, string>>(),
|
||||
@@ -215,12 +230,63 @@ namespace Octokit.Tests.Clients
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SendsAppropriateParameters()
|
||||
public async Task RequestsCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
client.GetAllForRepository("fake", "repo", new RepositoryIssueRequest
|
||||
await client.GetAllForRepository(1);
|
||||
|
||||
connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues"),
|
||||
Arg.Any<Dictionary<string, string>>(),
|
||||
Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithApiOptions()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
StartPage = 1,
|
||||
PageSize = 1
|
||||
};
|
||||
|
||||
await client.GetAllForRepository("fake", "repo", options);
|
||||
|
||||
connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues"), Arg.Any<Dictionary<string, string>>(), options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
StartPage = 1,
|
||||
PageSize = 1
|
||||
};
|
||||
|
||||
await client.GetAllForRepository(1, options);
|
||||
|
||||
connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues"),
|
||||
Arg.Any<Dictionary<string, string>>(),
|
||||
options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SendsAppropriateParameters()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
await client.GetAllForRepository("fake", "repo", new RepositoryIssueRequest
|
||||
{
|
||||
SortDirection = SortDirection.Ascending
|
||||
});
|
||||
@@ -233,6 +299,80 @@ namespace Octokit.Tests.Clients
|
||||
&& d["filter"] == "assigned"),
|
||||
Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SendsAppropriateParametersWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
await client.GetAllForRepository(1, new RepositoryIssueRequest
|
||||
{
|
||||
SortDirection = SortDirection.Ascending
|
||||
});
|
||||
|
||||
connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d.Count == 4
|
||||
&& d["state"] == "open"
|
||||
&& d["direction"] == "asc"
|
||||
&& d["sort"] == "created"
|
||||
&& d["filter"] == "assigned"),
|
||||
Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SendsAppropriateParametersWithApiOptions()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
StartPage = 1,
|
||||
PageSize = 1
|
||||
};
|
||||
|
||||
await client.GetAllForRepository("fake", "repo", new RepositoryIssueRequest
|
||||
{
|
||||
SortDirection = SortDirection.Ascending
|
||||
}, options);
|
||||
|
||||
connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d.Count == 4
|
||||
&& d["state"] == "open"
|
||||
&& d["direction"] == "asc"
|
||||
&& d["sort"] == "created"
|
||||
&& d["filter"] == "assigned"),
|
||||
options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SendsAppropriateParametersWithRepositoryIdWithApiOptions()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
StartPage = 1,
|
||||
PageSize = 1
|
||||
};
|
||||
|
||||
await client.GetAllForRepository(1, new RepositoryIssueRequest
|
||||
{
|
||||
SortDirection = SortDirection.Ascending
|
||||
}, options);
|
||||
|
||||
connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d.Count == 4
|
||||
&& d["state"] == "open"
|
||||
&& d["direction"] == "asc"
|
||||
&& d["sort"] == "created"
|
||||
&& d["filter"] == "assigned"),
|
||||
options);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheCreateMethod
|
||||
@@ -251,16 +391,32 @@ namespace Octokit.Tests.Clients
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresArgumentsNotNull()
|
||||
public void PostsToCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var newIssue = new NewIssue("some title");
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
client.Create(1, newIssue);
|
||||
|
||||
connection.Received().Post<Issue>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues"),
|
||||
newIssue);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, "name", new NewIssue("title")));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", new NewIssue("x")));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, "name", new NewIssue("x")));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", null, new NewIssue("x")));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", new NewIssue("x")));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "name", null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(1, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", new NewIssue("x")));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", new NewIssue("x")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,16 +436,32 @@ namespace Octokit.Tests.Clients
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresArgumentsNotNull()
|
||||
public void PostsToCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var issueUpdate = new IssueUpdate();
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
client.Update(1, 42, issueUpdate);
|
||||
|
||||
connection.Received().Patch<Issue>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42"),
|
||||
issueUpdate);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update(null, "name", 1, new IssueUpdate()));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Update("", "name", 1, new IssueUpdate()));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("owner", null, 1, new IssueUpdate()));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Update("owner", "", 1, new IssueUpdate()));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("owner", "name", 1, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update(1, 1, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Update("", "name", 1, new IssueUpdate()));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Update("owner", "", 1, new IssueUpdate()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,14 +479,26 @@ namespace Octokit.Tests.Clients
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresArgumentsNotNull()
|
||||
public void PostsToCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
client.Lock(1, 42);
|
||||
|
||||
connection.Received().Put<Issue>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/lock"), Arg.Any<object>(), Arg.Any<string>(), Arg.Is<string>(u => u.ToString() == "application/vnd.github.the-key-preview+json"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Lock(null, "name", 1));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Lock("", "name", 1));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Lock("owner", null, 1));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Lock("", "name", 1));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Lock("owner", "", 1));
|
||||
}
|
||||
}
|
||||
@@ -333,14 +517,26 @@ namespace Octokit.Tests.Clients
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresArgumentsNotNull()
|
||||
public void PostsToCorrectUrlWithApiOptions()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
client.Unlock(1, 42);
|
||||
|
||||
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/lock"), Arg.Any<object>(), Arg.Is<string>(u => u.ToString() == "application/vnd.github.the-key-preview+json"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Unlock(null, "name", 1));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Unlock("", "name", 1));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Unlock("owner", null, 1));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Unlock("", "name", 1));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Unlock("owner", "", 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ using Octokit.Reactive;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reactive.Linq;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
@@ -25,52 +24,235 @@ public class ObservableIssuesClientTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
public void GetsFromClientIssueIssueWithRepositoryId()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
client.Get(1, 42);
|
||||
|
||||
gitHubClient.Issue.Received().Get(1, 42);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ObservableIssuesClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "name", 1).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null, 1).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "", 1).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", null, 1).ToTask());
|
||||
Assert.Throws<ArgumentNullException>(() => client.Get(null, "name", 1));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Get("owner", null, 1));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Get("owner", "", 1));
|
||||
Assert.Throws<ArgumentException>(() => client.Get("", "name", 1));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllForRepositoryMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresArgumentsNotNull()
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ObservableIssuesClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
var options = new ApiOptions();
|
||||
var request = new RepositoryIssueRequest();
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name").ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", options).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", request).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", request, options).ToTask());
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name"));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name", options));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, options));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (ApiOptions)null));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name", request));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, request));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (RepositoryIssueRequest)null));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name", request, options));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, request, options));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null, options));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", request, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name").ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", options).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", request).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", request, options).ToTask());
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, (ApiOptions)null));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, (RepositoryIssueRequest)null));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, null, options));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, request, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, options).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, request).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, request, options).ToTask());
|
||||
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name"));
|
||||
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", ""));
|
||||
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name", options));
|
||||
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", options));
|
||||
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name", request));
|
||||
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", request));
|
||||
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name", request, options));
|
||||
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", request, options));
|
||||
}
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "").ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", options).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", request).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", request, options).ToTask());
|
||||
[Fact]
|
||||
public void RequestsCorrectUrl()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (ApiOptions)null).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (RepositoryIssueRequest)null).ToTask());
|
||||
client.GetAllForRepository("fake", "repo");
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null, options).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", request, null).ToTask());
|
||||
gitHubClient.Connection.Received().Get<List<Issue>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues"),
|
||||
Arg.Any<IDictionary<string, string>>(), null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestsCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
client.GetAllForRepository(1);
|
||||
|
||||
gitHubClient.Connection.Received().Get<List<Issue>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues"),
|
||||
Arg.Any<IDictionary<string, string>>(), null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestsCorrectUrlWithApiOptions()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
StartPage = 1,
|
||||
PageSize = 1
|
||||
};
|
||||
|
||||
client.GetAllForRepository("fake", "repo", options);
|
||||
|
||||
gitHubClient.Connection.Received().Get<List<Issue>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues"),
|
||||
Arg.Is<IDictionary<string, string>>(d => d.Count == 6
|
||||
&& d["filter"] == "assigned"
|
||||
&& d["state"] == "open"
|
||||
&& d["sort"] == "created"
|
||||
&& d["direction"] == "desc"
|
||||
&& d["page"] == "1"
|
||||
&& d["per_page"] == "1"), null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestsCorrectUrlWithRepositoryIdWithApiOptions()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
StartPage = 1,
|
||||
PageSize = 1
|
||||
};
|
||||
|
||||
client.GetAllForRepository(1, options);
|
||||
|
||||
gitHubClient.Connection.Received().Get<List<Issue>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues"),
|
||||
Arg.Is<IDictionary<string, string>>(d => d.Count == 6
|
||||
&& d["filter"] == "assigned"
|
||||
&& d["state"] == "open"
|
||||
&& d["sort"] == "created"
|
||||
&& d["direction"] == "desc"
|
||||
&& d["page"] == "1"
|
||||
&& d["per_page"] == "1"), null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SendsAppropriateParameters()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
client.GetAllForRepository("fake", "repo", new RepositoryIssueRequest
|
||||
{
|
||||
SortDirection = SortDirection.Ascending
|
||||
});
|
||||
|
||||
gitHubClient.Connection.Received().Get<List<Issue>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues"),
|
||||
Arg.Is<IDictionary<string, string>>(d => d.Count == 4
|
||||
&& d["filter"] == "assigned"
|
||||
&& d["state"] == "open"
|
||||
&& d["sort"] == "created"
|
||||
&& d["direction"] == "asc"), null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SendsAppropriateParametersWithRepositoryId()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
client.GetAllForRepository(1, new RepositoryIssueRequest
|
||||
{
|
||||
SortDirection = SortDirection.Ascending
|
||||
});
|
||||
|
||||
gitHubClient.Connection.Received().Get<List<Issue>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues"),
|
||||
Arg.Is<IDictionary<string, string>>(d => d.Count == 4
|
||||
&& d["filter"] == "assigned"
|
||||
&& d["state"] == "open"
|
||||
&& d["sort"] == "created"
|
||||
&& d["direction"] == "asc"), null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SendsAppropriateParametersWithApiOptions()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
StartPage = 1,
|
||||
PageSize = 1
|
||||
};
|
||||
|
||||
client.GetAllForRepository("fake", "repo", new RepositoryIssueRequest
|
||||
{
|
||||
SortDirection = SortDirection.Ascending
|
||||
}, options);
|
||||
|
||||
gitHubClient.Connection.Received().Get<List<Issue>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues"),
|
||||
Arg.Is<IDictionary<string, string>>(d => d.Count == 6
|
||||
&& d["filter"] == "assigned"
|
||||
&& d["state"] == "open"
|
||||
&& d["sort"] == "created"
|
||||
&& d["direction"] == "asc"
|
||||
&& d["page"] == "1"
|
||||
&& d["per_page"] == "1"),
|
||||
null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SendsAppropriateParametersWithRepositoryIdWithApiOptions()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
StartPage = 1,
|
||||
PageSize = 1
|
||||
};
|
||||
|
||||
client.GetAllForRepository(1, new RepositoryIssueRequest
|
||||
{
|
||||
SortDirection = SortDirection.Ascending
|
||||
}, options);
|
||||
|
||||
gitHubClient.Connection.Received().Get<List<Issue>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues"),
|
||||
Arg.Is<IDictionary<string, string>>(d => d.Count == 6
|
||||
&& d["filter"] == "assigned"
|
||||
&& d["state"] == "open"
|
||||
&& d["sort"] == "created"
|
||||
&& d["direction"] == "asc"
|
||||
&& d["page"] == "1"
|
||||
&& d["per_page"] == "1"),
|
||||
null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -135,18 +317,18 @@ public class ObservableIssuesClientTests
|
||||
public class TheGetAllForOwnedAndMemberRepositoriesMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ObservableIssuesClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(
|
||||
() => client.GetAllForOwnedAndMemberRepositories((ApiOptions)null).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(
|
||||
() => client.GetAllForOwnedAndMemberRepositories((IssueRequest)null).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(
|
||||
() => client.GetAllForOwnedAndMemberRepositories(null, new ApiOptions()).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(
|
||||
() => client.GetAllForOwnedAndMemberRepositories(new IssueRequest(), null).ToTask());
|
||||
Assert.Throws<ArgumentNullException>(
|
||||
() => client.GetAllForOwnedAndMemberRepositories((ApiOptions)null));
|
||||
Assert.Throws<ArgumentNullException>(
|
||||
() => client.GetAllForOwnedAndMemberRepositories((IssueRequest)null));
|
||||
Assert.Throws<ArgumentNullException>(
|
||||
() => client.GetAllForOwnedAndMemberRepositories(null, new ApiOptions()));
|
||||
Assert.Throws<ArgumentNullException>(
|
||||
() => client.GetAllForOwnedAndMemberRepositories(new IssueRequest(), null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -212,28 +394,28 @@ public class ObservableIssuesClientTests
|
||||
public class TheGetAllForOrganizationMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresArgumentsNotNull()
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ObservableIssuesClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
var options = new ApiOptions();
|
||||
var request = new RepositoryIssueRequest();
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization(null).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization(null, options).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization(null, request).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization(null, request, options).ToTask());
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForOrganization(null));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForOrganization(null, options));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForOrganization(null, request));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForOrganization(null, request, options));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForOrganization("").ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForOrganization("", options).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForOrganization("", request).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForOrganization("", request, options).ToTask());
|
||||
Assert.Throws<ArgumentException>(() => client.GetAllForOrganization(""));
|
||||
Assert.Throws<ArgumentException>(() => client.GetAllForOrganization("", options));
|
||||
Assert.Throws<ArgumentException>(() => client.GetAllForOrganization("", request));
|
||||
Assert.Throws<ArgumentException>(() => client.GetAllForOrganization("", request, options));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization("org", (ApiOptions)null).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization("org", (IssueRequest)null).ToTask());
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForOrganization("org", (ApiOptions)null));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForOrganization("org", (IssueRequest)null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization("org", null, options).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization("org", request, null).ToTask());
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForOrganization("org", null, options));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForOrganization("org", request, null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -299,14 +481,14 @@ public class ObservableIssuesClientTests
|
||||
public class TheGetAllForCurrentMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ObservableIssuesClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCurrent((ApiOptions)null).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCurrent((IssueRequest)null).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCurrent(null, new ApiOptions()).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCurrent(new IssueRequest(), null).ToTask());
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForCurrent((ApiOptions)null));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForCurrent((IssueRequest)null));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForCurrent(null, new ApiOptions()));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForCurrent(new IssueRequest(), null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -383,16 +565,31 @@ public class ObservableIssuesClientTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresArgumentsNotNull()
|
||||
public void CreatesFromClientIssueIssueWithRepositoryId()
|
||||
{
|
||||
var newIssue = new NewIssue("some title");
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
client.Create(1, newIssue);
|
||||
|
||||
gitHubClient.Issue.Received().Create(1, newIssue);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Create(null, "name", new NewIssue("title")));
|
||||
Assert.Throws<ArgumentException>(() => client.Create("", "name", new NewIssue("x")));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Create(null, "name", new NewIssue("x")));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Create("owner", null, new NewIssue("x")));
|
||||
Assert.Throws<ArgumentException>(() => client.Create("owner", "", new NewIssue("x")));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Create("owner", "name", null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Create(1, null));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Create("", "name", new NewIssue("x")));
|
||||
Assert.Throws<ArgumentException>(() => client.Create("owner", "", new NewIssue("x")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,16 +608,32 @@ public class ObservableIssuesClientTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresArgumentsNotNull()
|
||||
public void UpdatesClientIssueIssueWithRepositoryId()
|
||||
{
|
||||
var issueUpdate = new IssueUpdate();
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
client.Update(1, 42, issueUpdate);
|
||||
|
||||
gitHubClient.Issue.Received().Update(1, 42, issueUpdate);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Update(null, "name", 42, new IssueUpdate()));
|
||||
Assert.Throws<ArgumentException>(() => client.Update("", "name", 42, new IssueUpdate()));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Update("owner", null, 42, new IssueUpdate()));
|
||||
Assert.Throws<ArgumentException>(() => client.Update("owner", "", 42, new IssueUpdate()));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Update("owner", "name", 42, null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Update(1, 42, null));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Update("", "name", 42, new IssueUpdate()));
|
||||
Assert.Throws<ArgumentException>(() => client.Update("owner", "", 42, new IssueUpdate()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -433,18 +646,31 @@ public class ObservableIssuesClientTests
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
client.Lock("fake", "repo", 42);
|
||||
|
||||
gitHubClient.Issue.Received().Lock("fake", "repo", 42);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresArgumentsNotNull()
|
||||
public void LocksIssueWithRepositoryId()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
client.Lock(1, 42);
|
||||
|
||||
gitHubClient.Issue.Received().Lock(1, 42);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Lock(null, "name", 42));
|
||||
Assert.Throws<ArgumentException>(() => client.Lock("", "name", 42));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Lock("owner", null, 42));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Lock("", "name", 42));
|
||||
Assert.Throws<ArgumentException>(() => client.Lock("owner", "", 42));
|
||||
}
|
||||
}
|
||||
@@ -458,18 +684,31 @@ public class ObservableIssuesClientTests
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
client.Unlock("fake", "repo", 42);
|
||||
|
||||
gitHubClient.Issue.Received().Unlock("fake", "repo", 42);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresArgumentsNotNull()
|
||||
public void UnlocksIssueWithRepositoryId()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
client.Unlock(1, 42);
|
||||
|
||||
gitHubClient.Issue.Received().Unlock(1, 42);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Unlock(null, "name", 42));
|
||||
Assert.Throws<ArgumentException>(() => client.Unlock("", "name", 42));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Unlock("owner", null, 42));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Unlock("", "name", 42));
|
||||
Assert.Throws<ArgumentException>(() => client.Unlock("owner", "", 42));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user