public void TotalNumberOfJobsTest() { BenchmarkSystem target = BenchmarkSystem.instance; // Empty queues target.ExecuteAll(); // Add jobs and assert uint max = 10; Job[] jobs = new Job[max]; Assert.AreEqual((uint)0, target.TotalNumberOfJobs()); for (uint i = 1; i <= max; i++) { Job job = new Job("TotalNumberOfJobs test " + i, null, 1, i); jobs[i - 1] = job; target.Submit(job); Assert.AreEqual(i, target.TotalNumberOfJobs()); } // Remove jobs and assert for (uint i = max - 1; i > 0; i--) { target.Remove(jobs[i]); Assert.AreEqual(i, target.TotalNumberOfJobs()); } }
public void RemoveTest() { BenchmarkSystem target = BenchmarkSystem.instance; Job job = new Job("Remove test 1", owner, 3, 767); Job job2 = new Job("Remove test 2", owner, 4, 2); target.Submit(job); target.Submit(job2); target.Remove(job); Assert.IsTrue(!target.Contains(job)); }
public void RemovedTest() { BenchmarkSystem target = BenchmarkSystem.instance; target.JobRemoved += new EventHandler <JobEventArgs>(EventCalled); Job job = new Job("Removed test", null, 1, 1); target.Submit(job); EventCalledBool = false; target.Remove(job); System.Threading.Thread.Sleep(1000); Assert.IsTrue(EventCalledBool); Assert.AreEqual(JobEventArgs.EventType.JobRemoved, eventType); EventCalledBool = false; target.JobRemoved -= new EventHandler <JobEventArgs>(EventCalled); }
public void ContainsTest() { BenchmarkSystem target = BenchmarkSystem.instance; // Add jobs and assert uint max = 10; Job[] jobs = new Job[max]; for (uint i = 1; i <= max; i++) { Job job = new Job("Contains test " + i, null, 1, i); jobs[i - 1] = job; target.Submit(job); Assert.IsTrue(target.Contains(job)); } // Remove jobs and assert for (uint i = max - 1; i > 0; i--) { target.Remove(jobs[i]); Assert.IsFalse(target.Contains(jobs[i])); } }