Ejemplo n.º 1
0
        /// <summary>
        /// Updates the step according to this translation
        /// </summary>
        /// <param name="step"></param>
        public void UpdateStep(Step step)
        {
            int subStepCounter = 1;

            foreach (SubStep subStep in SubSteps)
            {
                SubStep newSubStep = (SubStep)Generated.acceptor.getFactory().createSubStep();
                newSubStep.Name = "Sub-step" + subStepCounter;
                step.appendSubSteps(newSubStep);

                foreach (Rules.Action action in subStep.Actions)
                {
                    Rules.Action newAct = (Rules.Action)Generated.acceptor.getFactory().createAction();
                    action.copyTo(newAct);
                    newSubStep.appendActions(newAct);
                    Review(newAct);
                }

                foreach (Expectation expectation in subStep.Expectations)
                {
                    Expectation newExp = (Expectation)Generated.acceptor.getFactory().createExpectation();
                    expectation.copyTo(newExp);
                    newSubStep.appendExpectations(newExp);
                    Review(newExp);
                }

                subStepCounter++;
            }
        }
Ejemplo n.º 2
0
        public override void visit(Generated.Action obj, bool visitSubNodes)
        {
            Rules.Action action = (Rules.Action)obj;

            if (Rebuild)
            {
                action.Statement = null;
            }

            // Side effect : compiles or recompiles the statement
            DataDictionary.Interpreter.Statement.Statement statement = action.Statement;

            base.visit(obj, visitSubNodes);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds a model element in this model element
 /// </summary>
 /// <param name="copy"></param>
 public override void AddModelElement(Utils.IModelElement element)
 {
     if (element is Rules.Action)
     {
         Rules.Action item = element as Rules.Action;
         if (item != null)
         {
             appendActions(item);
         }
     }
     else if (element is Expectation)
     {
         Tests.Expectation item = element as Tests.Expectation;
         if (item != null)
         {
             appendExpectations(item);
         }
     }
 }
Ejemplo n.º 4
0
            /// <summary>
            /// Adds a transition in the transitions sets
            /// </summary>
            /// <param name="update">The update state which provides the target of the transition</param>
            /// <param name="target">The target state, as determined by the update statement</param>
            /// <param name="filteredOut"></param>
            /// <param name="preCondition">the precondition (if any) which is used to determine the initial state</param>
            /// <param name="initial">The initial state</param>
            /// <returns>true if the transition has been filtered out. A transition can be filtered out if the target state is equal to the initial state or the initial state is null
            /// </returns>
            private bool AddTransition(Interpreter.Statement.VariableUpdateStatement update, Constants.State target, Rules.PreCondition preCondition, Constants.State initial)
            {
                bool retVal = false;

                Constants.State initialState = StateMachine.StateInThisStateMachine(initial);
                // TargetState is the target state either in this state machine or in a sub state machine
                Constants.State targetState = StateMachine.StateInThisStateMachine(target);

                // Determine the rule condition (if any) related to this state machine
                Rules.RuleCondition condition = null;
                if (update != null)
                {
                    Rules.Action action = update.Root as Rules.Action;
                    condition = action.RuleCondition;
                }

                if (targetState != null || initialState != null)
                {
                    // This transition is about this state machine.
                    if (initialState != targetState && initialState != null)
                    {
                        // Check that the transition is not yet present
                        // This case can occur when the same RuleCondition references two different states
                        // in a substate machine. Only draws the transition once.
                        if (!findMatchingTransition(condition, initialState, targetState))
                        {
                            Transitions.Add(new Rules.Transition(preCondition, initialState, update, targetState));
                        }
                    }
                    else
                    {
                        if (initialState == initial)
                        {
                            retVal = true;
                        }
                    }
                }

                return(retVal);
            }
Ejemplo n.º 5
0
 /// <summary>
 /// Review the expressions associated to this action
 /// </summary>
 /// <param name="action"></param>
 private void Review(Rules.Action action)
 {
     action.Expression = ReviewExpression(action.Step, action.Expression);
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="action"The action which raised the variable update></param>
 public VariableUpdate(Rules.Action action, Utils.IModelElement instance)
     : base(action.Statement.ToString(), instance)
 {
     Action = action;
 }