예제 #1
0
        public async void ExecuteJob_InvokeTaskRunner()
        {
            _jobQueueService.Setup(s => s.GetJobQueue(1, 1)).ReturnsAsync(new JobDto {
                Id = 1
            });
            _jobDefinitionService.Setup(s => s.GetJobTaskDefinitions(1, 1))
            .ReturnsAsync(new List <JobTaskDefinitionDto>());

            var engine = new CatapultEngine(_engineConfig.Object, _taskRunner.Object, _healthService.Object,
                                            _jobQueueService.Object, _jobDefinitionService.Object, _projectService.Object, _jobLogWriter.Object, _logger.Object);

            await engine.ExecuteJob(new JobDto { ProjectId = 1, Code = "20180817.1" });

            _taskRunner.Verify(tr => tr.Run(1, It.Is <JobDto>(j => j.Code == "20180817.1"), It.IsAny <List <JobTaskDefinitionDto> >(), It.IsAny <string>(), It.IsAny <string>()), Times.Once);
        }
예제 #2
0
        public async void ExecuteJob_InvokeDeleteProject()
        {
            _jobQueueService.Setup(s => s.GetJobQueue(1, 1))
            .ReturnsAsync(new JobDto {
                Id = 1, IsDeletion = true, ProjectStatus = ProjectStatusFilterType.Deleting
            });
            _jobDefinitionService.Setup(s => s.GetJobTaskDefinitions(1, 1))
            .ReturnsAsync(new List <JobTaskDefinitionDto>());
            _taskRunner
            .Setup(t => t.Run(It.IsAny <int>(), It.IsAny <JobDto>(), It.IsAny <List <JobTaskDefinitionDto> >(), It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync(new Dictionary <int, TaskRunnerResult>
            {
                { 1, new TaskRunnerResult(true, "") }
            });

            var engine = new CatapultEngine(_engineConfig.Object, _taskRunner.Object, _healthService.Object,
                                            _jobQueueService.Object, _jobDefinitionService.Object, _projectService.Object, _jobLogWriter.Object, _logger.Object);

            await engine.ExecuteJob(new JobDto { ProjectId = 1, Code = "20180817.1", IsDeletion = true, ProjectStatus = ProjectStatusFilterType.Deleting });

            _projectService.Verify(p => p.DeleteProjectByEngine(1), Times.Once);
        }