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 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); }