/// <summary> /// Constructor /// Creates subscriptions to the BenchmarkSystem EventHandlers /// </summary> /// <param name="benchmark">The Benchmark containing this Logger</param> /// <param name="dao">The DAO used to save log information.</param> public Logger(Benchmark benchmark, ITM_DAO dao) { Contract.Requires(benchmark != null); Contract.Requires(dao != null); _tmDAO = dao; benchmark.JobSubmitted += OnJobSubmitted; benchmark.JobCancelled += OnJobCancelled; benchmark.JobRunning += OnJobRunning; benchmark.JobTerminated += OnJobTerminated; benchmark.JobFailed += OnJobFailed; benchmark.JobDone += OnJobDone; }
public void LoadBenchmarkSystem() { _b = new Benchmark(); }
public void Test_GetJobsFromUserInPeriodOrdered() { Benchmark b = new Benchmark(); 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); }