Пример #1
0
        public void RunSchedulerTaskTest()
        {
            var repo = Container.Resolve <ScheduleRepository>();

            repo.DeleteAll(repo.GetAll());

            bool isFinished             = false;
            SchedulerInstance scheduler = SchedulerInstance.Instance;

            if (SchedulerInstance.Instance == null)
            {
                scheduler = Container.Resolve <SchedulerInstance>();
            }
            scheduler.TaskFinished += (t) =>
            {
                isFinished = true;
            };
            Container.Resolve <SchedulerServiceTracker>().Start();
            scheduler.Start(Container);
            scheduler.Schedule("sleep-5000");

            var cnt = 20;

            while (!isFinished && cnt-- >= 0)
            {
                Thread.Sleep(500);
            }
            scheduler.Stop();
            scheduler.Destroy();
            if (cnt == 0)
            {
                Assert.Fail("Service didn't finish in reasonable amount of time");
            }
        }
Пример #2
0
        public void SchedulerCustomEventTest()
        {
            var repo = Container.Resolve <ScheduleRepository>();

            repo.DeleteAll(repo.GetAll());

            bool isFinished             = false;
            bool isFired                = false;
            SchedulerInstance scheduler = SchedulerInstance.Instance;

            if (scheduler == null)
            {
                scheduler = Container.Resolve <SchedulerInstance>();
            }
            scheduler.TaskFinished += (t) =>
            {
                isFinished = true;
            };
            scheduler.ScriptCustomEvent += (t, s, i) =>
            {
                isFired = true;
            };
            Container.Resolve <SchedulerServiceTracker>().Start();
            scheduler.Start(Container);
            scheduler.Schedule("cusomEvent-fire");

            var cnt = 20;

            while (!isFinished && cnt-- >= 0)
            {
                Thread.Sleep(500);
            }
            scheduler.Stop();
            scheduler.Destroy();
            if (cnt == 0)
            {
                Assert.Fail("Service didn't finish in reasonable amount of time");
            }
            Assert.IsTrue(isFired, "Event has not been fired");
        }
Пример #3
0
        public SchedulerServiceTracker(SchedulerInstance schedulerInstance, IComponentContext context)
        {
            _schedulerInstance = schedulerInstance;
            _context = context;

        }
Пример #4
0
 public static void InitComponents()
 {
     ScheduleInstance = Bootstrap.Container.Resolve <SchedulerInstance>();
     ScheduleInstance.Start(Bootstrap.Container);
     log.Debug("Components initialized");
 }