Exemplo n.º 1
0
        public void WhenJobIsScheduledAndNotExecuting_GetJobStatus_ReturnsIdle()
        {
            // Arrange.
            const string processName = "TestProcess";
            var syncGuid = Guid.Parse("DF1F8724-297C-45AE-8E70-B924FD375620");
            var jobName = syncGuid.ToString();

            var jobDetail = new JobDetail(jobName, QuartzScheduler.QuartzGroupName, typeof(SyncProcessWorker));

            var trigger = Mock.Create<Trigger>(Behavior.CallOriginal);
            Mock.Arrange(() => trigger.Group).Returns(QuartzScheduler.QuartzGroupName);

            var scheduler = Mock.Create<IScheduler>(Behavior.CallOriginal);
            Mock.Arrange(() => scheduler.GetJobDetail(jobName, QuartzScheduler.QuartzGroupName)).Returns(jobDetail);
            Mock.Arrange(() => scheduler.GetCurrentlyExecutingJobs()).Returns(new List<JobExecutionContext>());
            Mock.Arrange(() => scheduler.GetTriggersOfJob(jobName, QuartzScheduler.QuartzGroupName)).Returns(new[] { trigger });

            var logger = Mock.Create<ILogger>(Behavior.CallOriginal);
            var target = new DummyQuartzScheduler { Logger = logger };
            target.SetScheduler(scheduler);

            // Act.
            var result = target.GetJobStatus(processName, syncGuid);

            // Assert.
            Assert.AreEqual(ESyncJobStatus.Idle, result);
            Mock.Assert(() => logger.Log(LogSeverity.Error, Arg.IsAny<string>(), Arg.IsAny<Exception>()), Occurs.Never());
        }
Exemplo n.º 2
0
        public void WhenJobIsNotFound_GetJobStatus_ReturnsNotPublished()
        {
            // Arrange.
            const string processName = "TestProcess";
            var syncGuid = Guid.Parse("DF1F8724-297C-45AE-8E70-B924FD375620");
            var jobName = syncGuid.ToString();

            var scheduler = Mock.Create<IScheduler>(Behavior.CallOriginal);
            Mock.Arrange(() => scheduler.GetJobDetail(jobName, QuartzScheduler.QuartzGroupName)).Returns(null as JobDetail);

            var logger = Mock.Create<ILogger>(Behavior.CallOriginal);
            var target = new DummyQuartzScheduler { Logger = logger };
            target.SetScheduler(scheduler);

            // Act.
            var result = target.GetJobStatus(processName, syncGuid);

            // Assert.
            Assert.AreEqual(ESyncJobStatus.NotPublished, result);
            Mock.Assert(() => logger.Log(LogSeverity.Error, Arg.IsAny<string>(), Arg.IsAny<Exception>()), Occurs.Never());
        }