public async void ShouldContinueWithCaughtContinueTest() { // Arrange const int iterations = 2; var step1 = new LoopStep("one"); var step2 = new LoopStep("two"); var controlStop = new StepThatThrowsContinue("three"); var baseStepList = new List <Step <SimpleWorkflowState> > { step1, step2, controlStop }; var nonControlStepCount = baseStepList.Count(x => x.GetType() != controlStop.GetType()); bool ShouldContinue(SimpleWorkflowState simpleWorkflowState) => simpleWorkflowState.MyInteger < iterations * nonControlStepCount; var forLoop = new WhileLoop <SimpleWorkflowState>(ShouldContinue, name: "foo", steps: baseStepList); // Act var result = await forLoop.Execute(_workflowState); // Assert Assert.Equal(iterations * nonControlStepCount, result.State.MyInteger); Assert.Equal(iterations * baseStepList.Count + 1, result.WorkflowChain.Count); Assert.Equal(iterations, forLoop.CurrentIteration); }
public async void ShouldContinueAsyncTest() { // Arrange const int iterations = 2; var step1 = new LoopStep("one"); var step2 = new LoopStep("two"); var step3 = new LoopStep("three"); var baseStepList = new List <Step <SimpleWorkflowState> > { step1, step2, step3 }; Task <bool> ShouldContinueAsync(SimpleWorkflowState simpleWorkflowState) => Task.FromResult(simpleWorkflowState.MyInteger < iterations * baseStepList.Count); var forLoop = new WhileLoop <SimpleWorkflowState>(ShouldContinueAsync, name: "foo", steps: baseStepList); // Act var result = await forLoop.Execute(_workflowState); // Assert Assert.Equal(iterations * baseStepList.Count, result.State.MyInteger); Assert.Equal(iterations * baseStepList.Count + 1, result.WorkflowChain.Count); Assert.Equal(iterations, forLoop.CurrentIteration); }
public async void DetermineIterationsTest() { // Arrange const int iterations = 2; int DetermineIterations(SimpleWorkflowState simpleWorkflowState) => iterations; var step1 = new LoopStep("one"); var step2 = new LoopStep("two"); var step3 = new LoopStep("three"); var baseStepList = new List <Step <SimpleWorkflowState> > { step1, step2, step3 }; var forLoop = new ForLoop <SimpleWorkflowState>(DetermineIterations, name: "foo", steps: baseStepList); // Act var result = await forLoop.Execute(_workflowState); // Assert Assert.Equal(iterations * baseStepList.Count, result.State.MyInteger); Assert.Equal(iterations * baseStepList.Count + 1, result.WorkflowChain.Count); Assert.Equal(iterations, forLoop.CurrentIteration); }
public async void BreakForLoopTest() { // Arrange var iterations = 2; var step1 = new LoopStep("one"); var step2 = new LoopStep("two"); var breakStep = new StopThatThrowsBreak("break-step"); var baseStepList = new List <Step <SimpleWorkflowState> > { step1, step2, breakStep }; var forLoop = new ForLoop <SimpleWorkflowState>(iterations, name: "foo", steps: baseStepList); // Act var result = await forLoop.Execute(_workflowState); var nonBreakStepCount = baseStepList.Count(x => x.GetType() != breakStep.GetType()); // Assert Assert.Equal(nonBreakStepCount, result.State.MyInteger); Assert.Equal(baseStepList.Count + 1, result.WorkflowChain.Count); Assert.Equal(0, forLoop.CurrentIteration); }
public async void ContinueForLoopTest() { // Arrange var iterations = 2; var step1 = new LoopStep("one"); var continueStep = new StepThatThrowsContinue("break-step"); var step3 = new LoopStep("three"); var baseStepList = new List <Step <SimpleWorkflowState> > { step1, continueStep, step3 }; var forLoop = new ForLoop <SimpleWorkflowState>(iterations, name: "foo", steps: baseStepList); // Act var result = await forLoop.Execute(_workflowState); // Assert Assert.Equal(iterations, result.State.MyInteger); Assert.Equal(iterations * 2 + 1, result.WorkflowChain.Count); Assert.Equal(iterations, forLoop.CurrentIteration); }
/// <summary> /// The create loop step. /// </summary> /// <returns> /// The <see cref="LoopStep"/>. /// </returns> public LoopStep CreateLoopStep() { var myLoopStep = new LoopStep(); return(myLoopStep); }
public void TestAllowChildren() { LoopStep step = new LoopStep(); step.ChildTestSteps.Add(new AutomationStep()); }