public static async Task <IEnumerable <Models.Objects.Label> > ListLabelsAsync(this GitHubClient s_gitHub, RepositoryInfo repo) { IssuesLabelsClient ilc = new IssuesLabelsClient(new ApiConnection(s_gitHub.Connection)); var labelsFromOctokit = await ilc.GetAllForRepository(repo.Owner, repo.Name); return(labelsFromOctokit.Select(l => new Models.Objects.Label(l))); }
public async Task RequestsCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new IssuesLabelsClient(connection); await client.GetAllForRepository("fake", "repo"); connection.Received().GetAll<Label>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/labels")); }
public async Task RequestsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new IssuesLabelsClient(connection); await client.GetAllForRepository("fake", "repo"); connection.Received().GetAll <Label>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/labels"), Args.ApiOptions); }
public async Task RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new IssuesLabelsClient(connection); await client.GetAllForRepository(1); connection.Received().GetAll <Label>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/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.GetAllForRepository(null, "name")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(null, "name", ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", null, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(1, null)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("", "name")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("owner", "")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("", "name", ApiOptions.None)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("owner", "", ApiOptions.None)); }
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.GetAllForRepository("fake", "repo", options); connection.Received().GetAll <Label>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/labels"), options); }
public async Task EnsuresNonNullArguments() { var client = new IssuesLabelsClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(1, null)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", ApiOptions.None)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", 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.GetAllForRepository(1, options); connection.Received().GetAll<Label>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/labels"), options); }
public async Task RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new IssuesLabelsClient(connection); await client.GetAllForRepository(1); connection.Received().GetAll<Label>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/labels"), Args.ApiOptions); }