コード例 #1
0
        public void SchedulesAJobInsideExecutionWindowWithProperEstimatedTime()
        {
            var date1 = DateFactory.Build("2019-11-10 09:00:00");
            var date2 = DateFactory.Build("2019-11-11 12:00:00");

            var executionWindow  = new ExecutionWindow(date1, date2);
            var maxEstimatedTime = new EstimatedTimeBR("8 horas");
            var jobScheduler     = new JobScheduler(executionWindow, maxEstimatedTime);

            var estimatedTime = new EstimatedTimeBR("2 horas");
            var jobObj        = new Job(1, "Integration", Convert.ToDateTime("2019-11-10 12:00:00"), estimatedTime);

            jobScheduler.Schedule(jobObj);

            var jobSchedulerArray      = jobScheduler.ToArray();
            var expectedSchedulerArray = new int[1][];

            expectedSchedulerArray[0]    = new int[1];
            expectedSchedulerArray[0][0] = 1;

            var queue = new Queue <Job>();

            queue.Enqueue(jobObj);
            var expectedQueues = new List <Queue <Job> >
            {
                queue
            };

            Assert.IsNotEmpty(jobSchedulerArray);
            Assert.AreEqual(expectedSchedulerArray, jobSchedulerArray);
            Assert.AreEqual(expectedQueues, jobScheduler.GetQueues());
        }
コード例 #2
0
        public void SchedulesFiveJobsInsideExecutionWindowWithProperEstimatedTime()
        {
            var date1 = DateFactory.Build("2019-11-10 09:00:00");
            var date2 = DateFactory.Build("2019-11-11 12:00:00");

            var executionWindow  = new ExecutionWindow(date1, date2);
            var maxEstimatedTime = new EstimatedTimeBR("8 horas");
            var jobScheduler     = new JobScheduler(executionWindow, maxEstimatedTime);

            var estimatedTime = new EstimatedTimeBR("2 horas");
            var jobObj        = new Job(1, "Integration", Convert.ToDateTime("2019-11-10 12:00:00"), estimatedTime);

            jobScheduler.Schedule(jobObj);
            var jobObj2 = new Job(2, "Integration2", Convert.ToDateTime("2019-11-11 12:00:00"), estimatedTime);

            jobScheduler.Schedule(jobObj2);
            var jobObj3 = new Job(3, "Integration3", Convert.ToDateTime("2019-11-11 08:00:00"), estimatedTime);

            jobScheduler.Schedule(jobObj3);
            var jobObj4 = new Job(4, "Integration4", Convert.ToDateTime("2019-11-11 09:00:00"), estimatedTime);

            jobScheduler.Schedule(jobObj4);

            var estimatedTime2 = new EstimatedTimeBR("8 horas");
            var jobObj5        = new Job(5, "Integration5", Convert.ToDateTime("2019-11-11 10:00:00"), estimatedTime2);

            jobScheduler.Schedule(jobObj5);

            var jobSchedulerArray      = jobScheduler.ToArray();
            var expectedSchedulerArray = new int[2][];

            expectedSchedulerArray[0]    = new int[4];
            expectedSchedulerArray[0][0] = 1;
            expectedSchedulerArray[0][1] = 2;
            expectedSchedulerArray[0][2] = 3;
            expectedSchedulerArray[0][3] = 4;
            expectedSchedulerArray[1]    = new int[1];
            expectedSchedulerArray[1][0] = 5;

            var queue = new Queue <Job>();

            queue.Enqueue(jobObj);
            queue.Enqueue(jobObj2);
            queue.Enqueue(jobObj3);
            queue.Enqueue(jobObj4);
            var queue2 = new Queue <Job>();

            queue2.Enqueue(jobObj5);

            var expectedQueues = new List <Queue <Job> >
            {
                queue,
                queue2
            };

            Assert.IsNotEmpty(jobSchedulerArray);
            Assert.AreEqual(expectedSchedulerArray, jobSchedulerArray);
            Assert.AreEqual(expectedQueues, jobScheduler.GetQueues());
        }
コード例 #3
0
        public void CreatesInstanceWithExecutionWindowAndEstimatedTime()
        {
            var date1 = DateFactory.Build("2019-11-10 09:00:00");
            var date2 = DateFactory.Build("2019-11-11 12:00:00");

            var executionWindow  = new ExecutionWindow(date1, date2);
            var maxEstimatedTime = new EstimatedTimeBR("8 horas");
            var jobScheduler     = new JobScheduler(executionWindow, maxEstimatedTime);

            Assert.IsInstanceOf(typeof(JobScheduler), jobScheduler);
        }
コード例 #4
0
        public void RespondsFalseToIsInWhenDateIsOutsideExecutionWindow()
        {
            DateTime date1 = DateFactory.Build("2019-11-11 09:00:00");
            DateTime date2 = DateFactory.Build("2019-11-10 12:00:00");

            DateTime date3 = DateFactory.Build("2019-11-20 10:00:00");

            var executionObj = new ExecutionWindow(date1, date2);

            Assert.False(executionObj.IsIn(date3));
        }
コード例 #5
0
        public void CreatesInstanceWithTwoDateTimeFromTheSmallestToLargest()
        {
            DateTime date1 = DateFactory.Build("2019-11-11 09:00:00");
            DateTime date2 = DateFactory.Build("2019-11-10 12:00:00");

            var executionObj = new ExecutionWindow(date1, date2);

            Assert.IsInstanceOf(typeof(ExecutionWindow), executionObj);
            Assert.AreEqual(date2, executionObj.Window.Item1);
            Assert.AreEqual(date1, executionObj.Window.Item2);
        }
コード例 #6
0
        public void RespondsToMaxJobDuration()
        {
            var date1 = DateFactory.Build("2019-11-10 09:00:00");
            var date2 = DateFactory.Build("2019-11-11 12:00:00");

            var executionWindow  = new ExecutionWindow(date1, date2);
            var maxEstimatedTime = new EstimatedTimeBR("8 horas");
            var jobScheduler     = new JobScheduler(executionWindow, maxEstimatedTime);

            Assert.IsInstanceOf(typeof(JobScheduler), jobScheduler);
            Assert.AreEqual(maxEstimatedTime, jobScheduler.MaxJobDuration());
        }
コード例 #7
0
        public void ItDoesNotSchedulesAJobAboveExecutionWindow()
        {
            var date1 = DateFactory.Build("2019-11-10 09:00:00");
            var date2 = DateFactory.Build("2019-11-11 12:00:00");

            var executionWindow  = new ExecutionWindow(date1, date2);
            var maxEstimatedTime = new EstimatedTimeBR("8 horas");
            var jobScheduler     = new JobScheduler(executionWindow, maxEstimatedTime);

            var estimatedTime = new EstimatedTimeBR("4 horas");
            var jobObj        = new Job(1, "Integration", Convert.ToDateTime("2019-11-15 12:00:00"), estimatedTime);

            jobScheduler.Schedule(jobObj);

            Assert.IsEmpty(jobScheduler.ToArray());
        }