mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
* Add release notes and bump version to 0.24 * run "build FormatCode" to fix up whitespace/formatting issues * Fix failing Ssh key tests due to "validation exception". This key must be in use on github (under another user, most likely from these tests failing). Changed to a new SSH key and tweaked tests to reduce chance of a key being created and not destroyed * Assignee and Assignees cant both be specified on NewIssue. We missed this one in the PR. Marked Assignee as [Obsolete] and fixed tests to use Assignees * Fix a couple of Reactions tests that were calling the wrong client methods * Fix timeline tests - looks like the response class has changed shape a bit, it now has an Issue object in the payload and Id field isnt present (leaving Id field there in case other timeline events do use it) * Fix some following tests that require the test user to follow more than 1 other user * Unskip these Event tests now because apparently they work! * add breaking changes notes * Update ApiErrorMessageSafe to return null for empty and whitespace strings (#1540) * return null if ApiError.Message is empty or whitespace * Uncomment test, which now passes * update release notes to include PR1540 * Add "Bot" AccountType, was causing a deserialization exception when running the integration test "SearchForExcludedLanguage" (#1541) * Update to include PR1541 * add bullets to make release notes easier to read * markup additional code mentions in notes * Fix grammar fields => field
150 lines
5.6 KiB
C#
150 lines
5.6 KiB
C#
using System;
|
|
using System.Reactive.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using NSubstitute;
|
|
using Octokit.Reactive;
|
|
using Xunit;
|
|
|
|
namespace Octokit.Tests
|
|
{
|
|
public class ObservableTreesClientTests
|
|
{
|
|
public class TheCtor
|
|
{
|
|
[Fact]
|
|
public void EnsuresNonNullArguments()
|
|
{
|
|
Assert.Throws<ArgumentNullException>(() => new ObservableTreesClient(null));
|
|
}
|
|
}
|
|
|
|
public class TheGetMethod
|
|
{
|
|
[Fact]
|
|
public void RequestsCorrectUrl()
|
|
{
|
|
var gitHubClient = Substitute.For<IGitHubClient>();
|
|
var client = new ObservableTreesClient(gitHubClient);
|
|
|
|
client.Get("fake", "repo", "123456ABCD");
|
|
|
|
gitHubClient.Git.Tree.Received().Get("fake", "repo", "123456ABCD");
|
|
}
|
|
|
|
[Fact]
|
|
public void RequestsCorrectUrlWithRepositoryId()
|
|
{
|
|
var gitHubClient = Substitute.For<IGitHubClient>();
|
|
var client = new ObservableTreesClient(gitHubClient);
|
|
|
|
client.Get(1, "123456ABCD");
|
|
|
|
gitHubClient.Git.Tree.Received().Get(1, "123456ABCD");
|
|
}
|
|
|
|
[Fact]
|
|
public async Task EnsuresNonNullArguments()
|
|
{
|
|
var client = new ObservableTreesClient(Substitute.For<IGitHubClient>());
|
|
|
|
Assert.Throws<ArgumentNullException>(() => client.Get(null, "name", "123456ABCD"));
|
|
Assert.Throws<ArgumentNullException>(() => client.Get("owner", null, "123456ABCD"));
|
|
Assert.Throws<ArgumentNullException>(() => client.Get("owner", "name", null));
|
|
|
|
Assert.Throws<ArgumentNullException>(() => client.Get(1, null));
|
|
|
|
Assert.Throws<ArgumentException>(() => client.Get("", "name", "123456ABCD"));
|
|
Assert.Throws<ArgumentException>(() => client.Get("owner", "", "123456ABCD"));
|
|
Assert.Throws<ArgumentException>(() => client.Get("owner", "name", ""));
|
|
|
|
Assert.Throws<ArgumentException>(() => client.Get(1, ""));
|
|
}
|
|
}
|
|
|
|
public class TheGetRecursiveMethod
|
|
{
|
|
[Fact]
|
|
public void RequestsCorrectUrl()
|
|
{
|
|
var gitHubClient = Substitute.For<IGitHubClient>();
|
|
var client = new ObservableTreesClient(gitHubClient);
|
|
|
|
client.GetRecursive("fake", "repo", "123456ABCD");
|
|
|
|
gitHubClient.Git.Tree.Received().GetRecursive("fake", "repo", "123456ABCD");
|
|
}
|
|
|
|
[Fact]
|
|
public void RequestsCorrectUrlWithRepositoryId()
|
|
{
|
|
var gitHubClient = Substitute.For<IGitHubClient>();
|
|
var client = new ObservableTreesClient(gitHubClient);
|
|
|
|
client.GetRecursive(1, "123456ABCD");
|
|
|
|
gitHubClient.Git.Tree.Received().GetRecursive(1, "123456ABCD");
|
|
}
|
|
|
|
[Fact]
|
|
public async Task EnsuresNonNullArguments()
|
|
{
|
|
var client = new ObservableTreesClient(Substitute.For<IGitHubClient>());
|
|
|
|
Assert.Throws<ArgumentNullException>(() => client.GetRecursive(null, "name", "123456ABCD"));
|
|
Assert.Throws<ArgumentNullException>(() => client.GetRecursive("owner", null, "123456ABCD"));
|
|
Assert.Throws<ArgumentNullException>(() => client.GetRecursive("owner", "name", null));
|
|
|
|
Assert.Throws<ArgumentNullException>(() => client.GetRecursive(1, null));
|
|
|
|
Assert.Throws<ArgumentException>(() => client.GetRecursive("", "name", "123456ABCD"));
|
|
Assert.Throws<ArgumentException>(() => client.GetRecursive("owner", "", "123456ABCD"));
|
|
Assert.Throws<ArgumentException>(() => client.GetRecursive("owner", "name", ""));
|
|
|
|
Assert.Throws<ArgumentException>(() => client.GetRecursive(1, ""));
|
|
}
|
|
}
|
|
|
|
public class TheCreateMethod
|
|
{
|
|
[Fact]
|
|
public void RequestsCorrectUrl()
|
|
{
|
|
var newTree = new NewTree();
|
|
var gitHubClient = Substitute.For<IGitHubClient>();
|
|
var client = new ObservableTreesClient(gitHubClient);
|
|
|
|
client.Create("fake", "repo", newTree);
|
|
|
|
gitHubClient.Git.Tree.Received().Create("fake", "repo", newTree);
|
|
}
|
|
|
|
[Fact]
|
|
public void RequestsCorrectUrlWithRepositoryId()
|
|
{
|
|
var newTree = new NewTree();
|
|
var gitHubClient = Substitute.For<IGitHubClient>();
|
|
var client = new ObservableTreesClient(gitHubClient);
|
|
|
|
client.Create(1, newTree);
|
|
|
|
gitHubClient.Git.Tree.Received().Create(1, newTree);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task EnsuresNonNullArguments()
|
|
{
|
|
var client = new ObservableTreesClient(Substitute.For<IGitHubClient>());
|
|
|
|
Assert.Throws<ArgumentNullException>(() => client.Create(null, "name", new NewTree()));
|
|
Assert.Throws<ArgumentNullException>(() => client.Create("owner", null, new NewTree()));
|
|
Assert.Throws<ArgumentNullException>(() => client.Create("owner", "name", null));
|
|
|
|
Assert.Throws<ArgumentNullException>(() => client.Create(1, null));
|
|
|
|
Assert.Throws<ArgumentException>(() => client.Create("", "name", new NewTree()));
|
|
Assert.Throws<ArgumentException>(() => client.Create("owner", "", new NewTree()));
|
|
}
|
|
}
|
|
}
|
|
}
|