Esempio 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");
        }
Esempio n. 2
0
        public void AfterAddWorkerCreateJobShouldHaveCorrectWorkers()
        {
            string name            = MethodBase.GetCurrentMethod().Name;
            JobConductorService fm = GetTestJobConductor(name);
            string jobName         = "Job_" + name;

            fm.AddWorker(typeof(TestWorker).AssemblyQualifiedName, "one", jobName);
            fm.AddWorker(typeof(TestWorker).AssemblyQualifiedName, "two", jobName);

            JobConf conf = fm.GetJob(jobName);
            Job     job  = conf.CreateJob();

            Expect.IsTrue(job.WorkerNames.Length == 2);
            Expect.IsNotNull(job["one"]);
            Expect.IsNotNull(job["two"]);
            Expect.AreEqual("one", job["one"].Name);
            Expect.AreEqual("two", job["two"].Name);
        }
Esempio n. 3
0
        public void AddWorkerShouldSetWorkerName()
        {
            string name            = MethodBase.GetCurrentMethod().Name;
            JobConductorService fm = GetTestJobConductor(name);
            string workerName      = "worker_" + name;
            string jobName         = "Job_" + name;

            fm.AddWorker(typeof(TestWorker).AssemblyQualifiedName, workerName, jobName);
            Expect.IsTrue(fm.WorkerExists(jobName, workerName));
        }
Esempio n. 4
0
        public void AddWorkerShouldCreateJob()
        {
            string name            = MethodBase.GetCurrentMethod().Name;
            JobConductorService fm = GetTestJobConductor(name);
            string jobName         = "Job_".RandomLetters(4);

            Expect.IsFalse(fm.JobExists(jobName));

            fm.AddWorker(typeof(TestWorker).AssemblyQualifiedName, "worker", jobName);

            Expect.IsTrue(fm.JobExists(jobName));
        }
Esempio n. 5
0
        public void ShouldBeAbleToAddWorker()
        {
            string name            = MethodBase.GetCurrentMethod().Name;
            JobConductorService fm = GetTestJobConductor(name);
            string jobName         = "Job_" + name;
            string workerName      = "worker_1";

            fm.AddWorker(typeof(TestWorker).AssemblyQualifiedName, workerName, jobName);

            JobConf job = fm.GetJob(jobName);

            Expect.IsTrue(job.WorkerExists(workerName));
        }
Esempio n. 6
0
        public void AddWorkerShouldThrowArgumentNullException()
        {
            string name            = MethodBase.GetCurrentMethod().Name;
            JobConductorService fm = GetTestJobConductor(name);

            Expect.Throws(() =>
            {
                fm.AddWorker("noTypeByThisNameShouldBeFound".RandomLetters(4), "work_" + name, "JobName");
            }, (ex) =>
            {
                ex.IsInstanceOfType <ArgumentNullException>("Exception wasn't the right type");
            }, "Should have thrown an exception but didn't");
        }