public void ComparesGreaterThanAndFailsWhenIsLess() { var obj1 = new EstimatedTimeBR("8 segundos"); var obj2 = new EstimatedTimeBR("5 segundos"); Assert.False(obj2.GreaterThan(obj1)); }
public void ComparesGreaterThanOrEqualAndFailsWhenIsLess() { var obj1 = new EstimatedTimeBR("2 segundos"); var obj2 = new EstimatedTimeBR("5 segundos"); Assert.False(obj1.GreaterThanOrEqual(obj2)); }
public void ComparesGreaterThanOrEqualWhenIsGreater() { var obj1 = new EstimatedTimeBR("10 segundos"); var obj2 = new EstimatedTimeBR("5 segundos"); Assert.True(obj1.GreaterThanOrEqual(obj2)); }
public void ComparesLessThanAndFailsWhenIsGreater() { var obj1 = new EstimatedTimeBR("9 segundos"); var obj2 = new EstimatedTimeBR("2 segundos"); Assert.False(obj1.LessThan(obj2)); }
public void ComparesLessThan() { var obj1 = new EstimatedTimeBR("5 segundos"); var obj2 = new EstimatedTimeBR("8 segundos"); Assert.True(obj1.LessThan(obj2)); }
public void ComparesGreaterThan() { var obj1 = new EstimatedTimeBR("5 segundos"); var obj2 = new EstimatedTimeBR("8 segundos"); Assert.True(obj2.GreaterThan(obj1)); }
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()); }
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()); }
public void CreatesInstanceWithInteger() { var integerValue = 5; var obj = new EstimatedTimeBR(integerValue); Assert.IsInstanceOf(typeof(EstimatedTimeBR), obj); Assert.AreEqual(integerValue, obj.ToSeconds()); }
public void ConvertsSecondsProperly() { var obj = new EstimatedTimeBR("5 segundos"); Assert.AreEqual(5, obj.ToSeconds()); Assert.AreEqual(0, obj.ToMinutes()); Assert.AreEqual(0, obj.ToHours()); }
public void ConvertsHoursProperly() { var obj = new EstimatedTimeBR("5 horas"); Assert.AreEqual(18000, obj.ToSeconds()); Assert.AreEqual(300, obj.ToMinutes()); Assert.AreEqual(5, obj.ToHours()); }
public void ConvertsHourProperly() { var obj = new EstimatedTimeBR("1 hora"); Assert.AreEqual(3600, obj.ToSeconds()); Assert.AreEqual(60, obj.ToMinutes()); Assert.AreEqual(1, obj.ToHours()); }
public void ConvertsMinuteProperly() { var obj = new EstimatedTimeBR("1 minuto"); Assert.AreEqual(60, obj.ToSeconds()); Assert.AreEqual(1, obj.ToMinutes()); Assert.AreEqual(0, obj.ToHours()); }
public void CreatesInstanceWithProperEstimation() { var estimatedTime = new EstimatedTimeBR("5 horas"); var jobObj = new Job(1, "Integration", new DateTime(), estimatedTime); Assert.IsInstanceOf(typeof(Job), jobObj); Assert.AreEqual(18000, jobObj.Duration()); }
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); }
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()); }
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()); }
public void CreatesInstanceWithValidString() { var obj = new EstimatedTimeBR("5 segundos"); Assert.IsInstanceOf(typeof(EstimatedTimeBR), obj); }