public void ValidPullRequestIsSent() { var bitbucketPullRequest = new BitbucketPullRequest(); var reviewers = GivenDefaultReviewers(); var nureOptions = GivenNureOptions(); m_ClientMock.Setup(client => client.GetCurrentUser()).Returns(new BitbucketUser()); m_ClientMock.Setup(client => client.GetDefaultReviewers()).Returns(reviewers); m_ClientMock.Setup(client => client.SendPullRequest(It.IsAny <BitbucketPullRequest>())) .Callback <BitbucketPullRequest>(pr => bitbucketPullRequest = pr); var pullRequestWriter = new BitbucketPullRequestWriter(nureOptions, m_ClientMock.Object); pullRequestWriter.WritePullRequest(A_BRANCH_NAME); m_ClientMock.Verify(client => client.GetCurrentUser()); m_ClientMock.Verify(client => client.GetDefaultReviewers()); m_ClientMock.Verify(client => client.SendPullRequest(It.IsAny <BitbucketPullRequest>())); Assert.Equal(nureOptions.PullRequestTitle, bitbucketPullRequest.Title); Assert.Equal(nureOptions.PullRequestDescription, bitbucketPullRequest.Description); Assert.Equal(A_BRANCH_NAME, bitbucketPullRequest.SourceBranch.Branch.Name); Assert.Equal(nureOptions.DefaultBranch, bitbucketPullRequest.DestinationBranch.Branch.Name); Assert.Equal(reviewers, bitbucketPullRequest.Reviewers); }
public void CurrentUserIsFilteredFromDefaultReviewers() { BitbucketPullRequest bitbucketPullRequest = new BitbucketPullRequest(); m_ClientMock.Setup(client => client.GetCurrentUser()).Returns(new BitbucketUser { UserId = A_CURRENT_USER_ID }); m_ClientMock.Setup(client => client.GetDefaultReviewers()).Returns(GivenDefaultReviewers); m_ClientMock.Setup(client => client.SendPullRequest(It.IsAny <BitbucketPullRequest>())).Callback <BitbucketPullRequest>(pr => bitbucketPullRequest = pr); BitbucketPullRequestWriter pullRequestWriter = new BitbucketPullRequestWriter(GivenNureOptions(), m_ClientMock.Object); pullRequestWriter.WritePullRequest(A_BRANCH_NAME); Assert.All(bitbucketPullRequest.Reviewers, reviewer => Assert.NotEqual(A_CURRENT_USER_ID, reviewer.UserId)); }