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(); var client = new RepositoryPagesClient(connection); client.Get("fake", "repo"); connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/pages"), null); } [Fact] public async Task EnsuresNonNullArguments() { var connection = Substitute.For(); var client = new RepositoryPagesClient(connection); await Assert.ThrowsAsync(() => client.Get(null, "name")); await Assert.ThrowsAsync(() => client.Get("owner", null)); } } public class TheGetBuildsMethod { [Fact] public void RequestsCorrectUrl() { var connection = Substitute.For(); var client = new RepositoryPagesClient(connection); client.GetAllBuilds("fake", "repo"); connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/pages/builds")); } [Fact] public async Task EnsuresNonNullArguments() { var connection = Substitute.For(); var client = new RepositoryPagesClient(connection); await Assert.ThrowsAsync(() => client.Get(null, "name")); await Assert.ThrowsAsync(() => client.Get("owner", null)); } } public class TheGetLatestBuildMethod { [Fact] public void RequestsCorrectUrl() { var connection = Substitute.For(); var client = new RepositoryPagesClient(connection); client.GetLatestBuild("fake", "repo"); connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/pages/builds/latest"), null); } [Fact] public async Task EnsuresNonNullArguments() { var connection = Substitute.For(); var client = new RepositoryPagesClient(connection); await Assert.ThrowsAsync(() => client.Get(null, "name")); await Assert.ThrowsAsync(() => client.Get("owner", null)); } } } }