public void OwnerLongTest() { int length = 100; string name = ""; for (int index = 0; index < length; index++) name += "a"; Owner owner = new Owner(name); }
public void CancelJobTest() { Owner owner = new Owner("Wing 3714 - The ladies man"); Job job = new Job(owner, 5); _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(job.State, JobState.Cancelled); }
/// <summary> /// Constructor - An owner and expected time consumption has to be pronounced /// </summary> /// <param name="o">The owner of this job</param> /// <param name="time">Expected time to complete this job</param> public Job(Owner o, uint time) { Contract.Requires(o != null); Contract.Ensures(Owner == o); Contract.Ensures(func != null); CPUs = 1; func = (string[] s) => { OnJobRunning(); try { //Made to let it wait //for (uint index = 0; index < 10000; index++) // System.Console.WriteLine("Let me count for your: " + index); } catch (Exception) { OnJobFailed(); } OnJobDone(); return 42; }; Owner = o; ExpectedRuntime = time; if (time <= 30.0) { Type = JobType.SHORT; } else if (time <= 120.0) { Type = JobType.LONG; } else { Type = JobType.VERY_LONG; } State = JobState.Waiting; }
public void OwnerShortTest() { Owner owner = new Owner("a"); }
public Owner Constructor(string name) { Owner target = new Owner(name); return target; // TODO: add assertions to method OwnerTest.Constructor(String) }
public Job Constructor(Owner o, uint time) { Job target = new Job(o, time); return target; // TODO: add assertions to method JobTest.Constructor(Owner, UInt32) }
public User(string name) { Contract.Requires(!String.IsNullOrEmpty(name)); Owner = new Owner(name); }
public void StoreJobTest() { int expectedTime = 1; //Minutes Owner owner = new Owner("Undercover Brother"); Job job = new Job(owner, (uint)expectedTime); _b.SubmitJob(job); List<Job> jobs = _b.GetJobs(owner); foreach (Job j in jobs) if (j.State != JobState.Waiting) Assert.Fail(); job.JobDone += delegate { List<Job> newJobs = _b.GetJobs(owner); foreach (Job newJ in newJobs) if (newJ.State != JobState.Done) Assert.Fail(); }; _b.ExecuteAll(); }
public void GetJobsTest() { Owner owner = new Owner("Arnold"); Job job = new Job(owner, 56); _b.SubmitJob(job); _b.ExecuteAll(); List<Job> jobs = _b.GetJobs(owner); if (!jobs.Contains(job)) Assert.Fail(); }
public void ExecuteAllTest() { //Also tests StartNextJob() uint numbOfJobs = 100; int timeToComplete = 1000; Job job; Owner owner = new Owner("TestOwner"); for (uint index = 0; index < numbOfJobs; index++) { job = new Job(owner, index); _b.SubmitJob(job); } List<Job> jobs = _b.GetJobs(owner); uint counterDone = 0; uint counterUndone = 0; foreach (Job j in jobs) if (j.State != JobState.Done) counterUndone++; else counterDone++; Assert.AreEqual(counterDone, (uint)0); Assert.AreEqual(counterUndone, numbOfJobs); _b.ExecuteAll(); System.Threading.Thread.Sleep(timeToComplete); 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); }
public List<Job> GetJobs([PexAssumeUnderTest]BenchmarkSystem target, Owner owner) { List<Job> result = target.GetJobs(owner); return result; // TODO: add assertions to method BenchmarkSystemTest.GetJobs(BenchmarkSystem, Owner) }
/// <summary> /// Get jobs that is owned by the owner /// </summary> /// <param name="owner">Owner of the jobs</param> /// <returns>The jobs that is owned by the owner</returns> public List<Job> GetJobs(Owner owner) { Contract.Requires(owner != null); return _jobs.ContainsKey(owner) ? _jobs[owner] : new List<Job>(0); }