mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-03 11:05:56 +00:00
added new unit tests
This commit is contained in:
@@ -31,6 +31,17 @@ namespace Octokit.Tests.Clients
|
||||
connection.Received().GetAll<Label>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
await client.GetAllForIssue(1, 42);
|
||||
|
||||
connection.Received().GetAll<Label>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels"), Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithApiOptions()
|
||||
{
|
||||
@@ -49,6 +60,24 @@ namespace Octokit.Tests.Clients
|
||||
connection.Received().GetAll<Label>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels"), options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
StartPage = 1,
|
||||
PageSize = 1
|
||||
};
|
||||
|
||||
await client.GetAllForIssue(1, 42, options);
|
||||
|
||||
connection.Received().GetAll<Label>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels"), options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
@@ -60,6 +89,8 @@ namespace Octokit.Tests.Clients
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForIssue("owner", null, 1, ApiOptions.None));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForIssue("owner", "name", 1, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForIssue(1, 1, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForIssue("", "name", 1));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForIssue("owner", "", 1));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForIssue("", "name", 1, ApiOptions.None));
|
||||
@@ -80,6 +111,17 @@ namespace Octokit.Tests.Clients
|
||||
connection.Received().GetAll<Label>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/labels"), Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
await client.GetAllForRepository(1);
|
||||
|
||||
connection.Received().GetAll<Label>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/labels"), Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithApiOptions()
|
||||
{
|
||||
@@ -98,6 +140,24 @@ namespace Octokit.Tests.Clients
|
||||
connection.Received().GetAll<Label>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/labels"), options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
StartPage = 1,
|
||||
PageSize = 1
|
||||
};
|
||||
|
||||
await client.GetAllForRepository(1, options);
|
||||
|
||||
connection.Received().GetAll<Label>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/labels"), options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
@@ -109,6 +169,8 @@ namespace Octokit.Tests.Clients
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, ApiOptions.None));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(1, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", ""));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", ApiOptions.None));
|
||||
@@ -129,6 +191,17 @@ namespace Octokit.Tests.Clients
|
||||
connection.Received().GetAll<Label>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/milestones/42/labels"), Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
await client.GetAllForMilestone(1, 42);
|
||||
|
||||
connection.Received().GetAll<Label>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/milestones/42/labels"), Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithApiOptions()
|
||||
{
|
||||
@@ -147,6 +220,24 @@ namespace Octokit.Tests.Clients
|
||||
connection.Received().GetAll<Label>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/milestones/42/labels"), options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
StartPage = 1,
|
||||
PageSize = 1
|
||||
};
|
||||
|
||||
await client.GetAllForMilestone(1, 42, options);
|
||||
|
||||
connection.Received().GetAll<Label>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/milestones/42/labels"), options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
@@ -158,6 +249,8 @@ namespace Octokit.Tests.Clients
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForMilestone("owner", null, 42, ApiOptions.None));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForMilestone("owner", "name", 42, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForMilestone(1, 42, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForMilestone("", "name", 42));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForMilestone("owner", "", 42));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForMilestone("", "name", 42, ApiOptions.None));
|
||||
@@ -178,6 +271,17 @@ namespace Octokit.Tests.Clients
|
||||
connection.Received().Get<Label>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/labels/label"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
await client.Get(1, "label");
|
||||
|
||||
connection.Received().Get<Label>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/labels/label"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
@@ -187,9 +291,13 @@ namespace Octokit.Tests.Clients
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null, "label"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", "name", null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(1, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", "name", "label"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "", "label"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "name", ""));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get(1, ""));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,6 +316,17 @@ namespace Octokit.Tests.Clients
|
||||
connection.Received().Post<IReadOnlyList<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Arg.Any<string[]>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PostsToCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
client.AddToIssue(1, 42, labels);
|
||||
|
||||
connection.Received().Post<IReadOnlyList<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels"), Arg.Any<string[]>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
@@ -217,6 +336,8 @@ namespace Octokit.Tests.Clients
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.AddToIssue("owner", null, 42, labels));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.AddToIssue("owner", "name", 42, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.AddToIssue(1, 42, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.AddToIssue("", "name", 42, labels));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.AddToIssue("owner", "", 42, labels));
|
||||
}
|
||||
@@ -235,6 +356,17 @@ namespace Octokit.Tests.Clients
|
||||
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels/label"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DeleteCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
client.RemoveFromIssue(1, 42, "label");
|
||||
|
||||
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels/label"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
@@ -244,9 +376,13 @@ namespace Octokit.Tests.Clients
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.RemoveFromIssue("owner", null, 42, "label"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.RemoveFromIssue("owner", "name", 42, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.RemoveFromIssue(1, 42, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.RemoveFromIssue("", "name", 42, "label"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.RemoveFromIssue("owner", "", 42, "label"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.RemoveFromIssue("owner", "name", 42, ""));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.RemoveFromIssue(1, 42, ""));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,6 +401,17 @@ namespace Octokit.Tests.Clients
|
||||
connection.Received().Put<IReadOnlyList<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Arg.Any<string[]>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PutsToCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
client.ReplaceAllForIssue(1, 42, labels);
|
||||
|
||||
connection.Received().Put<IReadOnlyList<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels"), Arg.Any<string[]>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
@@ -274,6 +421,8 @@ namespace Octokit.Tests.Clients
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ReplaceAllForIssue("owner", null, 42, labels));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ReplaceAllForIssue("owner", "name", 42, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ReplaceAllForIssue(1, 42, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.ReplaceAllForIssue("", "name", 42, labels));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.ReplaceAllForIssue("owner", "", 42, labels));
|
||||
}
|
||||
@@ -292,6 +441,17 @@ namespace Octokit.Tests.Clients
|
||||
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DeletesCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
client.RemoveAllFromIssue(1, 42);
|
||||
|
||||
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
@@ -304,5 +464,143 @@ namespace Octokit.Tests.Clients
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.RemoveAllFromIssue("owner", "", 42));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheDeleteMethod
|
||||
{
|
||||
[Fact]
|
||||
public void DeletesCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
client.Delete("fake", "repo", "labelName");
|
||||
|
||||
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/labels/labelName"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DeletesCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
client.Delete(1, "labelName");
|
||||
|
||||
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/labels/labelName"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new IssuesLabelsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete(null, "name", "labelName"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete("owner", null, "labelName"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete("owner", "name", null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete(1, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("", "name", "labelName"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("owner", "", "labelName"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("owner", "name", ""));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Delete(1, ""));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheCreateMethod
|
||||
{
|
||||
[Fact]
|
||||
public void CreatesCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
var newLabel = new NewLabel("labelName", "FF0000");
|
||||
|
||||
client.Create("fake", "repo", newLabel);
|
||||
|
||||
connection.Received().Post<Label>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/labels"), newLabel);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CreatesCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
var newLabel = new NewLabel("labelName", "FF0000");
|
||||
|
||||
client.Create(1, newLabel);
|
||||
|
||||
connection.Received().Post<Label>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/labels"), newLabel);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new IssuesLabelsClient(Substitute.For<IApiConnection>());
|
||||
var newLabel = new NewLabel("labelName", "FF0000");
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, "name", newLabel));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", null, newLabel));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "name", null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(1, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", newLabel));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", newLabel));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheUpdateMethod
|
||||
{
|
||||
[Fact]
|
||||
public void UpdatesCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
var labelUpdate = new LabelUpdate("name", "FF0000");
|
||||
|
||||
client.Update("fake", "repo", "labelName", labelUpdate);
|
||||
|
||||
connection.Received().Post<Label>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/labels/labelName"), labelUpdate);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UpdatesCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
var labelUpdate = new LabelUpdate("name", "FF0000");
|
||||
|
||||
client.Update(1, "labelName", labelUpdate);
|
||||
|
||||
connection.Received().Post<Label>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/labels/labelName"), labelUpdate);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new IssuesLabelsClient(Substitute.For<IApiConnection>());
|
||||
var labelUpdate = new LabelUpdate("name", "FF0000");
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update(null, "name", "labelName", labelUpdate));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("owner", null, "labelName", labelUpdate));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("owner", "name", null, labelUpdate));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("owner", "name", "labelName", null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update(1, null, labelUpdate));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update(1, "labelName", null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Update("", "name", "labelName", labelUpdate));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Update("owner", "", "labelName", labelUpdate));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Update("owner", "name", "", labelUpdate));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Update(1, "", labelUpdate));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,18 @@ namespace Octokit.Tests.Reactive
|
||||
connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Args.EmptyDictionary, null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IConnection>();
|
||||
var gitHubClient = new GitHubClient(connection);
|
||||
var client = new ObservableIssuesLabelsClient(gitHubClient);
|
||||
|
||||
client.GetAllForIssue(1, 42);
|
||||
|
||||
connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels"), Args.EmptyDictionary, null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithApiOptions()
|
||||
{
|
||||
@@ -52,6 +64,25 @@ namespace Octokit.Tests.Reactive
|
||||
connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IConnection>();
|
||||
var gitHubClient = new GitHubClient(connection);
|
||||
var client = new ObservableIssuesLabelsClient(gitHubClient);
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
StartPage = 1,
|
||||
PageSize = 1
|
||||
};
|
||||
|
||||
client.GetAllForIssue(1, 42, options);
|
||||
|
||||
connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
@@ -63,6 +94,8 @@ namespace Octokit.Tests.Reactive
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForIssue("owner", null, 1, ApiOptions.None));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForIssue("owner", "name", 1, null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForIssue(1, 1, null));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.GetAllForIssue("", "name", 1));
|
||||
Assert.Throws<ArgumentException>(() => client.GetAllForIssue("owner", "", 1));
|
||||
Assert.Throws<ArgumentException>(() => client.GetAllForIssue("", "name", 1, ApiOptions.None));
|
||||
@@ -84,6 +117,18 @@ namespace Octokit.Tests.Reactive
|
||||
connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/labels"), Args.EmptyDictionary, null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IConnection>();
|
||||
var gitHubClient = new GitHubClient(connection);
|
||||
var client = new ObservableIssuesLabelsClient(gitHubClient);
|
||||
|
||||
client.GetAllForRepository(1);
|
||||
|
||||
connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/labels"), Args.EmptyDictionary, null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithApiOptions()
|
||||
{
|
||||
@@ -103,6 +148,25 @@ namespace Octokit.Tests.Reactive
|
||||
connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/labels"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IConnection>();
|
||||
var gitHubClient = new GitHubClient(connection);
|
||||
var client = new ObservableIssuesLabelsClient(gitHubClient);
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
StartPage = 1,
|
||||
PageSize = 1
|
||||
};
|
||||
|
||||
client.GetAllForRepository(1, options);
|
||||
|
||||
connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/labels"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
@@ -114,6 +178,8 @@ namespace Octokit.Tests.Reactive
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, ApiOptions.None));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, null));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name"));
|
||||
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", ""));
|
||||
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name", ApiOptions.None));
|
||||
@@ -135,6 +201,18 @@ namespace Octokit.Tests.Reactive
|
||||
connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/milestones/42/labels"), Args.EmptyDictionary, null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IConnection>();
|
||||
var gitHubClient = new GitHubClient(connection);
|
||||
var client = new ObservableIssuesLabelsClient(gitHubClient);
|
||||
|
||||
client.GetAllForMilestone(1, 42);
|
||||
|
||||
connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/milestones/42/labels"), Args.EmptyDictionary, null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithApiOptions()
|
||||
{
|
||||
@@ -154,6 +232,25 @@ namespace Octokit.Tests.Reactive
|
||||
connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/milestones/42/labels"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IConnection>();
|
||||
var gitHubClient = new GitHubClient(connection);
|
||||
var client = new ObservableIssuesLabelsClient(gitHubClient);
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
StartPage = 1,
|
||||
PageSize = 1
|
||||
};
|
||||
|
||||
client.GetAllForMilestone(1, 42, options);
|
||||
|
||||
connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/milestones/42/labels"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
@@ -165,6 +262,8 @@ namespace Octokit.Tests.Reactive
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForMilestone("owner", null, 42, ApiOptions.None));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForMilestone("owner", "name", 42, null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAllForMilestone(1, 42, null));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.GetAllForMilestone("", "name", 42));
|
||||
Assert.Throws<ArgumentException>(() => client.GetAllForMilestone("owner", "", 42));
|
||||
Assert.Throws<ArgumentException>(() => client.GetAllForMilestone("", "name", 42, ApiOptions.None));
|
||||
@@ -185,6 +284,17 @@ namespace Octokit.Tests.Reactive
|
||||
gitHubClient.Issue.Labels.Received().Get("fake", "repo", "label");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesLabelsClient(gitHubClient);
|
||||
|
||||
client.Get(1, "label");
|
||||
|
||||
gitHubClient.Issue.Labels.Received().Get(1, "label");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
@@ -194,9 +304,13 @@ namespace Octokit.Tests.Reactive
|
||||
Assert.Throws<ArgumentNullException>(() => client.Get("owner", null, "label"));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Get("owner", "name", null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Get(1, null));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Get("", "name", "label"));
|
||||
Assert.Throws<ArgumentException>(() => client.Get("owner", "", "label"));
|
||||
Assert.Throws<ArgumentException>(() => client.Get("owner", "name", ""));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Get(1, ""));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,6 +329,17 @@ namespace Octokit.Tests.Reactive
|
||||
gitHubClient.Issue.Labels.Received().AddToIssue("fake", "repo", 42, labels);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PostsToCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesLabelsClient(gitHubClient);
|
||||
|
||||
client.AddToIssue(1, 42, labels);
|
||||
|
||||
gitHubClient.Issue.Labels.Received().AddToIssue(1, 42, labels);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
@@ -224,6 +349,8 @@ namespace Octokit.Tests.Reactive
|
||||
Assert.Throws<ArgumentNullException>(() => client.AddToIssue("owner", null, 42, labels));
|
||||
Assert.Throws<ArgumentNullException>(() => client.AddToIssue("owner", "name", 42, null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.AddToIssue(1, 42, null));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.AddToIssue("", "name", 42, labels));
|
||||
Assert.Throws<ArgumentException>(() => client.AddToIssue("owner", "", 42, labels));
|
||||
}
|
||||
@@ -243,6 +370,18 @@ namespace Octokit.Tests.Reactive
|
||||
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels/label"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DeleteCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IConnection>();
|
||||
var gitHubClient = new GitHubClient(connection);
|
||||
var client = new ObservableIssuesLabelsClient(gitHubClient);
|
||||
|
||||
client.RemoveFromIssue(1, 42, "label");
|
||||
|
||||
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels/label"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
@@ -252,9 +391,13 @@ namespace Octokit.Tests.Reactive
|
||||
Assert.Throws<ArgumentNullException>(() => client.RemoveFromIssue("owner", null, 42, "label"));
|
||||
Assert.Throws<ArgumentNullException>(() => client.RemoveFromIssue("owner", "name", 42, null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.RemoveFromIssue(1, 42, null));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.RemoveFromIssue("", "name", 42, "label"));
|
||||
Assert.Throws<ArgumentException>(() => client.RemoveFromIssue("owner", "", 42, "label"));
|
||||
Assert.Throws<ArgumentException>(() => client.RemoveFromIssue("owner", "name", 42, ""));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.RemoveFromIssue(1, 42, ""));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,6 +416,17 @@ namespace Octokit.Tests.Reactive
|
||||
gitHubClient.Issue.Labels.Received().ReplaceAllForIssue("fake", "repo", 42, labels);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PutsToCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesLabelsClient(gitHubClient);
|
||||
|
||||
client.ReplaceAllForIssue(1, 42, labels);
|
||||
|
||||
gitHubClient.Issue.Labels.Received().ReplaceAllForIssue(1, 42, labels);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
@@ -282,6 +436,8 @@ namespace Octokit.Tests.Reactive
|
||||
Assert.Throws<ArgumentNullException>(() => client.ReplaceAllForIssue("owner", null, 42, labels));
|
||||
Assert.Throws<ArgumentNullException>(() => client.ReplaceAllForIssue("owner", "name", 42, null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.ReplaceAllForIssue(1, 42, null));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.ReplaceAllForIssue("", "name", 42, labels));
|
||||
Assert.Throws<ArgumentException>(() => client.ReplaceAllForIssue("owner", "", 42, labels));
|
||||
}
|
||||
@@ -301,6 +457,18 @@ namespace Octokit.Tests.Reactive
|
||||
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DeletesCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IConnection>();
|
||||
var gitHubClient = new GitHubClient(connection);
|
||||
var client = new ObservableIssuesLabelsClient(gitHubClient);
|
||||
|
||||
client.RemoveAllFromIssue(1, 42);
|
||||
|
||||
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
@@ -313,5 +481,143 @@ namespace Octokit.Tests.Reactive
|
||||
Assert.Throws<ArgumentException>(() => client.RemoveAllFromIssue("owner", "", 42));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheDeleteMethod
|
||||
{
|
||||
[Fact]
|
||||
public void DeletesCorrectUrl()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesLabelsClient(gitHubClient);
|
||||
|
||||
client.Delete("fake", "repo", "labelName");
|
||||
|
||||
gitHubClient.Received().Issue.Labels.Delete("fake", "repo", "labelName");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DeletesCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesLabelsClient(gitHubClient);
|
||||
|
||||
client.Delete(1, "labelName");
|
||||
|
||||
gitHubClient.Received().Issue.Labels.Delete(1, "labelName");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ObservableIssuesLabelsClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Delete(null, "name", "labelName"));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Delete("owner", null, "labelName"));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Delete("owner", "name", null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Delete(1, null));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Delete("", "name", "labelName"));
|
||||
Assert.Throws<ArgumentException>(() => client.Delete("owner", "", "labelName"));
|
||||
Assert.Throws<ArgumentException>(() => client.Delete("owner", "name", ""));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Delete(1, ""));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheCreateMethod
|
||||
{
|
||||
[Fact]
|
||||
public void CreatesCorrectUrl()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesLabelsClient(gitHubClient);
|
||||
|
||||
var newLabel = new NewLabel("labelName", "FF0000");
|
||||
|
||||
client.Create("fake", "repo", newLabel);
|
||||
|
||||
gitHubClient.Received().Issue.Labels.Create("fake", "repo", newLabel);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CreatesCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesLabelsClient(gitHubClient);
|
||||
|
||||
var newLabel = new NewLabel("labelName", "FF0000");
|
||||
|
||||
client.Create(1, newLabel);
|
||||
|
||||
gitHubClient.Received().Issue.Labels.Create(1, newLabel);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ObservableIssuesLabelsClient(Substitute.For<IGitHubClient>());
|
||||
var newLabel = new NewLabel("labelName", "FF0000");
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Create(null, "name", newLabel));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Create("owner", null, newLabel));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Create("owner", "name", null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Create(1, null));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Create("", "name", newLabel));
|
||||
Assert.Throws<ArgumentException>(() => client.Create("owner", "", newLabel));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheUpdateMethod
|
||||
{
|
||||
[Fact]
|
||||
public void UpdatesCorrectUrl()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesLabelsClient(gitHubClient);
|
||||
|
||||
var labelUpdate = new LabelUpdate("name", "FF0000");
|
||||
|
||||
client.Update("fake", "repo", "labelName", labelUpdate);
|
||||
|
||||
gitHubClient.Received().Issue.Labels.Update("fake", "repo", "labelName", labelUpdate);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UpdatesCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesLabelsClient(gitHubClient);
|
||||
|
||||
var labelUpdate = new LabelUpdate("name", "FF0000");
|
||||
|
||||
client.Update(1, "labelName", labelUpdate);
|
||||
|
||||
gitHubClient.Received().Issue.Labels.Update(1, "labelName", labelUpdate);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ObservableIssuesLabelsClient(Substitute.For<IGitHubClient>());
|
||||
var labelUpdate = new LabelUpdate("name", "FF0000");
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Update(null, "name", "labelName", labelUpdate));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Update("owner", null, "labelName", labelUpdate));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Update("owner", "name", null, labelUpdate));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Update("owner", "name", "labelName", null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Update(1, null, labelUpdate));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Update(1, "labelName", null));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Update("", "name", "labelName", labelUpdate));
|
||||
Assert.Throws<ArgumentException>(() => client.Update("owner", "", "labelName", labelUpdate));
|
||||
Assert.Throws<ArgumentException>(() => client.Update("owner", "name", "", labelUpdate));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Update(1, "", labelUpdate));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user