Exemple #1
0
        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");
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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));
        }
Exemple #4
0
        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));
        }
Exemple #5
0
        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);
        }