コード例 #1
0
        public void JobShouldRunIfRunnerThreadIsRunning()
        {
            string            name = MethodBase.GetCurrentMethod().Name;
            JobManagerService jc   = GetTestJobConductor(name);

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

            JobConf conf = jc.CreateJob(name);

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

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

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

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

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