Ejemplo n.º 1
0
        public void Start()
        {
            using (var manager = new JobManager())
            {
                var mockJob = new Mocks.MockHourlyJob();
                manager.Initialize();
                manager.LoadJobInstance(mockJob);
                Assert.True(manager.JobIsLoaded("MockHourly"));

                manager.Start();                 //should kick off this job ...
                Assert.Equal(JobManager.State.Running, manager.RunningState);

                var nextRunTime = manager.GetNextRunTime("MockHourly");
                Assert.NotNull(nextRunTime);
                Assert.True((nextRunTime.Value - DateTime.UtcNow).TotalMinutes > 59.0);
            }
        }
Ejemplo n.º 2
0
        public void RunJob()
        {
            using (var manager = new JobManager())
            {
                var did_run = false;
                var mockJob = new Mocks.MockHourlyJob((token) =>
                {
                    did_run = true;
                });
                manager.Initialize();
                manager.LoadJobInstance(mockJob);
                Assert.True(manager.JobIsLoaded("MockHourly"));
                manager.RunJob("MockHourly");

                var elapsed = Utility.Threading.BlockUntil(() => did_run, 500);
                Assert.True(elapsed < 500);
                Assert.True(did_run);
            }
        }