public async Task Create_Branch_Exception() { var InputOwner = "foo"; var InputRepo = "bar"; var InputBranchName = "baz"; var InputSha = "qux"; var ExpectedURL = $"https://api.github.com/repos/{InputOwner}/{InputRepo}/git/refs"; var branchRef = new BranchRef() { Ref = $"refs/heads/{InputBranchName}", sha = InputSha }; var ExpectedJson = JsonConvert.SerializeObject(branchRef); var fixture = new GitHubFixture(); fixture.SetupCreateBranchWithFailure(ExpectedURL, ExpectedJson); var repository = new GitHubRepository(fixture.GitHubContext); var ex = await Assert.ThrowsAsync <RestAPICallException>(async() => await repository.CreateBranchAsync(InputOwner, InputRepo, InputBranchName, InputSha) ); Assert.Equal("InternalServerError", ex.StatusCode); Assert.Equal("Internal Server Error", ex.Message); Assert.Equal(ExpectedURL, ex.RequestMessage.RequestUri.ToString()); }
public async Task Create_Branch_Normal() { var InputOwner = "foo"; var InputRepo = "bar"; var InputBranchName = "baz"; var InputSha = "qux"; // public async Task CreateBranchAsync(string owner, string repo, string branchName, string sha) var ExpectedURL = $"https://api.github.com/repos/{InputOwner}/{InputRepo}/git/refs"; var branchRef = new BranchRef() { Ref = $"refs/heads/{InputBranchName}", sha = InputSha }; var ExpectedJson = JsonConvert.SerializeObject(branchRef); var fixture = new GitHubFixture(); fixture.SetupCreateBranch(ExpectedURL, ExpectedJson); var repository = new GitHubRepository(fixture.GitHubContext); await repository.CreateBranchAsync(InputOwner, InputRepo, InputBranchName, InputSha); fixture.VerifyCreateBranch(ExpectedURL, ExpectedJson); }