Exemplo n.º 1
0
        private ConditionResult assertCondition(IfElement condition)
        {
            ConditionResult _assertResult = null;

            string valueOF       = condition.getAttribute(AttributeConstants.VALUE_OF).getValue().ToString();
            object expectedValue = condition.getAttribute(AttributeConstants.VALUE).getValue();
            string conditionType = condition.getAttribute(AttributeConstants.CONDITION).getValue().ToString();

            object valueToCheck = this._AttributeSelector.valueOf(valueOF);

            if (valueToCheck == null)
            {
                throw new Exception("Could not assert [null] value-of.");
            }

            try
            {
                ConditionType _condition = EnumUtil.Parse <ConditionType>(conditionType);
                _assertResult = new ConditionResult(
                    AssertionUtil.AssertCondition(_condition, expectedValue, valueToCheck),
                    condition.DoNodes,
                    condition.ElseNodes);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(_assertResult);
        }
Exemplo n.º 2
0
        private void runRecursive(IList <IElement> execution)
        {
            foreach (IElement line in execution)
            {
                switch (line.getElementName())
                {
                case ElementNameConstants.ACTIVITY:
                    var     activity = (ActivityElement)line;
                    IResult result   = this.executeActivity(activity);
                    if (result != null)
                    {
                        if (this._stateProvider.getActivityResults().ContainsKey(activity.getAttribute(AttributeConstants.ID).getValue()))
                        {
                            this._stateProvider.getActivityResults().Remove(activity.getAttribute(AttributeConstants.ID).getValue());
                        }
                        this._stateProvider.getActivityResults().Add(activity.getAttribute(AttributeConstants.ID).getValue(), result);
                    }
                    break;

                case ElementNameConstants.IF:
                    ConditionResult conditionResult = this.assertCondition((IfElement)line);
                    if (conditionResult.Result)
                    {
                        if (conditionResult.DoNodes != null)
                        {
                            runRecursive(conditionResult.DoNodes);
                        }
                    }
                    else
                    {
                        if (conditionResult.ElseNodes != null)
                        {
                            runRecursive(conditionResult.ElseNodes);
                        }
                    }
                    break;

                case ElementNameConstants.FOR_EACH:
                    this.executeForEach((ForEachElement)line);
                    break;

                case ElementNameConstants.ASSIGN:
                    this.executeAssign((AssignElement)line);
                    break;

                case ElementNameConstants.VARIABLE:
                    this.createVariable((VariableElement)line);
                    break;

                case ElementNameConstants.LOGGER:
                    this.executeLogger((LoggerElement)line);
                    break;

                case ElementNameConstants.REPEAT:
                    this.executeRepeat((RepeatElement)line);
                    break;

                default:
                    break;
                }
            }
        }