mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-20 14:15:12 +00:00
missing test changes & correct tests which were calling Repositories.Get
This commit is contained in:
@@ -32,7 +32,7 @@ namespace Octokit.Tests.Clients
|
|||||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create(null));
|
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create(null));
|
||||||
await AssertEx.Throws<ArgumentException>(async () => await client.Create(new NewRepository { Name = null }));
|
await AssertEx.Throws<ArgumentException>(async () => await client.Create(new NewRepository { Name = null }));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void UsesTheUserReposUrl()
|
public void UsesTheUserReposUrl()
|
||||||
{
|
{
|
||||||
@@ -224,9 +224,9 @@ namespace Octokit.Tests.Clients
|
|||||||
var readme = await reposEndpoint.GetReadme("fake", "repo");
|
var readme = await reposEndpoint.GetReadme("fake", "repo");
|
||||||
|
|
||||||
Assert.Equal("README.md", readme.Name);
|
Assert.Equal("README.md", readme.Name);
|
||||||
connection.Received().Get<ReadmeResponse>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/readme"),
|
connection.Received().Get<ReadmeResponse>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/readme"),
|
||||||
null);
|
null);
|
||||||
connection.DidNotReceive().GetHtml(Arg.Is<Uri>(u => u.ToString() == "https://github.example.com/readme"),
|
connection.DidNotReceive().GetHtml(Arg.Is<Uri>(u => u.ToString() == "https://github.example.com/readme"),
|
||||||
null);
|
null);
|
||||||
var htmlReadme = await readme.GetHtmlContent();
|
var htmlReadme = await readme.GetHtmlContent();
|
||||||
Assert.Equal("<html>README</html>", htmlReadme);
|
Assert.Equal("<html>README</html>", htmlReadme);
|
||||||
@@ -249,28 +249,5 @@ namespace Octokit.Tests.Clients
|
|||||||
Assert.Equal("<html>README</html>", readme);
|
Assert.Equal("<html>README</html>", readme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TheGetMethodForRepositoryHooks
|
|
||||||
{
|
|
||||||
[Fact]
|
|
||||||
public void RequestsCorrectUrl()
|
|
||||||
{
|
|
||||||
var connection = Substitute.For<IApiConnection>();
|
|
||||||
var client = new RepositoriesClient(connection);
|
|
||||||
|
|
||||||
client.Hooks.GetHooks("fake", "repo");
|
|
||||||
|
|
||||||
connection.Received().GetAll<RepositoryHook>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/hooks"));
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task EnsuresNonNullArguments()
|
|
||||||
{
|
|
||||||
var client = new RepositoriesClient(Substitute.For<IApiConnection>());
|
|
||||||
|
|
||||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Get(null, "name"));
|
|
||||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Get("owner", null));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
57
Octokit.Tests/Clients/RepositoryHooksClientTest.cs
Normal file
57
Octokit.Tests/Clients/RepositoryHooksClientTest.cs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using NSubstitute;
|
||||||
|
using Octokit.Tests.Helpers;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Octokit.Tests.Clients
|
||||||
|
{
|
||||||
|
public class RepositoryHooksClientTests
|
||||||
|
{
|
||||||
|
public class TheGetMethod
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void RequestsCorrectUrl()
|
||||||
|
{
|
||||||
|
var connection = Substitute.For<IApiConnection>();
|
||||||
|
var client = new RepositoriesClient(connection);
|
||||||
|
|
||||||
|
client.Hooks.GetHooks("fake", "repo");
|
||||||
|
|
||||||
|
connection.Received().GetAll<RepositoryHook>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/hooks"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task EnsuresNonNullArguments()
|
||||||
|
{
|
||||||
|
var client = new RepositoriesClient(Substitute.For<IApiConnection>());
|
||||||
|
|
||||||
|
await AssertEx.Throws<ArgumentNullException>(async () => await client.Hooks.GetHooks(null, "name"));
|
||||||
|
await AssertEx.Throws<ArgumentNullException>(async () => await client.Hooks.GetHooks("owner", null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TheGetByIdMethod
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void RequestsCorrectUrl()
|
||||||
|
{
|
||||||
|
var connection = Substitute.For<IApiConnection>();
|
||||||
|
var client = new RepositoriesClient(connection);
|
||||||
|
|
||||||
|
client.Hooks.GetHookById("fake", "repo", 12345678);
|
||||||
|
|
||||||
|
connection.Received().Get<RepositoryHook>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/hooks/12345678"), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task EnsuresNonNullArguments()
|
||||||
|
{
|
||||||
|
var client = new RepositoriesClient(Substitute.For<IApiConnection>());
|
||||||
|
|
||||||
|
await AssertEx.Throws<ArgumentNullException>(async () => await client.Hooks.GetHookById(null, "name", 123));
|
||||||
|
await AssertEx.Throws<ArgumentNullException>(async () => await client.Hooks.GetHookById("owner", null, 123));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -66,6 +66,7 @@
|
|||||||
<Compile Include="Clients\IssuesClientTests.cs" />
|
<Compile Include="Clients\IssuesClientTests.cs" />
|
||||||
<Compile Include="Clients\NotificationsClientTests.cs" />
|
<Compile Include="Clients\NotificationsClientTests.cs" />
|
||||||
<Compile Include="Clients\ReleasesClientTests.cs" />
|
<Compile Include="Clients\ReleasesClientTests.cs" />
|
||||||
|
<Compile Include="Clients\RepositoryHooksClientTest.cs" />
|
||||||
<Compile Include="Clients\SshKeysClientTests.cs" />
|
<Compile Include="Clients\SshKeysClientTests.cs" />
|
||||||
<Compile Include="Exceptions\ApiExceptionTests.cs" />
|
<Compile Include="Exceptions\ApiExceptionTests.cs" />
|
||||||
<Compile Include="Exceptions\ApiValidationExceptionTests.cs" />
|
<Compile Include="Exceptions\ApiValidationExceptionTests.cs" />
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ namespace Octokit
|
|||||||
{
|
{
|
||||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
|
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
|
||||||
Ensure.ArgumentNotNull(hookId, "hookId");
|
|
||||||
|
|
||||||
return ApiConnection.Get<RepositoryHook>(ApiUrls.RepositoryHooksById(owner, repositoryName, hookId));
|
return ApiConnection.Get<RepositoryHook>(ApiUrls.RepositoryHooksById(owner, repositoryName, hookId));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user