Ejemplo n.º 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");
            }
        }
Ejemplo n.º 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");
        }
Ejemplo n.º 3
0
 public static void InitComponents()
 {
     ScheduleInstance = Bootstrap.Container.Resolve <SchedulerInstance>();
     ScheduleInstance.Start(Bootstrap.Container);
     log.Debug("Components initialized");
 }