public async Task RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); await client.GetAllForRepository(1); connection.Received().GetAll <PullRequest>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/pulls"), Arg.Any <Dictionary <string, string> >(), "application/vnd.github.shadow-cat-preview+json", Args.ApiOptions); }
public async Task RequestsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); await client.GetAllForRepository("fake", "repo"); connection.Received().GetAll <PullRequest>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/pulls"), Arg.Any <Dictionary <string, string> >()); }
public async Task RequestsCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); await client.GetAllForRepository("fake", "repo"); connection.Received().GetAll<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls"), Arg.Any<Dictionary<string, string>>(), Args.ApiOptions); }
public async Task SendsAppropriateParameters() { var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); await client.GetAllForRepository("fake", "repo", new PullRequestRequest { Head = "user:ref-head", Base = "fake_base_branch" }); connection.Received().GetAll<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls"), Arg.Is<Dictionary<string, string>>(d => d.Count == 5 && d["head"] == "user:ref-head" && d["state"] == "open" && d["base"] == "fake_base_branch" && d["sort"] == "created" && d["direction"] == "desc"), Args.ApiOptions); }
public async Task SendsAppropriateParametersWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); await client.GetAllForRepository(1, new PullRequestRequest { Head = "user:ref-head", Base = "fake_base_branch" }); connection.Received().GetAll <PullRequest>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/pulls"), Arg.Is <Dictionary <string, string> >(d => d.Count == 5 && d["head"] == "user:ref-head" && d["state"] == "open" && d["base"] == "fake_base_branch" && d["sort"] == "created" && d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json", Args.ApiOptions); }
public void SendsAppropriateParameters() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); client.GetAllForRepository("fake", "repo", new PullRequestRequest { Head = "user:ref-head", Base = "fake_base_branch" }); connection.Received().GetAll <PullRequest>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/pulls"), Arg.Is <Dictionary <string, string> >(d => d.Count == 5 && d["head"] == "user:ref-head" && d["state"] == "open" && d["base"] == "fake_base_branch" && d["sort"] == "created" && d["direction"] == "desc")); }
public async Task RequestsCorrectUrlWithApiOptions() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); var options = new ApiOptions { StartPage = 1, PageCount = 1, PageSize = 1 }; await client.GetAllForRepository("fake", "repo", options); connection.Received().GetAll <PullRequest>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/pulls"), Arg.Any <Dictionary <string, string> >(), "application/vnd.github.shadow-cat-preview+json", options); }
public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); var options = new ApiOptions { StartPage = 1, PageCount = 1, PageSize = 1 }; await client.GetAllForRepository(1, options); connection.Received().GetAll <PullRequest>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/pulls"), Arg.Any <Dictionary <string, string> >(), options); }
public async Task SendsAppropriateParametersWithApiOptionsWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); var options = new ApiOptions { StartPage = 1, PageCount = 1, PageSize = 1 }; await client.GetAllForRepository(1, new PullRequestRequest { Head = "user:ref-head", Base = "fake_base_branch" }, options); connection.Received().GetAll <PullRequest>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/pulls"), Arg.Is <Dictionary <string, string> >(d => d.Count == 5 && d["head"] == "user:ref-head" && d["state"] == "open" && d["base"] == "fake_base_branch" && d["sort"] == "created" && d["direction"] == "desc"), options); }
public async IAsyncEnumerable <PullRequest> EnumerateClosedPullRequests( string organization, string repository) { EnsureGitHubAuthenticatiod(); var apiConnection = new ApiConnection(GitHubClient.Connection); var pullRequestsClient = new PullRequestsClient(apiConnection); var page = 1; while (true) { var apiOptions = new ApiOptions() { StartPage = page, PageCount = 1 }; var pullRequests = await pullRequestsClient.GetAllForRepository(organization, repository, new PullRequestRequest() { State = ItemStateFilter.Closed, SortDirection = SortDirection.Descending, SortProperty = PullRequestSort.Created, }, apiOptions).ConfigureAwait(false); if (pullRequests.Count == 0) { break; } foreach (var pullRequest in pullRequests) { yield return(pullRequest); } page++; } }
public async Task EnsuresNonNullArguments() { var client = new PullRequestsClient(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", (ApiOptions)null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", new PullRequestRequest())); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, new PullRequestRequest())); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (PullRequestRequest)null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", new PullRequestRequest(), ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, new PullRequestRequest(), ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null, ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", new PullRequestRequest(), 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)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", new PullRequestRequest())); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", new PullRequestRequest())); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", new PullRequestRequest(), ApiOptions.None)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", new PullRequestRequest(), ApiOptions.None)); }
public async Task EnsuresNonNullArguments() { var client = new PullRequestsClient(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", (ApiOptions)null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(null, "name", new PullRequestRequest())); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", null, new PullRequestRequest())); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (PullRequestRequest)null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(null, "name", new PullRequestRequest(), ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", null, new PullRequestRequest(), ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", "name", new PullRequestRequest(), null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(1, (ApiOptions)null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(1, (PullRequestRequest)null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(1, null, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(1, new PullRequestRequest(), 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)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("", "name", new PullRequestRequest())); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("owner", "", new PullRequestRequest())); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("", "name", new PullRequestRequest(), ApiOptions.None)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("owner", "", new PullRequestRequest(), ApiOptions.None)); }
public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); var options = new ApiOptions { StartPage = 1, PageCount = 1, PageSize = 1 }; await client.GetAllForRepository(1, options); connection.Received().GetAll<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls"), Arg.Any<Dictionary<string, string>>(), options); }
public async Task SendsAppropriateParametersWithApiOptionsWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); var options = new ApiOptions { StartPage = 1, PageCount = 1, PageSize = 1 }; await client.GetAllForRepository(1, new PullRequestRequest { Head = "user:ref-head", Base = "fake_base_branch" }, options); connection.Received().GetAll<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls"), Arg.Is<Dictionary<string, string>>(d => d.Count == 5 && d["head"] == "user:ref-head" && d["state"] == "open" && d["base"] == "fake_base_branch" && d["sort"] == "created" && d["direction"] == "desc"), options); }