예제 #1
0
        public async Task ItShouldProcessIssueCommentsWebhookWhenActionIsCreated(string actionState)
        {
            var currentUser = new User("", "", "", 0, "", DateTimeOffset.MinValue, DateTimeOffset.MinValue, 0, "", 0,
                                       0, null, "", 0, 0, "", "currentUser", null, 0, null, 0, 0, 0, "",
                                       new RepositoryPermissions(false, false, false), false, "", null);

            var githubService = new Mock <IGitHubService>();

            githubService.Setup(x => x.GetCurrentUser()).ReturnsAsync(currentUser);

            var pipelineRunnerService = new Mock <IPipelineRunnerService>();

            var controller = new GitHubController(pipelineRunnerService.Object, githubService.Object);

            var viewModel = new IssueCommentWebHookViewModel()
            {
                Action = actionState,
                Issue  = new IssueViewModel()
                {
                    Number = 5
                },
                Comment = new IssueCommentViewModel()
                {
                    User = new UserViewModel()
                    {
                        Login = "******"
                    }
                }
            };

            var result = await controller.HandleIssueCommentsWebhook("", viewModel);

            pipelineRunnerService.Verify(x => x.ProcessIssue(It.Is <int>(y => y == 5)), Times.Once());
            Assert.IsType <OkResult>(result);
        }
예제 #2
0
        public async Task ItShouldNotProcessIssueCommentsWebhookWhenActionIsNotCreated(string actionState)
        {
            var pipelineRunnerService = new Mock <IPipelineRunnerService>();

            var controller = new GitHubController(pipelineRunnerService.Object, Mock.Of <IGitHubService>());

            var viewModel = new IssueCommentWebHookViewModel()
            {
                Action = actionState,
                Issue  = new IssueViewModel()
                {
                    Number = 5
                },
                Comment = new IssueCommentViewModel()
                {
                    User = new UserViewModel()
                    {
                        Login = "******"
                    }
                }
            };

            var result = await controller.HandleIssueCommentsWebhook("", viewModel);

            pipelineRunnerService.Verify(x => x.ProcessIssue(It.Is <int>(y => y == 5)), Times.Never());
            Assert.IsType <OkResult>(result);
        }