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 override JobLib.Job Build() { var expiresAt = new DateFactory(SampleJob.ExpiresAt).Build(); var estimatedTime = new EstimatedTimeBRFactory(SampleJob.EstimatedTime).Build(); return(new JobLib.Job(SampleJob.Id, SampleJob.Description, expiresAt, estimatedTime)); }
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 Date_Factory_Test() { DateFactory factory = new DateFactory("date", DateFactory.Dates, false); foreach (KeyValuePair<DateTime, string> pair in FormattedDates) { MatchParagraphs<DateTime>(factory, pair.Value, pair.Key, true); } }
public void should_set_test_suite_end_time() { var date = DateFactory.SomeDate(); GotoTimeAndEndTestSuite(date); var report = Reporter.ExportXml(); Check.That(report.EvaluateXPath("//Report/End")).IsEqualTo(date.ToReportFormat()); }
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 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); }
public void should_set_test_suite_start_time() { var start = DateFactory.SomeDate(); GotoTimeAndStartTestSuite(start); var expected = start.ToReportFormat(); var report = Reporter.ExportXml(); Check.That(report.EvaluateXPath("//Report/Start")).IsEqualTo(expected); }
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)); }
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 ExecutionWindowFactory(Sample sample) { if (sample.ExecutionWindow.Length < 2) { throw new ArgumentException("Sample ExecutionWindow must be a DateString Tuple"); } var date1 = new DateFactory(sample.ExecutionWindow[0]).Build(); var date2 = new DateFactory(sample.ExecutionWindow[1]).Build(); Window = new ExecutionWindow(date1, date2); }
public void should_set_scenario_start_time() { var start = DateFactory.SomeDate(); TimeTravelTo(start); var scenario = TestConstants.SampleScenarios.ReplacedItems; Reporter.ScenarioStarted(_feature.Title, scenario); var report = Reporter.ExportXml(); Check.That(report.EvaluateXPath("//Report/Features/FeatureNode/Scenarios/ScenarioNode/Start")).IsEqualTo(start.ToReportFormat()); }
public void should_calculate_duration_of_test_suite_correctly() { var start = DateFactory.SomeDate().At("17:30:20"); var end = DateFactory.SomeDate().At("17:32:00"); var expected = "PT1M40S"; GotoTimeAndStartTestSuite(start); GotoTimeAndEndTestSuite(end); var report = Reporter.ExportXml(); Check.That(report.EvaluateXPath("//Report/Duration")).IsEqualTo(expected); }
public void should_set_scenario_end_time_when_scenario_marked_as_failed() { var scenario = TestConstants.SampleScenarios.ReplacedItems; Reporter.ScenarioStarted(_feature.Title, scenario); var end = DateFactory.SomeDate(); TimeTravelTo(end); Reporter.MarkScenarioAsFailed(_feature.Title, scenario); var report = Reporter.ExportXml(); Check.That(report.EvaluateXPath("//Report/Features/FeatureNode/Scenarios/ScenarioNode/End")).IsEqualTo(end.ToReportFormat()); }
public static Evaluator getEvaluator(Integer typeObj, Integer operObj) { int type = typeObj.intValue(); int oper = operObj.intValue(); switch (type) { case Evaluator.__Fields.STRING_TYPE: return(StringFactory.getStringEvaluator(oper)); case Evaluator.__Fields.OBJECT_TYPE: return(ObjectFactory.getObjectEvaluator(oper)); case Evaluator.__Fields.SHORT_TYPE: return(ShortFactory.getShortEvaluator(oper)); case Evaluator.__Fields.INTEGER_TYPE: return(IntegerFactory.getIntegerEvaluator(oper)); case Evaluator.__Fields.BOOLEAN_TYPE: return(BooleanFactory.getBooleanEvaluator(oper)); case Evaluator.__Fields.DOUBLE_TYPE: return(DoubleFactory.getDoubleEvaluator(oper)); case Evaluator.__Fields.CHAR_TYPE: return(CharacterFactory.getCharacterEvaluator(oper)); case Evaluator.__Fields.BYTE_TYPE: return(ByteFactory.getByteEvaluator(oper)); case Evaluator.__Fields.FLOAT_TYPE: return(FloatFactory.getFloatEvaluator(oper)); case Evaluator.__Fields.LONG_TYPE: return(LongFactory.getLongEvaluator(oper)); case Evaluator.__Fields.DATE_TYPE: return(DateFactory.getDateEvaluator(oper)); case Evaluator.__Fields.ARRAY_TYPE: return(ArrayFactory.getArrayEvaluator(oper)); default: throw new RuntimeException("Type '" + type + "' does not exist for BaseEvaluator.__FieldsFactory"); } }
public void should_set_scenario_duration_based_on_start_and_end_time() { var scenario = TestConstants.SampleScenarios.ReplacedItems; var start = DateFactory.SomeDate().At("05:30:00"); var end = DateFactory.SomeDate().At("05:32:30"); var expected = "PT2M30S"; TimeTravelTo(start); Reporter.ScenarioStarted(_feature.Title, scenario); TimeTravelTo(end); Reporter.MarkScenarioAsPassed(_feature.Title, scenario); var report = Reporter.ExportXml(); Check.That(report.EvaluateXPath("//Report/Features/FeatureNode/Scenarios/ScenarioNode/Duration")).IsEqualTo(expected); }
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()); }