public async Task EnsuresArgumentsNotNull() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); AssertEx.Throws <ArgumentNullException>(async() => await client.Create(null, "name", new NewPullRequest("title", "ref", "ref2"))); AssertEx.Throws <ArgumentException>(async() => await client.Create("", "name", new NewPullRequest("title", "ref", "ref2"))); AssertEx.Throws <ArgumentNullException>(async() => await client.Create("owner", null, new NewPullRequest("title", "ref", "ref2"))); AssertEx.Throws <ArgumentException>(async() => await client.Create("owner", "", new NewPullRequest("title", "ref", "ref2"))); AssertEx.Throws <ArgumentNullException>(async() => await client.Create("owner", "name", null)); }
/// <summary> /// Commit the changes. /// Creates a pr from <see cref="CurrentBranch"/> of <see cref="LocalRepo"/> to <see cref="OriginBranch"/> of <see cref="OriginRepo"/> /// </summary> /// <param name="prTitle">Title of the creating pull request</param> public Task Commit(string prTitle) { if (string.IsNullOrWhiteSpace(prTitle)) { throw new ArgumentException("Pull request title must be not empty."); } var head = $"{LocalRepo.Owner.Login}:{CurrentBranch.Ref}"; return(PullRequestsClient.Create(OriginRepo.Id, new(prTitle, head, OriginBranch.Ref) { Draft = true }));
public void PostsToCorrectUrl() { var newPullRequest = new NewPullRequest("some title", "branch:name", "branch:name"); var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); client.Create("fake", "repo", newPullRequest); connection.Received().Post <PullRequest>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/pulls"), newPullRequest); }
public void PostsToCorrectUrl() { var newPullRequest = new NewPullRequest("some title", "branch:name", "branch:name"); var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); client.Create("fake", "repo", newPullRequest); connection.Received().Post<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls"), newPullRequest); }
public async Task PostsToCorrectUrlWithRepositoryId() { var newPullRequest = new NewPullRequest("some title", "branch:name", "branch:name"); var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); await client.Create(1, newPullRequest); connection.Received().Post <PullRequest>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/pulls"), newPullRequest, "application/vnd.github.shadow-cat-preview+json"); }
public async Task EnsuresNonNullArguments() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create(null, "name", new NewPullRequest("title", "ref", "ref2"))); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create("owner", null, new NewPullRequest("title", "ref", "ref2"))); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create("owner", "name", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create(1, null)); await Assert.ThrowsAsync <ArgumentException>(() => client.Create("", "name", new NewPullRequest("title", "ref", "ref2"))); await Assert.ThrowsAsync <ArgumentException>(() => client.Create("owner", "", new NewPullRequest("title", "ref", "ref2"))); }
public async Task EnsuresArgumentsNotNull() { var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); await AssertEx.Throws<ArgumentNullException>(() => client.Create(null, "name", new NewPullRequest("title", "ref", "ref2"))); await AssertEx.Throws<ArgumentException>(() => client.Create("", "name", new NewPullRequest("title", "ref", "ref2"))); await AssertEx.Throws<ArgumentNullException>(() => client.Create("owner", null, new NewPullRequest("title", "ref", "ref2"))); await AssertEx.Throws<ArgumentException>(() => client.Create("owner", "", new NewPullRequest("title", "ref", "ref2"))); await AssertEx.Throws<ArgumentNullException>(() => client.Create("owner", "name", null)); }
public async Task PostsToCorrectUrlWithRepositoryId() { var newPullRequest = new NewPullRequest("some title", "branch:name", "branch:name"); var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); await client.Create(1, newPullRequest); connection.Received().Post<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls"), newPullRequest); }