public void CreateJobShouldThrowExceptionIfItExists() { string name = MethodBase.GetCurrentMethod().Name; JobConductorService fm = GetTestJobConductor(name); string testJobName = name + "_JobName_".RandomLetters(4); fm.CreateJob(testJobName); Expect.IsTrue(fm.JobExists(testJobName)); Expect.Throws(() => { fm.CreateJob(testJobName); }, "Should have thrown an exception but didn't"); }
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); }
public void ExistsShouldBeTrueAfterCreate() { string name = MethodBase.GetCurrentMethod().Name; JobConductorService fm = GetTestJobConductor(name); string testJobName = name + "_JobName_".RandomLetters(4); fm.CreateJob(testJobName); Expect.IsTrue(fm.JobExists(testJobName)); }
public void JobConductorShouldCreaetJobConf() { JobConductorService.Default.JobsDirectory = new DirectoryInfo(MethodBase.GetCurrentMethod().Name).FullName; JobConductorService fm = JobConductorService.Default; string name = "JobConfTest_".RandomLetters(4); JobConf conf = fm.CreateJob(name); string path = Path.Combine(fm.JobsDirectory, conf.Name, conf.Name + ".job"); Expect.IsTrue(File.Exists(path)); }
public void GetJobShouldReturnExistingJob() { string name = MethodBase.GetCurrentMethod().Name; JobConductorService orch = GetTestJobConductor(name); Expect.IsFalse(orch.JobExists(name)); JobConf conf = orch.CreateJob(name); Expect.IsTrue(orch.JobExists(name)); JobConf validate = orch.GetJobConf(name); Expect.IsNotNull(validate); Expect.AreEqual(name, validate.Name); }