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 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 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 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 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 MainWindow( IDebuggerSession session, ISourcesProvider sourcesProvider, SourcesWindow sourcesWindow, SourceWindow sourceWindow, LogWindow log, CallStackDisplay callStackDisplay, ExecutionWindow executionWindow, DebuggerWindowManager windowManager ) { this.log = log; this.callStackDisplay = callStackDisplay; this.executionWindow = executionWindow; this.sourcesWindow = sourcesWindow; this.sourceWindow = sourceWindow; this.session = session; this.windowManager = windowManager; if (HasArguments ()) this.session.Port = SdbPortFromCommandLine (); Camera.main.backgroundColor = new Color (0.125f, 0.125f, 0.125f, 0); Application.runInBackground = true; AdjustLayout (); if (!HasArguments ()) return; this.session.TraceCallback += s => Trace (s); sourcesProvider.Path = ProjectPathFromCommandLine (); sourcesWindow.StartRefreshing (); session.Start (); }
/// <summary> /// Prepares the virtual machine to start the execution. /// </summary> /// <returns>The window that will show the execution information.</returns> private async Task<ExecutionWindow> PrepareExecutionAsync() { Memory memory = null; await Task.Run(async () => { int virtualMachineSize = (int)Settings.Default[App.SystemMemorySettingKey]; InstructionSet instructionsCollection = InstructionSet.CreateFromFile(_selectedFilePath); Memory mem = Memory.CreateMemory(virtualMachineSize, instructionsCollection); if (mem.StackRegion.Count <= 0) { await this.Dispatcher.InvokeAsync(async () => await this.ShowMessageAsync(ProgramTooBigErrorTitle, ProgramTooBigErrorMessage)); return; } memory = mem; }); if (memory == null) { //We don't have memory :'( return null; } ExecutionWindow executionWindow; ExecutionContext currentContext = new ExecutionContext() { ProgramCounter = new ProgramCounter(CPU.InitialProgramCounter), Memory = memory }; executionWindow = new ExecutionWindow(_selectedFilePath, App.ProgramNameFromArgument, currentContext); currentContext.InputProvider = executionWindow as IInputProvider; currentContext.OutputProvider = executionWindow as IOutputProvider; return executionWindow; }
private void OnExecuteEnd(ExecutionWindow ExecutionWindow) { IsExecuted = true; Executed?.Invoke(this, new PcdmisEventArgs(_pcdPartProgram.ExecutionWasCancelled, null)); }
private void StartButton_Click(object sender, RoutedEventArgs e) { string exceptionMessage = string.Empty; if (!_edtAssetSelectionControl.HasSelection) { MessageBox.Show("Please select a device to continue.", ApplicationName, MessageBoxButton.OK, MessageBoxImage.Error); return; } if (_scenarioList.Count == 0) { MessageBox.Show("There are no scenarios to execute!", ApplicationName, MessageBoxButton.OK, MessageBoxImage.Error); return; } if (_isFim && (string.IsNullOrEmpty(BaseFirmwareTextBox.Text) || string.IsNullOrEmpty(TargetFirmwareTextBox.Text) || !Directory.Exists(BaseFirmwareTextBox.Text) || !Directory.Exists(TargetFirmwareTextBox.Text))) { MessageBox.Show("Please validate the firmware locations for the device.", ApplicationName, MessageBoxButton.OK, MessageBoxImage.Error); return; } //kick start the execution TestInstanceData activeTestInstanceData = new TestInstanceData { ActiveScenarios = _scenarioList.Where(x => x.Active).ToList(), DeviceAssetInfoCollection = ConfigurationServices.AssetInventory.GetAssets(_edtAssetSelectionControl.AssetSelectionData.SelectedAssets), BaseFirmwarePath = BaseFirmwareTextBox.Text, TargetFirmwarePath = TargetFirmwareTextBox.Text, RunName = RunComboBox.Text, RunId = (Guid)RunComboBox.SelectedValue }; if (BashCollectorCheckBox.IsChecked.HasValue) { activeTestInstanceData.BashCollectorHost = BashCollectorCheckBox.IsChecked.Value ? _addressControl.Text : string.Empty; } this.Visibility = Visibility.Collapsed; try { ExecutionWindow executionWindow = new ExecutionWindow(activeTestInstanceData); executionWindow.ShowDialog(); } catch (Exception ex) { exceptionMessage = Extension.JoinAllErrorMessages(ex); } this.Visibility = Visibility.Visible; if (!string.IsNullOrEmpty(exceptionMessage)) { MessageBox.Show($"An error occurred. {exceptionMessage}", ApplicationName, MessageBoxButton.OK, MessageBoxImage.Error); } }