public async Task RequestsCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new IssuesLabelsClient(connection); await client.GetAllForIssue("fake", "repo", 42); connection.Received().GetAll<Label>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels")); }
public async Task RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new IssuesLabelsClient(connection); await client.GetAllForIssue(1, 42); connection.Received().GetAll<Label>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels"), Args.ApiOptions); }
public async Task RequestsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new IssuesLabelsClient(connection); await client.GetAllForIssue("fake", "repo", 42); connection.Received().GetAll <Label>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Args.ApiOptions); }
public async Task RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new IssuesLabelsClient(connection); await client.GetAllForIssue(1, 42); connection.Received().GetAll <Label>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/issues/42/labels"), null, "application/vnd.github.symmetra-preview+json", Args.ApiOptions); }
public async Task EnsuresNonNullArguments() { var client = new IssuesLabelsClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForIssue(null, "name", 1)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForIssue("owner", null, 1)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForIssue(null, "name", 1, ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForIssue("owner", null, 1, ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForIssue("owner", "name", 1, null)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForIssue("", "name", 1)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForIssue("owner", "", 1)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForIssue("", "name", 1, ApiOptions.None)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForIssue("owner", "", 1, ApiOptions.None)); }
public async Task EnsuresNonNullArguments() { var client = new IssuesLabelsClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForIssue(null, "name", 1)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForIssue("owner", null, 1)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForIssue(null, "name", 1, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForIssue("owner", null, 1, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForIssue("owner", "name", 1, null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForIssue(1, 1, null)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForIssue("", "name", 1)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForIssue("owner", "", 1)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForIssue("", "name", 1, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForIssue("owner", "", 1, ApiOptions.None)); }
public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new IssuesLabelsClient(connection); var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; await client.GetAllForIssue(1, 42, options); connection.Received().GetAll<Label>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels"), options); }
public async Task RequestsCorrectUrlWithApiOptions() { var connection = Substitute.For <IApiConnection>(); var client = new IssuesLabelsClient(connection); var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; await client.GetAllForIssue("fake", "repo", 42, options); connection.Received().GetAll <Label>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels"), options); }
private Task <IReadOnlyList <Label> > GetLabelsAsync(PullRequestContext context) { var client = new IssuesLabelsClient(new ApiConnection(context.GithubConnection)); return(client.GetAllForIssue(context.Payload.Repository.Id, context.Payload.PullRequest.Number)); }