Exemple #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));
 }
Exemple #2
0
 public void Test_ProcessEmptyArgs()
 {
     Job job = new Job(new User("Test", ""), 100, 1, s => 0);
     job.Process(new String[] { });
 }
Exemple #3
0
 public void Test_ProcessNullArgs()
 {
     Job job = new Job(new User("Test", ""), 100, 1, s => 0);
     try
     {
         job.Process(null);
     }
     catch
     {
         // This is good
     }
 }
        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);
        }