public async Task TestGetPullRequestFromMentionAsync_InCorrect() { var repo = new GitHubRepositoryReference("AwesomeOrg", "AwesomeRepo"); var mention = new GitHubMention(repo, 123); var mockPrs = new Mock <IPullRequestsClient>(); mockPrs .Setup(i => i.Get( It.Is <string>(s => s == repo.Owner), It.Is <string>(s => s == repo.Name), It.Is <int>(i => i == mention.Number) )) .ThrowsAsync(new NotFoundException(new Mock <IResponse>().Object)); var mockClient = new Mock <IGitHubClient>(); mockClient.Setup(c => c.PullRequest).Returns(mockPrs.Object); var result = await GitHubMentionResolver.GetPullRequestFromMentionAsync(mockClient.Object, mention); Assert.Null(result); }
public async Task TestGetIssueFromMentionAsync_Correct() { var repo = new GitHubRepositoryReference("AwesomeOrg", "AwesomeRepo"); var mention = new GitHubMention(repo, 123); var issue = new Issue(); var mockIssues = new Mock <IIssuesClient>(); mockIssues .Setup(i => i.Get( It.Is <string>(s => s == repo.Owner), It.Is <string>(s => s == repo.Name), It.Is <int>(i => i == mention.Number) )) .Returns(Task.FromResult(issue)); var mockClient = new Mock <IGitHubClient>(); mockClient.Setup(c => c.Issue).Returns(mockIssues.Object); var result = await GitHubMentionResolver.GetIssueFromMentionAsync(mockClient.Object, mention); Assert.Same(issue, result); }