Exemplo n.º 1
0
 public void Test_CompareToPositive()
 {
     Job job1 = new Job(new User("Test", ""), 100, 1, s => 0);
     Job job2 = new Job(new User("Test", ""), 100, 2, s => 0);
     job1.Process(new String[] { " not empty" });
     Assert.AreEqual(1, job1.CompareTo(job2));
 }
Exemplo n.º 2
0
        public void Test_AddJob()
        {
            User user = new User("Test User", "Test Password");
            _tmDAO.AddUser(user);
            Job job = new Job(user, 100, 5, s => 50);

            _tmDAO.AddJob(job);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Add a job to the database
        /// </summary>
        /// <param name="job">The job to add</param>
        public void AddJob(Job job)
        {
            Contract.Requires(job != null);

            if (job.UserId == 0)
            {
                AddUser(job.User);
            }
            else
            {
                _dbContext.Jobs.AddObject(job);
                _dbContext.SaveChanges();
            }
        }
Exemplo n.º 4
0
 public void EventHandlerRunningTest()
 {
     Job job = new Job(new User("test", ""), 1, 1, s => 0);
     _b.JobCancelled += delegate { throw new Exception(); };
     _b.SubmitJob(job);
     try
     {
         _b.ExecuteAll();
         Assert.Fail();
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// The main method...
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            ITM_DAO tm2sqlDAO = new TM2SQL_DAO();
            //NB Modified TaskManagerModelContainer.Designer.cs linie 40!!

            //var obs = new ObjectContext(@"metadata=res://*/TaskManagerModel.csdl|res://*/TaskManagerModel.ssdl|res://*/TaskManagerModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source='YNDAL-LAPTOP\SQLEXPRESS';initial catalog=TaskManagerDB;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot");

            //Console.WriteLine("First step done");

            //IEnumerable<User> users = TM2SQL_DAO.GetAllUsers();

            //Console.Out.WriteLine("Size: " + users.Count<User>());

            //foreach (User u in users)
            //{
            //    Console.Out.WriteLine(u.UserName);
            //}

            //TM2SQL_DAO.GetJobsFromUser(4);

            //TM2SQL_DAO.GetJobsFromPeriodGrouped(new DateTime(2012, 1, 1), new DateTime(2012, 12, 31));
                //.GetJobsFromUser(5);

            User user = new User("Endnu en.WIHhhU..!", "...");
            tm2sqlDAO.AddUser(user);

            //IEnumerable<User> users = TM2SQL_DAO.GetAllUsers();

            Job job = new Job(user, 50, 5, s => 50);
            //job.TimeSubmitted = DateTime.Now;

            tm2sqlDAO.AddJob(job);
            tm2sqlDAO.AddLog(job, DateTime.Now);

            IEnumerable<User> users = tm2sqlDAO.GetAllUsers();
            IEnumerable<Job> jobs = tm2sqlDAO.GetJobsFromUser(user.UserId);

            foreach (User u in users)
            {
                Console.WriteLine("User: "******"Jobs: " + j);
            }

            //ConsoleUI console = new ConsoleUI();
        }
Exemplo n.º 6
0
        public void CancelJobTest()
        {
            User user = new User("Wing 3714 - The ladies man", "");
            Job job = new Job(user, 5, 1, s => 0);
            _b.SubmitJob(job);

            //If job does anything else than runs or cancels...
            job.JobDone += delegate { Assert.Fail();};
            job.JobFailed += delegate { Assert.Fail(); };
            job.JobTerminated += delegate { Assert.Fail(); };

            _b.CancelJob(job);

            Assert.AreEqual(JobState.Cancelled, job.State);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Add a log to the database
        /// </summary>
        /// <param name="job">The job affecting the log</param>
        /// <param name="time">The timestamp for the log</param>
        public void AddLog(Job job, DateTime time)
        {
            Contract.Requires(job != null);
            Contract.Requires(job.User != null);
            Contract.Requires(job.JobId != 0);

            Log log = new Log();

            log.Event = job.StateString;
            log.Time = time;
            log.JobId = job.JobId;

            _dbContext.Logs.AddObject(log);
            _dbContext.SaveChanges();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Adds a job to the scheduler
        /// </summary>
        /// <param name="job">The job to add to the scheduler</param>
        /// <exception cref="ArgumentNullException">If parameter is null</exception>
        public void AddJob(Job job)
        {
            Contract.Requires(job != null);

            lock (sequenceLock)
            {
                _jobSequence.Add(job);
            }
            lock (depletedLock)
            {
                _listByJobtype[job.Type].Add(job);
            }

            Subscribe(job);
        }
Exemplo n.º 9
0
        public void Test_AddJob()
        {
            Scheduler s = new Scheduler();

            // Add legal jobs with the three types: SHORT, LONG, VERY_LONG
            Func<string[], int> funk = st => 10;
            Job shortJob = new Job(new User("test", ""), 25, 5, funk);
            Job longJob = new Job(new User("test", ""), 115, 5, funk);
            Job veryLongJob = new Job(new User("test", ""), 500, 5, funk);

            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 User("test", ""), i, 5, funk));
            }

            Assert.AreEqual(5003, s.JobsInSequence.Count);
        }
Exemplo n.º 10
0
 public void Test_CompareToTransitive()
 {
     Job job1 = new Job(new User("Test", ""), 100, 1, s => 0);
     Job job2 = new Job(new User("Test", ""), 100, 2, s => 0);
     Job job3 = new Job(new User("Test", ""), 100, 3, s => 0);
     Assert.AreEqual(0, job1.CompareTo(job2));
     Assert.AreEqual(0, job2.CompareTo(job3));
     Assert.AreEqual(0, job1.CompareTo(job3));
 }
Exemplo n.º 11
0
        public void Test_GetJobsFromUser()
        {
            User user = new User("Test User", "Test Password");
            _tmDAO.AddUser(user);
            Job job = new Job(user, 100, 5, s => 50);
            _tmDAO.AddJob(job);

            IEnumerable<Job> jobs = _tmDAO.GetJobsFromUser(user.UserId);
            Assert.AreEqual(1, jobs.Count());
        }
Exemplo n.º 12
0
 public void SubmitJobTest()
 {
     Job job = new Job(new User("test", ""), 30, 1, s => 0);
     _b.SubmitJob(job);
     List<Job> list = _b.GetJobs(job.User);
     Assert.IsTrue(list.Contains(job));
 }
Exemplo n.º 13
0
 public void Test_CompareZero()
 {
     Job job1 = new Job(new User("Test", ""), 100, 1, s => 0);
     Job job2 = new Job(new User("Test", ""), 100, 2, s => 0);
     Assert.AreEqual(0, job1.Compare(job2, job1));
 }
Exemplo n.º 14
0
 public void GetJobsTest()
 {
     User owner = new User("Arnold", "");
     Job job = new Job(owner, 56, 1, s => 0);
     _b.SubmitJob(job);
     _b.ExecuteAll();
     List<Job> jobs = _b.GetJobs(owner);
     if (!jobs.Contains(job)) Assert.Fail();
 }
Exemplo n.º 15
0
        public void StoreJobTest()
        {
            int expectedTime = 1; //Minutes
            User owner = new User("Undercover Brother", "");
            Job job = new Job(owner, (uint)expectedTime, 1, s => 0);
            _b.SubmitJob(job);

            List<Job> jobs = _b.GetJobs(owner);

            if(!jobs.Contains(job)) Assert.Fail("The job was not stored!");
        }
Exemplo n.º 16
0
        public void ExecuteAllTest()
        {
            //Also tests StartNextJob()
            uint numbOfJobs = 100;

            Job job;
            User owner = new User("TestOwner", "");
            for (uint index = 0; index < numbOfJobs; index++)
            {
                job = new Job(owner, index, 1, s => 0);
                _b.SubmitJob(job);
            }

            List<Job> jobs = _b.GetJobs(owner);

            uint counterDone = 0;
            uint counterUndone = 0;

            foreach (Job j in jobs)
                if (JobState.Done == j.State)
                    counterUndone++;
                    else
                    counterDone++;

            //No jobs should be done
            Assert.AreEqual((uint)0, counterDone);
            Assert.AreEqual(numbOfJobs, counterUndone);

            _b.ExecuteAll();

            counterDone = 0;
            counterUndone = 0;

            foreach (Job j in jobs)
                if (j.State == JobState.Done)
                    counterUndone++;
                else
                    counterDone++;

            Assert.AreEqual(counterDone, numbOfJobs);
            Assert.AreEqual(counterUndone, (uint)0);
        }
Exemplo n.º 17
0
        public void FinishCurrentJobsTest()
        {
            uint numberOfJobs = 5;
            List<Job> jobs = new List<Job>((int)numberOfJobs);

            uint counter = 0;
            Job job;
            for (int index = 0; index < numberOfJobs; index++)
            {
                job = new Job(new User("test", ""), 1, 1, s => 0) { Description = "Job " + index };
                job.JobDone += delegate { counter++; };
                jobs.Add(job);
                _b.SubmitJob(job);

            }

            _b.JobDone += delegate
            {
                if (counter == numberOfJobs)
                    Assert.AreEqual(BSStatus.Stopped, _b.Status);
            };
            _b.ExecuteAll();
            _b.FinishCurrentJobs();
        }
 public void CancelJobThrowsContractException142()
 {
     try
     {
       Owner owner;
       Dictionary<Owner, List<Job>> dictionary;
       List<Job> list;
       Dictionary<JobType, List<Job>> dictionary1_;
       Dictionary<JobType, uint> dictionary2_;
       BenchmarkSystem.Scheduler scheduler;
       SBenchmarkSystem sBenchmarkSystem;
       Logger logger;
       BenchmarkSystem benchmarkSystem;
       owner = PexInvariant.CreateInstance<Owner>();
       PexInvariant.SetField<string>((object)owner, "<Name>k__BackingField", "\0");
       PexInvariant.CheckInvariant((object)owner);
       dictionary = new Dictionary<Owner, List<Job>>(0);
       dictionary[owner] = (List<Job>)null;
       Job[] jobs = new Job[0];
       list = new List<Job>((IEnumerable<Job>)jobs);
       dictionary1_ = new Dictionary<JobType, List<Job>>(4);
       dictionary1_[JobType.SHORT] = (List<Job>)null;
       dictionary2_ = new Dictionary<JobType, uint>(1);
       dictionary2_[JobType.SHORT] = 0u;
       scheduler = PexInvariant.CreateInstance<BenchmarkSystem.Scheduler>();
       PexInvariant.SetField<uint>((object)scheduler, "_shortJobsRunning", 0u);
       PexInvariant.SetField<uint>((object)scheduler, "_longJobsRunning", 0u);
       PexInvariant.SetField<uint>((object)scheduler, "_veryLongJobsRunning", 0u);
       PexInvariant.SetField<List<Job>>((object)scheduler, "_shortList", list);
       PexInvariant.SetField<List<Job>>((object)scheduler, "_longList", list);
       PexInvariant.SetField<List<Job>>((object)scheduler, "_veryLongList", list);
       PexInvariant.SetField<List<Job>>((object)scheduler, "_jobSequence", list);
       PexInvariant.SetField<Dictionary<JobType, List<Job>>>
       ((object)scheduler, "_listByJobtype", dictionary1_);
       PexInvariant.SetField<Dictionary<JobType, uint>>
       ((object)scheduler, "_counterByJobtype", dictionary2_);
       PexInvariant.SetField<EventHandler>
       ((object)scheduler, "JobDone", (EventHandler)null);
       PexInvariant.SetField<EventHandler>
       ((object)scheduler, "JobFailed", (EventHandler)null);
       PexInvariant.SetField<EventHandler>
       ((object)scheduler, "JobTerminated", (EventHandler)null);
       PexInvariant.CheckInvariant((object)scheduler);
       sBenchmarkSystem = new SBenchmarkSystem();
       logger = new Logger((BenchmarkSystem)sBenchmarkSystem);
       benchmarkSystem = PexInvariant.CreateInstance<BenchmarkSystem>();
       PexInvariant.SetField<BenchmarkSystem.Scheduler>
       ((object)benchmarkSystem, "_scheduler", scheduler);
       PexInvariant.SetField<Logger>((object)benchmarkSystem, "_logger", logger);
       PexInvariant.SetField<EventHandler>
       ((object)benchmarkSystem, "JobSubmitted", (EventHandler)null);
       PexInvariant.SetField<EventHandler>
       ((object)benchmarkSystem, "JobCancelled", (EventHandler)null);
       PexInvariant.SetField<EventHandler>
       ((object)benchmarkSystem, "JobRunning", (EventHandler)null);
       PexInvariant.SetField<EventHandler>
       ((object)benchmarkSystem, "JobTerminated", (EventHandler)null);
       PexInvariant.SetField<EventHandler>
       ((object)benchmarkSystem, "JobFailed", (EventHandler)null);
       PexInvariant.SetField<EventHandler>
       ((object)benchmarkSystem, "JobDone", (EventHandler)null);
       PexInvariant.SetField<List<Job>>((object)benchmarkSystem, "_threads", list);
       PexInvariant.SetField<Dictionary<Owner, List<Job>>>
       ((object)benchmarkSystem, "_jobs", dictionary);
       PexInvariant.SetField<bool>((object)benchmarkSystem, "_isFinishing", false);
       PexInvariant.SetField<BSStatus>
       ((object)benchmarkSystem, "<Status>k__BackingField", BSStatus.Ready);
       PexInvariant.CheckInvariant((object)benchmarkSystem);
       this.CancelJob(benchmarkSystem, (Job)null);
       throw
     new AssertFailedException("expected an exception of type ContractException");
     }
     catch(Exception ex)
     {
       if (!PexContract.IsContractException(ex))
     throw ex;
     }
 }
Exemplo n.º 19
0
 public void Test_ProcessEmptyArgs()
 {
     Job job = new Job(new User("Test", ""), 100, 1, s => 0);
     job.Process(new String[] { });
 }
Exemplo n.º 20
0
 public void Test_ProcessNullArgs()
 {
     Job job = new Job(new User("Test", ""), 100, 1, s => 0);
     try
     {
         job.Process(null);
     }
     catch
     {
         // This is good
     }
 }
Exemplo n.º 21
0
        public void Test_GetJobsFromUserInPeriodOrdered()
        {
            BenchmarkSystem b = new BenchmarkSystem();
            DateTime startTime = new DateTime(2020, 1, 1);
            DateTime endTime = new DateTime(2020, 12, 31);
            User user = new User("Test User", "A secret password");

            _tmDAO.AddUser(user);
            int jobQuantity = 30;
            Job job = null;
            for (int index = 1; index <= jobQuantity; index++)
            {
                DateTime t1 = new DateTime(2020, 3, index);

                job = new Job(user, 100, 5, s => 38);
                _tmDAO.AddJob(job);
                _tmDAO.AddLog(job, t1);
                if (index % 2 == 0)
                {
                    job.Process(new String[] { "test" });
                    _tmDAO.AddLog(job, t1.AddHours(1));
                }
            }
            List<Job> jobsRequested = new List<Job>(_tmDAO.GetJobsFromUserInPeriodOrdered(user.UserId, startTime, endTime));

            for (int i = 0; i < jobsRequested.Count - 1; i++)
            {
                if (jobsRequested[i].CompareTo(jobsRequested[i + 1]) == 1)
                {
                    Assert.Fail("The order is no correct. JobId: " + jobsRequested[i] + " was larger than JobId: " + jobsRequested[i + 1]);
                }
            }

            Assert.AreEqual(jobQuantity, jobsRequested.Count);
        }
Exemplo n.º 22
0
        public void Test_PopJobSequence()
        {
            Scheduler s = new Scheduler();
            Func<string[], int> funk = st => 10;

            // Check the sequence og jobs returned
            Job shortJob = new Job(new User("test", ""), 25, 5, funk);
            Job longJob = new Job(new User("test", ""), 115, 5, funk);
            Job veryLongJob = new Job(new User("test", ""), 500, 5, funk);

            // short, long, verylong
            AssertSequence(s, shortJob, longJob, veryLongJob);
            // long, short, verylong
            AssertSequence(s, longJob, shortJob, veryLongJob);
            // long, verylong, short
            AssertSequence(s, longJob, veryLongJob, shortJob);
            // short, verylong, long
            AssertSequence(s, shortJob, veryLongJob, longJob);
            // verylong, short, long
            AssertSequence(s, veryLongJob, shortJob, longJob);
            // verylong, long, short
            AssertSequence(s, veryLongJob, longJob, shortJob);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Lets the user add a new job to the system
        /// </summary>
        private void AddNewJob()
        {
            int CPUs = 0;
            string description;
            int expectedRuntime;
            System.Console.WriteLine("To add a new job - please fill in:");
            System.Console.Write("1: A short description: ");
            description = System.Console.ReadLine();

            bool validInputTime = false;
            do
            {
                System.Console.Write("2: Expected runtime in minutes: ");
                validInputTime = Int32.TryParse(System.Console.ReadLine(), out expectedRuntime);

                if (!validInputTime)
                    System.Console.WriteLine("Invalid input - must be a digit above 0.\n");
            } while (!validInputTime);

            bool validInputCPUs = false;
            do
            {
                System.Console.Write("3: CPUs to use (1-6): ");
                validInputCPUs = Int32.TryParse(System.Console.ReadLine(), out CPUs);
                if (1 > CPUs || CPUs > 6) validInputCPUs = false;

                if (!validInputCPUs)
                    System.Console.WriteLine("Invalid input - Must be a digit from 1 to 6.\n");
            } while (!validInputCPUs);
            System.Console.WriteLine();

            Func<string[], int> test = s => { return 78;};

            Job job = new Job(_user, (uint)expectedRuntime, CPUs, test);

            _benchmark.SubmitJob(job);

            System.Console.WriteLine("The job has been submitted");
        }
Exemplo n.º 24
0
 public void Test_CompareToSymmetric()
 {
     Job job1 = new Job(new User("Test", ""), 100, 1, s => 0);
     Job job2 = new Job(new User("Test", ""), 100, 2, s => 0);
     Assert.AreEqual(0, job1.CompareTo(job2));
     Assert.AreEqual(0, job2.CompareTo(job1));
 }
Exemplo n.º 25
0
        public void Test_GetJobsFromUserWithinDays()
        {
            User user = new User("Test User", "Test Password");
            _tmDAO.AddUser(user);

            // Create 10 jobs on different days
            Job job = null;
            List<TimeSpan> timespans = new List<TimeSpan>();
            for (int i = 0; i < 10; i++)
            {
                timespans.Add(new TimeSpan(i, 0, 0, 0));
                job = new Job(user, 100, 5, s => 50);
                job.TimeSubmitted = DateTime.Now.Subtract(timespans[i]);

                _tmDAO.AddJob(job);
                _tmDAO.AddLog(job, DateTime.Now.Subtract(timespans[i]));
            }

            foreach (TimeSpan timespan in timespans)
            {
                IEnumerable<Job> jobs = _tmDAO.GetJobsFromUserInPeriod(user.UserId, DateTime.Now.Subtract(timespan), DateTime.Now);
                Assert.AreEqual(timespan.TotalDays, jobs.Count());
            }
        }
Exemplo n.º 26
0
        public void Test_RemoveJobInScheduler()
        {
            Scheduler s = new Scheduler();
            Func<string[], int> funk = st => 10;
            Job job = new Job(new User("test", ""), 20, 5, funk);
            s.AddJob(job);

            // Remove a job in the scheduler
            s.RemoveJob(job);
            Assert.AreEqual(0, s.JobsInSequence.Count);
        }
 public void ExecuteAll544()
 {
     Owner owner;
     Dictionary<Owner, List<Job>> dictionary;
     List<Job> list;
     Dictionary<JobType, List<Job>> dictionary1_;
     Dictionary<JobType, uint> dictionary2_;
     BenchmarkSystem.Scheduler scheduler;
     SBenchmarkSystem sBenchmarkSystem;
     Logger logger;
     BenchmarkSystem benchmarkSystem;
     owner = PexInvariant.CreateInstance<Owner>();
     PexInvariant.SetField<string>((object)owner, "<Name>k__BackingField", "\0");
     PexInvariant.CheckInvariant((object)owner);
     dictionary = new Dictionary<Owner, List<Job>>(0);
     dictionary[owner] = (List<Job>)null;
     Job[] jobs = new Job[0];
     list = new List<Job>((IEnumerable<Job>)jobs);
     dictionary1_ = new Dictionary<JobType, List<Job>>(4);
     dictionary1_[JobType.SHORT] = (List<Job>)null;
     dictionary2_ = new Dictionary<JobType, uint>(1);
     dictionary2_[JobType.SHORT] = 0u;
     scheduler = PexInvariant.CreateInstance<BenchmarkSystem.Scheduler>();
     PexInvariant.SetField<uint>((object)scheduler, "_shortJobsRunning", 0u);
     PexInvariant.SetField<uint>((object)scheduler, "_longJobsRunning", 0u);
     PexInvariant.SetField<uint>((object)scheduler, "_veryLongJobsRunning", 0u);
     PexInvariant.SetField<List<Job>>((object)scheduler, "_shortList", list);
     PexInvariant.SetField<List<Job>>((object)scheduler, "_longList", list);
     PexInvariant.SetField<List<Job>>((object)scheduler, "_veryLongList", list);
     PexInvariant.SetField<List<Job>>((object)scheduler, "_jobSequence", list);
     PexInvariant.SetField<Dictionary<JobType, List<Job>>>
     ((object)scheduler, "_listByJobtype", dictionary1_);
     PexInvariant.SetField<Dictionary<JobType, uint>>
     ((object)scheduler, "_counterByJobtype", dictionary2_);
     PexInvariant.SetField<EventHandler>
     ((object)scheduler, "JobDone", (EventHandler)null);
     PexInvariant.SetField<EventHandler>
     ((object)scheduler, "JobFailed", (EventHandler)null);
     PexInvariant.SetField<EventHandler>
     ((object)scheduler, "JobTerminated", (EventHandler)null);
     PexInvariant.CheckInvariant((object)scheduler);
     sBenchmarkSystem = new SBenchmarkSystem();
     logger = new Logger((BenchmarkSystem)sBenchmarkSystem);
     benchmarkSystem = PexInvariant.CreateInstance<BenchmarkSystem>();
     PexInvariant.SetField<BenchmarkSystem.Scheduler>
     ((object)benchmarkSystem, "_scheduler", scheduler);
     PexInvariant.SetField<Logger>((object)benchmarkSystem, "_logger", logger);
     PexInvariant.SetField<EventHandler>
     ((object)benchmarkSystem, "JobSubmitted", (EventHandler)null);
     PexInvariant.SetField<EventHandler>
     ((object)benchmarkSystem, "JobCancelled", (EventHandler)null);
     PexInvariant.SetField<EventHandler>
     ((object)benchmarkSystem, "JobRunning", (EventHandler)null);
     PexInvariant.SetField<EventHandler>
     ((object)benchmarkSystem, "JobTerminated", (EventHandler)null);
     PexInvariant.SetField<EventHandler>
     ((object)benchmarkSystem, "JobFailed", (EventHandler)null);
     PexInvariant.SetField<EventHandler>
     ((object)benchmarkSystem, "JobDone", (EventHandler)null);
     PexInvariant.SetField<List<Job>>((object)benchmarkSystem, "_threads", list);
     PexInvariant.SetField<Dictionary<Owner, List<Job>>>
     ((object)benchmarkSystem, "_jobs", dictionary);
     PexInvariant.SetField<bool>((object)benchmarkSystem, "_isFinishing", false);
     PexInvariant.SetField<BSStatus>
     ((object)benchmarkSystem, "<Status>k__BackingField", BSStatus.Ready);
     PexInvariant.CheckInvariant((object)benchmarkSystem);
     this.ExecuteAll(benchmarkSystem);
     Assert.IsNotNull((object)benchmarkSystem);
     Assert.AreEqual<BSStatus>(BSStatus.Ready, benchmarkSystem.Status);
 }
Exemplo n.º 28
0
 public void Test_RemoveJobNoTInScheduler()
 {
     Scheduler s = new Scheduler();
     Func<string[], int> funk = st => 10;
     Job phonyJob = new Job(new User("test", ""), 50, 5, funk);
     try
     {
         s.RemoveJob(phonyJob);
         Assert.Fail("It was possible to remove a job not in the scheduler");
     }
     catch (ArgumentException)
     {
         // This is good
     }
 }
Exemplo n.º 29
0
 public Job Constructor(Owner o, uint time)
 {
     Job target = new Job(o, time);
     return target;
     // TODO: add assertions to method JobTest.Constructor(Owner, UInt32)
 }
Exemplo n.º 30
0
 /// <summary>
 /// Helper method. Checks that the sequence of jobs returned is in the same order as they were added
 /// </summary>
 /// <param name="s">The scheduler</param>
 /// <param name="first">Job to add first</param>
 /// <param name="second">Job to add second</param>
 /// <param name="third">Job to add last</param>
 private void AssertSequence(Scheduler s, Job first, Job second, Job third)
 {
     s.AddJob(first);
     s.AddJob(second);
     s.AddJob(third);
     Assert.AreEqual(first, s.PopJob());
     Assert.AreEqual(second, s.PopJob());
     Assert.AreEqual(third, s.PopJob());
 }