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