Пример #1
0
        public void TryConditionalStep()
        {
            var obj  = new TestObject();
            var step = new ConditionalStepConfig
                       (
                new StepConfig[]
            {
                new StepConfig()
                {
                    Step = new TestStep(obj), Condition = new ExecutionCondition()
                    {
                        Always = true
                    }
                }
            },
                new StepConfig[] { },
                new TestRandom()
                       )
            {
                Condition = new ExecutionCondition()
                {
                    Always = true
                }
            };
            var processor = new Processor(new StepConfig[] { step });

            processor.Execute();

            Assert.AreEqual(true, obj.Changed);
            Assert.AreEqual(2, processor.Info.Steps.Count);
        }
Пример #2
0
            public void BuildConditionanStep_AsInstance()
            {
                // Arrange
                ConditionalStepConfig config = CreateSimpleConditationalStepConfig();

                // Act
                IStep step = StepBuilder.FromConditionalConfig(config).BuildAsSingleStep();

                // Assert
                AssertConditionalStep(step);
            }
Пример #3
0
            public void BuildConditionalStep_AsList()
            {
                // Arrange
                ConditionalStepConfig config = CreateSimpleConditationalStepConfig();

                // Act
                IEnumerable <IStep> step = StepBuilder.FromConditionalConfig(config).BuildSteps();

                // Assert
                IStep first = step.First();

                AssertConditionalStep(first);
            }
Пример #4
0
 /// <summary>
 /// Set the configured <see cref="Step"/> settings.
 /// </summary>
 /// <param name="conditionalStepConfig">The conditional step configuration.</param>
 /// <returns></returns>
 public static StepBuilder FromConditionalConfig(ConditionalStepConfig conditionalStepConfig)
 {
     return(new StepBuilder(stepConfiguration: null, conditionalStepConfig: conditionalStepConfig));
 }
Пример #5
0
 private StepBuilder(Step[] stepConfiguration, ConditionalStepConfig conditionalStepConfig)
 {
     _stepConfiguration     = stepConfiguration;
     _conditionalStepConfig = conditionalStepConfig;
 }
Пример #6
0
        public void InitializeSteps()
        {
            _steps = new List <IStepConfig>();

            for (int i = 0; i < 10; ++i)
            {
                IStepConfig config = new EmptyStepConfig {
                    Step = new EmptyStep()
                };

                config.Condition = i % 2 == 0 ? new ExecutionCondition {
                    Always = true
                } :
                new ExecutionCondition {
                    IfPreviousSucceded = true
                };

                _steps.Add(config);
            }

            _stepsWithCondition = new List <IStepConfig>();

            for (int i = 0; i < 3; ++i)
            {
                IStepConfig config = new EmptyStepConfig {
                    Step = new EmptyStep()
                };

                config.Condition = i % 2 == 0 ? new ExecutionCondition {
                    Always = true
                } :
                new ExecutionCondition {
                    IfPreviousSucceded = true
                };

                _stepsWithCondition.Add(config);
            }

            List <IStepConfig> stepsIfTrue = new List <IStepConfig>();

            for (int i = 0; i < 5; ++i)
            {
                IStepConfig config = new EmptyStepConfig {
                    Step = new EmptyStep()
                };

                config.Condition = new ExecutionCondition {
                    Always = true
                };

                stepsIfTrue.Add(config);
            }

            List <IStepConfig> stepsIfFalse = new List <IStepConfig>();

            for (int i = 0; i < 5; ++i)
            {
                IStepConfig config = new EmptyStepConfig {
                    Step = new EmptyStep()
                };

                config.Condition = new ExecutionCondition {
                    Always = true
                };

                stepsIfTrue.Add(config);
            }

            ConditionalStepConfig conditionalStepConfig = new ConditionalStepConfig(_stepsWithCondition[0],
                                                                                    stepsIfTrue, stepsIfFalse);

            _stepsWithCondition.Add(conditionalStepConfig);
        }