Ejemplo n.º 1
0
        /// <summary>
        /// Schedules a job that is guaranteed to be executed.
        /// </summary>
        private void PrepareJobForExecution(BeingExecuteDelegate beginExecute,
                                            EndExecuteDelegate endExecute)
        {
            JobDetails jobDetails = new JobDetails(dummyJobSpec, DateTime.UtcNow);

            jobDetails.JobState = JobState.Pending;

            PrepareMockJobWatcher(jobDetails);

            Expect.Call(mockTrigger.Schedule(TriggerScheduleCondition.Latch, DateTime.MinValue, null))
            .Constraints(Rhino.Mocks.Constraints.Is.Equal(TriggerScheduleCondition.Latch), Rhino.Mocks.Constraints.Is.Anything(), Rhino.Mocks.Constraints.Is.Null())
            .Return(TriggerScheduleAction.ExecuteJob);
            Expect.Call(mockTrigger.NextFireTimeUtc).Return(null);
            Expect.Call(mockTrigger.NextMisfireThreshold).Return(null);

            mockJobStore.SaveJobDetails(jobDetails);
            LastCall.Do((SaveJobDetailsDelegate) delegate
            {
                Assert.AreEqual(JobState.Running, jobDetails.JobState);
                Assert.IsNotNull(jobDetails.LastJobExecutionDetails);
                Assert.AreEqual(scheduler.Guid, jobDetails.LastJobExecutionDetails.SchedulerGuid);
                Assert.GreaterOrEqual(jobDetails.LastJobExecutionDetails.StartTimeUtc, jobDetails.CreationTimeUtc);
                Assert.IsNull(jobDetails.LastJobExecutionDetails.EndTimeUtc);
                Assert.IsFalse(jobDetails.LastJobExecutionDetails.Succeeded);
            });

            Expect.Call(mockJobRunner.BeginExecute(null, null, null))
            .IgnoreArguments().Repeat.Any().Do(beginExecute);
            Expect.Call(mockJobRunner.EndExecute(null))
            .IgnoreArguments().Repeat.Any().Do(endExecute);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Schedules a job that is guaranteed to be executed.
        /// </summary>
        private void PrepareJobForExecution(BeingExecuteDelegate beginExecute,
            EndExecuteDelegate endExecute)
        {
            JobDetails jobDetails = new JobDetails(dummyJobSpec, DateTime.UtcNow);
            jobDetails.JobState = JobState.Pending;

            PrepareMockJobWatcher(jobDetails);

            Expect.Call(mockTrigger.Schedule(TriggerScheduleCondition.Latch, DateTime.MinValue, null))
                .Constraints(Rhino.Mocks.Constraints.Is.Equal(TriggerScheduleCondition.Latch), Rhino.Mocks.Constraints.Is.Anything(), Rhino.Mocks.Constraints.Is.Null())
                .Return(TriggerScheduleAction.ExecuteJob);
            Expect.Call(mockTrigger.NextFireTimeUtc).Return(null);
            Expect.Call(mockTrigger.NextMisfireThreshold).Return(null);

            mockJobStore.SaveJobDetails(jobDetails);
            LastCall.Do((SaveJobDetailsDelegate) delegate
            {
                Assert.AreEqual(JobState.Running, jobDetails.JobState);
                Assert.IsNotNull(jobDetails.LastJobExecutionDetails);
                Assert.AreEqual(scheduler.Guid, jobDetails.LastJobExecutionDetails.SchedulerGuid);
                Assert.GreaterOrEqual(jobDetails.LastJobExecutionDetails.StartTimeUtc, jobDetails.CreationTimeUtc);
                Assert.IsNull(jobDetails.LastJobExecutionDetails.EndTimeUtc);
                Assert.IsFalse(jobDetails.LastJobExecutionDetails.Succeeded);
            });

            Expect.Call(mockJobRunner.BeginExecute(null, null, null))
                .IgnoreArguments().Repeat.Any().Do(beginExecute);
            Expect.Call(mockJobRunner.EndExecute(null))
                .IgnoreArguments().Repeat.Any().Do(endExecute);
        }