Example #1
0
        public void Test_AddJob()
        {
            BenchmarkSystem.Scheduler s = new BenchmarkSystem.Scheduler();

            // Add legal jobs with the three types: SHORT, LONG, VERY_LONG
            Job shortJob = new Job(new Owner("test"), 25);
            Job longJob = new Job(new Owner("test"), 115);
            Job veryLongJob = new Job(new Owner("test"), 500);

            s.AddJob(shortJob);
            s.AddJob(longJob);
            s.AddJob(veryLongJob);

            Assert.AreEqual(3, s.JobsInSequence.Count);

            // Add 5000 jobs of varying type
            for (uint i = 0; i < 5000; i++)
            {
                s.AddJob(new Job(new Owner("test"), i));
            }

            Assert.AreEqual(5003, s.JobsInSequence.Count);
        }
Example #2
0
        public void Test_RemoveJob()
        {
            BenchmarkSystem.Scheduler s = new BenchmarkSystem.Scheduler();
            Job job = new Job(new Owner("test"), 20);
            s.AddJob(job);

            // Try to remove null
            try
            {
                s.RemoveJob(null);
                Assert.Fail("It was possible to remove a \"null\" job");
            }
            catch (ArgumentNullException)
            {
                // This is good
            }

            // Try to remove job not in scheduler
            Job phonyJob = new Job(new Owner("test"), 50);
            try
            {
                s.RemoveJob(phonyJob);
                Assert.Fail("It was possible to remove a job not in the scheduler");
            }
            catch (ArgumentException)
            {
                // This is good
            }

            // Remove a job in the scheduler
            s.RemoveJob(job);
            Assert.AreEqual(0, s.JobsInSequence.Count);
        }