public void TaskExecutionCondition_gets_most_severe_previous_step_outcome( ResolverType resolverType, TaskOutcome firstStepOutcome, TaskOutcome secondStepOutcome, TaskOutcome outcomePassedToThirdStepCondition) { // Arrange var actualOutcomePassedToCondition = (TaskOutcome?)null; var task = new TaskDefinition( GetStepForOutcome(firstStepOutcome), GetStepForOutcome(secondStepOutcome, TaskStepUtils.AlwaysExecuteCondition), new BasicTaskStep( "TestedStep", () => { }, x => { actualOutcomePassedToCondition = x; return(true); })); // Act task.Execute(resolverType, cancellation: _cancellationSource); // Assert actualOutcomePassedToCondition.Should().Be(outcomePassedToThirdStepCondition); }
public TaskStepExecutionContext( TaskDefinition task, ExecutionEventsBag eventsBag, TaskOutcome outcomeSoFar) { Task = task; EventsBag = eventsBag; OutcomeSoFar = outcomeSoFar; }
public void default_condition___executed_only_if_successful( ResolverType resolverType, TaskOutcome precedingStepOutcome, bool testedStepExecuted) { var task = new TaskDefinition( GetStepForOutcome(precedingStepOutcome), new BasicTaskStep( "TestedStep", () => { _testedStepExecuted = true; })); test_conditional_execution(resolverType, task, testedStepExecuted); }
private void ExecuteStep <TStep>( TStep step, TaskDefinition task, TaskOutcome outcomeSoFar, CancellationToken cancellation, ExecutionEventsBag eventsBag) where TStep : ITaskStep { var stepExecutor = _taskStepExecutorResolver.Resolve <TStep>(); var context = new TaskStepExecutionContext( task, eventsBag, outcomeSoFar); stepExecutor.Execute(step, context, cancellation); }
private ITaskStep GetStepForOutcome( TaskOutcome outcome, Func <TaskOutcome, bool> executionCondition = null) { return(new BasicTaskStep( Guid.NewGuid().ToString(), () => { switch (outcome) { case TaskOutcome.Successful: return; case TaskOutcome.Canceled: _cancellationSource.Cancel(); return; case TaskOutcome.Failed: throw new Exception(); } }, executionCondition)); }