mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-05 23:06:10 +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
199 lines
8.2 KiB
C#
199 lines
8.2 KiB
C#
using System;
|
|
using NSubstitute;
|
|
using Octokit.Reactive;
|
|
using Xunit;
|
|
|
|
namespace Octokit.Tests.Clients
|
|
{
|
|
public class ObservableCommitStatusClientTests
|
|
{
|
|
public class TheGetMethod
|
|
{
|
|
[Fact]
|
|
public void RequestsCorrectUrl()
|
|
{
|
|
var gitHubClient = Substitute.For<IGitHubClient>();
|
|
var client = new ObservableCommitStatusClient(gitHubClient);
|
|
|
|
client.GetAll("fake", "repo", "sha");
|
|
|
|
gitHubClient.Received().Repository.Status.GetAll("fake", "repo", "sha");
|
|
}
|
|
|
|
[Fact]
|
|
public void RequestsCorrectUrlWithRepositoryId()
|
|
{
|
|
var gitHubClient = Substitute.For<IGitHubClient>();
|
|
var client = new ObservableCommitStatusClient(gitHubClient);
|
|
|
|
client.GetAll(1, "sha");
|
|
|
|
gitHubClient.Received().Repository.Status.GetAll(1, "sha");
|
|
}
|
|
|
|
[Fact]
|
|
public void RequestsCorrectUrlWithApiOptions()
|
|
{
|
|
var connection = Substitute.For<IGitHubClient>();
|
|
var client = new ObservableCommitStatusClient(connection);
|
|
|
|
var options = new ApiOptions
|
|
{
|
|
PageSize = 1,
|
|
PageCount = 1,
|
|
StartPage = 1
|
|
};
|
|
|
|
client.GetAll("fake", "repo", "sha", options);
|
|
|
|
connection.Received().Repository.Status.GetAll("fake", "repo", "sha", options);
|
|
}
|
|
|
|
[Fact]
|
|
public void RequestsCorrectUrlWithApiOptionsWithRepositoryId()
|
|
{
|
|
var connection = Substitute.For<IGitHubClient>();
|
|
var client = new ObservableCommitStatusClient(connection);
|
|
|
|
var options = new ApiOptions
|
|
{
|
|
PageSize = 1,
|
|
PageCount = 1,
|
|
StartPage = 1
|
|
};
|
|
|
|
client.GetAll(1, "sha", options);
|
|
|
|
connection.Received().Repository.Status.GetAll(1, "sha", options);
|
|
}
|
|
|
|
[Fact]
|
|
public void EnsuresNonNullArguments()
|
|
{
|
|
var client = new ObservableCommitStatusClient(Substitute.For<IGitHubClient>());
|
|
|
|
Assert.Throws<ArgumentNullException>(() => client.GetAll(null, "name", "sha"));
|
|
Assert.Throws<ArgumentNullException>(() => client.GetAll("owner", null, "sha"));
|
|
Assert.Throws<ArgumentNullException>(() => client.GetAll("owner", "name", null));
|
|
Assert.Throws<ArgumentNullException>(() => client.GetAll(null, "name", "sha", ApiOptions.None));
|
|
Assert.Throws<ArgumentNullException>(() => client.GetAll("owner", null, "sha", ApiOptions.None));
|
|
Assert.Throws<ArgumentNullException>(() => client.GetAll("owner", "name", null, ApiOptions.None));
|
|
Assert.Throws<ArgumentNullException>(() => client.GetAll("owner", "name", "sha", null));
|
|
|
|
Assert.Throws<ArgumentNullException>(() => client.GetAll(1, null));
|
|
Assert.Throws<ArgumentNullException>(() => client.GetAll(1, "sha", null));
|
|
|
|
Assert.Throws<ArgumentException>(() => client.GetAll("", "name", "sha"));
|
|
Assert.Throws<ArgumentException>(() => client.GetAll("owner", "", "sha"));
|
|
Assert.Throws<ArgumentException>(() => client.GetAll("owner", "name", ""));
|
|
Assert.Throws<ArgumentException>(() => client.GetAll("", "name", "sha", ApiOptions.None));
|
|
Assert.Throws<ArgumentException>(() => client.GetAll("owner", "", "sha", ApiOptions.None));
|
|
Assert.Throws<ArgumentException>(() => client.GetAll("owner", "name", "", ApiOptions.None));
|
|
|
|
Assert.Throws<ArgumentException>(() => client.GetAll(1, "", ApiOptions.None));
|
|
}
|
|
}
|
|
|
|
public class TheGetCombinedMethod
|
|
{
|
|
[Fact]
|
|
public void RequestsCorrectUrl()
|
|
{
|
|
var gitHubClient = Substitute.For<IGitHubClient>();
|
|
var client = new ObservableCommitStatusClient(gitHubClient);
|
|
|
|
client.GetCombined("fake", "repo", "sha");
|
|
|
|
gitHubClient.Received().Repository.Status.GetCombined("fake", "repo", "sha");
|
|
}
|
|
|
|
[Fact]
|
|
public void RequestsCorrectUrlWithRepositoryId()
|
|
{
|
|
var gitHubClient = Substitute.For<IGitHubClient>();
|
|
var client = new ObservableCommitStatusClient(gitHubClient);
|
|
|
|
client.GetCombined(1, "sha");
|
|
|
|
gitHubClient.Received().Repository.Status.GetCombined(1, "sha");
|
|
}
|
|
|
|
[Fact]
|
|
public void EnsuresNonNullArguments()
|
|
{
|
|
var client = new ObservableCommitStatusClient(Substitute.For<IGitHubClient>());
|
|
|
|
Assert.Throws<ArgumentNullException>(() => client.GetCombined(null, "name", "sha"));
|
|
Assert.Throws<ArgumentNullException>(() => client.GetCombined("owner", null, "sha"));
|
|
Assert.Throws<ArgumentNullException>(() => client.GetCombined("owner", "name", null));
|
|
|
|
Assert.Throws<ArgumentNullException>(() => client.GetCombined(1, null));
|
|
|
|
Assert.Throws<ArgumentException>(() => client.GetCombined("", "name", "sha"));
|
|
Assert.Throws<ArgumentException>(() => client.GetCombined("owner", "", "sha"));
|
|
Assert.Throws<ArgumentException>(() => client.GetCombined("owner", "name", ""));
|
|
|
|
Assert.Throws<ArgumentException>(() => client.GetCombined(1, ""));
|
|
}
|
|
}
|
|
|
|
public class TheCreateMethodForUser
|
|
{
|
|
[Fact]
|
|
public void PostsToTheCorrectUrl()
|
|
{
|
|
var gitHubClient = Substitute.For<IGitHubClient>();
|
|
var client = new ObservableCommitStatusClient(gitHubClient);
|
|
|
|
var newCommitStatus = new NewCommitStatus { State = CommitState.Success };
|
|
|
|
client.Create("owner", "repo", "sha", newCommitStatus);
|
|
|
|
gitHubClient.Received().Repository.Status.Create("owner", "repo", "sha", newCommitStatus);
|
|
}
|
|
|
|
[Fact]
|
|
public void PostsToTheCorrectUrlWithRepositoryId()
|
|
{
|
|
var gitHubClient = Substitute.For<IGitHubClient>();
|
|
var client = new ObservableCommitStatusClient(gitHubClient);
|
|
|
|
var newCommitStatus = new NewCommitStatus { State = CommitState.Success };
|
|
|
|
client.Create(1, "sha", newCommitStatus);
|
|
|
|
gitHubClient.Received().Repository.Status.Create(1, "sha", newCommitStatus);
|
|
}
|
|
|
|
[Fact]
|
|
public void EnsuresNonNullArguments()
|
|
{
|
|
var client = new ObservableCommitStatusClient(Substitute.For<IGitHubClient>());
|
|
|
|
Assert.Throws<ArgumentNullException>(() => client.Create(null, "name", "sha", new NewCommitStatus()));
|
|
Assert.Throws<ArgumentNullException>(() => client.Create("owner", null, "sha", new NewCommitStatus()));
|
|
Assert.Throws<ArgumentNullException>(() => client.Create("owner", "name", null, new NewCommitStatus()));
|
|
Assert.Throws<ArgumentNullException>(() => client.Create("owner", "name", "sha", null));
|
|
|
|
Assert.Throws<ArgumentNullException>(() => client.Create(1, null, new NewCommitStatus()));
|
|
Assert.Throws<ArgumentNullException>(() => client.Create(1, "sha", null));
|
|
|
|
Assert.Throws<ArgumentException>(() => client.Create("", "name", "sha", new NewCommitStatus()));
|
|
Assert.Throws<ArgumentException>(() => client.Create("owner", "", "sha", new NewCommitStatus()));
|
|
Assert.Throws<ArgumentException>(() => client.Create("owner", "name", "", new NewCommitStatus()));
|
|
|
|
Assert.Throws<ArgumentException>(() => client.Create(1, "", new NewCommitStatus()));
|
|
}
|
|
}
|
|
|
|
public class TheCtor
|
|
{
|
|
[Fact]
|
|
public void EnsuresNonNullArguments()
|
|
{
|
|
Assert.Throws<ArgumentNullException>(() => new ObservableCommitStatusClient(null));
|
|
}
|
|
}
|
|
}
|
|
}
|