Exemplo n.º 1
0
        // process the steps until we get a NoAction
        // for example if we needed to show the form to someone, this base handler doesn't understand that
        // so this would have to be picked up by a different type of runner
        // for example a webapi handler would be able to process a collect data action
        public virtual ActionBase ProcessSteps()
        {
            var stepInstance = FlowInstance.NextStep();

            while (stepInstance != null)
            {
                if (!CanProcess(stepInstance.GetType()))
                {
                    return new UnhandlableAction {
                               Step = stepInstance
                    }
                }
                ;

                // process the flow
                // move to completed if step thinks it is complete
                stepInstance.Process(FlowInstance, this);
                if (stepInstance.IsComplete)
                {
                    FlowInstance.CompletedSteps.Add(new CompletedStep(stepInstance.Id, stepInstance.VersionId));
                }

                stepInstance = FlowInstance.NextStep();
            }
            return(new NoAction());
        }
Exemplo n.º 2
0
        public void Should_return_first_step_if_no_steps_are_completed()
        {
            // arrange
            var steps = new List <IStep> {
                new StartStep {
                    Id = 1
                }, new CollectDataStep {
                    Id = 2
                }, new StopStep {
                    Id = 3
                }
            };
            var template = new FlowTemplate {
                Steps = steps
            };
            var sut = new FlowInstance {
                Template = template
            };

            // act
            var result = sut.NextStep();

            // assert
            Assert.NotNull(result);
            Assert.IsType <StartStep>(result);
        }