Пример #1
0
        public void JobShouldRunIfRunnerThreadIsRunning()
        {
            string name            = MethodBase.GetCurrentMethod().Name;
            JobConductorService fm = GetTestJobConductor(name);

            fm.StopJobRunnerThread();
            fm.JobQueue.Clear();
            fm.StartJobRunnerThread();

            JobConf conf = fm.CreateJob(name);

            TestWorker.ValueToCheck = false;
            TestWorker worker = new TestWorker();

            conf.AddWorker(worker);
            Expect.IsFalse(TestWorker.ValueToCheck);

            bool?          finished = false;
            AutoResetEvent signal   = new AutoResetEvent(false);

            fm.WorkerFinished += (o, a) =>
            {
                Expect.IsTrue(TestWorker.ValueToCheck);
                finished = true;
                signal.Set();
            };

            fm.EnqueueJob(conf);
            signal.WaitOne(10000);
            Expect.IsTrue(finished == true);
        }