public async Task PRNeedsMergeGradesAccepted(string commentText, bool gradesExpected, CommentType commentType)
        {
            var gitHubMock = GitHubClientMockFactory.CreateDefault()
                             .WithOrganizationMemberGet("abcabc", true)
                             .WithPullRequestGet(336882879, 24, GitHubMockData.CreatePullRequest(24, Octokit.ItemState.Open, mergeable: true))
                             .WithNeptunTxtContent("NEPT12");
            var gradeStoreMock = GradeStoreMockFactory.Create();

            var eh     = createHandler(commentType, gitHubMock.CreateFactory(), gradeStoreMock.Object);
            var result = await eh.Execute(getPayloadWithComment(commentType, commentText));

            Assert.IsTrue(result.Result.Contains("grade done", System.StringComparison.InvariantCultureIgnoreCase));
            gitHubMock.GitHubClientMock.Verify(c =>
                                               c.PullRequest.Review.Create(336882879, 24, It.IsAny <Octokit.PullRequestReviewCreate>()),
                                               Times.Once());
            gitHubMock.GitHubClientMock.Verify(c =>
                                               c.PullRequest.Merge(336882879, 24, It.IsAny <Octokit.MergePullRequest>()),
                                               Times.Once());

            gradeStoreMock.Verify(c =>
                                  c.StoreGrade("NEPT12", "org1/repo1", 24, "https://www.github.com/org1/repo1/pull/24", It.IsAny <string>(), @"https://github.com/org1/repo1/pull/1#issuecomment-821112111", It.IsAny <IReadOnlyCollection <double> >()),
                                  gradesExpected ? Times.Once() : Times.Never());
            gradeStoreMock.Verify(c =>
                                  c.ConfirmAutoGrade("NEPT12", "org1/repo1", 24, "https://www.github.com/org1/repo1/pull/24", It.IsAny <string>(), @"https://github.com/org1/repo1/pull/1#issuecomment-821112111"),
                                  gradesExpected ? Times.Never() : Times.Once());
        }
        public async Task OtherClosedPullRequestYieldsWarning()
        {
            var gitHubMock = GitHubClientMockFactory.CreateDefault()
                             .WithPullRequestGetAll(c => c.ReturnsAsync(new[]
            {
                GitHubMockData.CreatePullRequest(189, Octokit.ItemState.Open, 556677),
                GitHubMockData.CreatePullRequest(23, Octokit.ItemState.Closed, 556677),
            }))
                             .WithIssueEventGetAll(c => c.ReturnsAsync(new[] { GitHubMockData.CreateIssueEvent(Octokit.EventInfoState.Closed, 444444) }));

            var eh     = new PullRequestOpenDuplicateHandler(gitHubMock.CreateFactory(), MemoryCacheMockFactory.Instance, NullLogger.Instance);
            var result = await eh.Execute(SampleData.PrOpen);

            Assert.IsTrue(result.Result.Contains("already closed PRs", System.StringComparison.InvariantCultureIgnoreCase));
            gitHubMock.GitHubClientMock.Verify(c =>
                                               c.Issue.Comment.Create(339316008, 189, It.IsAny <string>()),
                                               Times.Once());
        }
        public async Task PRAlreadyClosedGradesAccepted(CommentType commentType)
        {
            var gitHubMock = GitHubClientMockFactory.CreateDefault()
                             .WithOrganizationMemberGet("abcabc", true)
                             .WithPullRequestGet(336882879, 24, GitHubMockData.CreatePullRequest(24, Octokit.ItemState.Closed, mergeable: false));
            var gradeStoreMock = GradeStoreMockFactory.Create();

            var eh     = createHandler(commentType, gitHubMock.CreateFactory(), gradeStoreMock.Object);
            var result = await eh.Execute(getPayloadWithComment(commentType, @"/ahk ok"));

            Assert.IsTrue(result.Result.Contains("grade done", System.StringComparison.InvariantCultureIgnoreCase));
            gitHubMock.GitHubClientMock.Verify(c =>
                                               c.PullRequest.Merge(It.IsAny <long>(), It.IsAny <int>(), It.IsAny <Octokit.MergePullRequest>()),
                                               Times.Never());
            gradeStoreMock.Verify(c =>
                                  c.StoreGrade(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <IReadOnlyCollection <double> >()),
                                  Times.Never());
            gradeStoreMock.Verify(c =>
                                  c.ConfirmAutoGrade("ABC123", "org1/repo1", 24, "https://www.github.com/org1/repo1/pull/24", It.IsAny <string>(), @"https://github.com/org1/repo1/pull/1#issuecomment-821112111"),
                                  Times.Once());
        }
        public async Task WorkflowRunsReachedWarningLimit()
        {
            var gitHubMock = GitHubClientMockFactory.CreateDefault();

            var payload = getPayload();
            var gh      = gitHubMock
                          .WithWorkflowRunsCount("aabbcc", "reporep", "someone", 6)
                          .WithPullRequestGetAll(c => c.ReturnsAsync(new[]
            {
                GitHubMockData.CreatePullRequest(1, Octokit.ItemState.Open, 111),
                GitHubMockData.CreatePullRequest(2, Octokit.ItemState.Open, 111),
            }))
                          .CreateFactory();

            var eh     = new ActionWorkflowRunHandler(gh, MemoryCacheMockFactory.Instance, NullLogger.Instance);
            var result = await eh.Execute(payload);

            Assert.IsTrue(result.Result.Contains("workflow_run warning, threshold exceeded", System.StringComparison.InvariantCultureIgnoreCase));
            gitHubMock.GitHubClientMock.Verify(c =>
                                               c.Issue.Comment.Create(283462325, 2, It.IsAny <string>()),
                                               Times.Once());
        }