mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-19 21:55:12 +00:00
83 lines
2.8 KiB
C#
83 lines
2.8 KiB
C#
using NSubstitute;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using Xunit;
|
|
|
|
namespace Octokit.Tests.Clients
|
|
{
|
|
public class RepositoryPagesClientTests
|
|
{
|
|
public class TheGetMethod
|
|
{
|
|
[Fact]
|
|
public void RequestsCorrectUrl()
|
|
{
|
|
var connection = Substitute.For<IApiConnection>();
|
|
var client = new RepositoryPagesClient(connection);
|
|
|
|
client.Get("fake", "repo");
|
|
|
|
connection.Received().Get<Page>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pages"), null);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task EnsuresNonNullArguments()
|
|
{
|
|
var connection = Substitute.For<IApiConnection>();
|
|
var client = new RepositoryPagesClient(connection);
|
|
|
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "name"));
|
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null));
|
|
}
|
|
}
|
|
|
|
public class TheGetBuildsMethod
|
|
{
|
|
[Fact]
|
|
public void RequestsCorrectUrl()
|
|
{
|
|
var connection = Substitute.For<IApiConnection>();
|
|
var client = new RepositoryPagesClient(connection);
|
|
|
|
client.GetAllBuilds("fake", "repo");
|
|
|
|
connection.Received().GetAll<PagesBuild>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pages/builds"));
|
|
}
|
|
|
|
[Fact]
|
|
public async Task EnsuresNonNullArguments()
|
|
{
|
|
var connection = Substitute.For<IApiConnection>();
|
|
var client = new RepositoryPagesClient(connection);
|
|
|
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "name"));
|
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null));
|
|
}
|
|
}
|
|
|
|
public class TheGetLatestBuildMethod
|
|
{
|
|
[Fact]
|
|
public void RequestsCorrectUrl()
|
|
{
|
|
var connection = Substitute.For<IApiConnection>();
|
|
var client = new RepositoryPagesClient(connection);
|
|
|
|
client.GetLatestBuild("fake", "repo");
|
|
|
|
connection.Received().Get<PagesBuild>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pages/builds/latest"), null);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task EnsuresNonNullArguments()
|
|
{
|
|
var connection = Substitute.For<IApiConnection>();
|
|
var client = new RepositoryPagesClient(connection);
|
|
|
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "name"));
|
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null));
|
|
}
|
|
}
|
|
}
|
|
}
|