Exemplo n.º 1
0
        public void ShouldBeAbleToRunJobWithSpecifiedStepNumber()
        {
            string name = MethodBase.GetCurrentMethod().Name;

            TestWorker.ValueToCheck     = false;
            StepTestWorker.ValueToCheck = false;
            JobConductorService jc = GetTestJobConductor(name);
            string jobName         = "Job_" + name;

            jc.AddWorker(typeof(TestWorker).AssemblyQualifiedName, "TestWorker", jobName);
            jc.AddWorker(typeof(StepTestWorker).AssemblyQualifiedName, "StepTestWorker", jobName);

            Expect.IsFalse(TestWorker.ValueToCheck);
            Expect.IsFalse(StepTestWorker.ValueToCheck);
            bool?          finished = false;
            AutoResetEvent signal   = new AutoResetEvent(false);

            jc.JobFinished += (o, a) =>
            {
                Expect.IsFalse(TestWorker.ValueToCheck, "testworker value should have been false after job finished");
                Expect.IsTrue(StepTestWorker.ValueToCheck, "Step test worker value should have been true after job finished");
                finished = true;
                signal.Set();
            };

            JobConf conf = jc.GetJob(jobName);

            jc.RunJob(conf.CreateJob(), 1);
            signal.WaitOne(10000);
            Expect.IsTrue(finished.Value, "finished value should have been set");
        }