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 BreakWhileLoopTest()
        {
            // Arrange
            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 WhileLoop <SimpleWorkflowState>(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);
        }