Пример #1
0
        private void SetVariableAndArgumentType(string paramValue, ITypeData type, VariableTreeTable variableTree,
                                                ISequenceFlowContainer parent)
        {
            IVariable variable;
            IArgument argument;
            string    variableName = ModuleUtils.GetVarNameByParamValue(paramValue);

            if (null != (variable = variableTree.GetVariable(variableName)))
            {
                if (!ModuleUtils.IsPropertyParam(paramValue))
                {
                    variable.Type = type;
                }
            }
            else if (null != (argument = variableTree.GetArgument(variableName)))
            {
                if (!ModuleUtils.IsPropertyParam(paramValue))
                {
                    argument.Type = type;
                }
            }
            else
            {
                ThrowIfVariableNotFound(variableName, parent);
            }
        }
Пример #2
0
 private void VerifyVariableTypes(ISequence sequence, VariableTreeTable variableTree)
 {
     variableTree.Push(sequence.Variables);
     foreach (ISequenceStep sequenceStep in sequence.Steps)
     {
         VerifyVariableTypes(sequenceStep, variableTree);
     }
     variableTree.Pop();
 }
Пример #3
0
        /// <summary>
        /// 初始化变量和参数的类型数据
        /// </summary>
        public void VerifyVariableTypes(ISequenceGroup sequenceGroup)
        {
            VariableTreeTable variableTree = new VariableTreeTable(sequenceGroup.Arguments);

            variableTree.Push(sequenceGroup.Variables);
            VerifyVariableTypes(sequenceGroup.SetUp, variableTree);
            foreach (ISequence sequence in sequenceGroup.Sequences)
            {
                VerifyVariableTypes(sequence, variableTree);
            }
            VerifyVariableTypes(sequenceGroup.TearDown, variableTree);
            variableTree.Pop();
        }
Пример #4
0
        /// <summary>
        /// 初始化变量和参数的类型数据
        /// </summary>
        public void VerifyVariableTypes(ITestProject testProject)
        {
            VariableTreeTable variableTree = new VariableTreeTable(null);

            variableTree.Push(testProject.Variables);
            VerifyVariableTypes(testProject.SetUp, variableTree);
            VerifyVariableTypes(testProject.TearDown, variableTree);
            foreach (ISequenceGroup sequenceGroup in testProject.SequenceGroups)
            {
                if (null != sequenceGroup && sequenceGroup.Available)
                {
                    VerifyVariableTypes(sequenceGroup);
                }
            }
        }
Пример #5
0
        private void SetVariableAndArgumentType(string variableName, ITypeData type, VariableTreeTable variableTree,
                                                ISequenceFlowContainer parent)
        {
            IVariable variable;
            IArgument argument;

            if (null != (variable = variableTree.GetVariable(variableName)))
            {
                variable.Type = type;
            }
            else if (null != (argument = variableTree.GetArgument(variableName)))
            {
                argument.Type = type;
            }
            else
            {
                ThrowIfVariableNotFound(variableName, parent);
            }
        }
Пример #6
0
        private void VerifyVariableTypes(ISequenceStep sequenceStep, VariableTreeTable variableTree)
        {
            if (!string.IsNullOrWhiteSpace(sequenceStep.LoopCounter?.CounterVariable))
            {
                string    variableName = ModuleUtils.GetVarNameByParamValue(sequenceStep.LoopCounter.CounterVariable);
                IVariable variable     = variableTree.GetVariable(variableName);
                Type      varType      = typeof(int);
                // Argument不能作为遍历变量
                if (null == variable)
                {
                    ThrowIfVariableNotFound(variableName, sequenceStep);
                }
                else if (!ModuleUtils.IsPropertyParam(sequenceStep.LoopCounter.CounterVariable) &&
                         (variable.Type == null || !variable.Type.Name.Equals(varType.Name)))
                {
                    variable.Type = _comInterfaceManager.GetTypeByName(varType.Name, varType.Namespace);
                }
            }

            if (!string.IsNullOrWhiteSpace(sequenceStep.RetryCounter?.CounterVariable))
            {
                string    variableName = ModuleUtils.GetVarNameByParamValue(sequenceStep.RetryCounter.CounterVariable);
                IVariable variable     = variableTree.GetVariable(variableName);
                // Argument不能作为遍历变量
                if (null == variable)
                {
                    ThrowIfVariableNotFound(variableName, sequenceStep);
                }
                else if (!ModuleUtils.IsPropertyParam(sequenceStep.RetryCounter.CounterVariable))
                {
                    Type      varType  = typeof(int);
                    ITypeData typeData = _comInterfaceManager.GetTypeByName(varType.Name, varType.Namespace);
                    variable.Type = typeData;
                }
            }
            if (null != sequenceStep.Function)
            {
                IFunctionData functionData = sequenceStep.Function;
                if (!string.IsNullOrWhiteSpace(functionData.Instance))
                {
                    SetVariableAndArgumentType(functionData.Instance, functionData.ClassType, variableTree, sequenceStep);
                }
                if (!string.IsNullOrWhiteSpace(functionData.Return))
                {
                    SetVariableAndArgumentType(functionData.Return, functionData.ReturnType.Type, variableTree, sequenceStep);
                }
                for (int i = 0; i < functionData.ParameterType.Count; i++)
                {
                    IParameterData parameterValue = functionData.Parameters[i];
                    if (parameterValue.ParameterType == ParameterType.Variable &&
                        !string.IsNullOrWhiteSpace(parameterValue.Value))
                    {
                        SetVariableAndArgumentType(parameterValue.Value, functionData.ParameterType[i].Type, variableTree,
                                                   sequenceStep);
                    }
                }
            }
            if (sequenceStep.HasSubSteps)
            {
                foreach (ISequenceStep subStep in sequenceStep.SubSteps)
                {
                    VerifyVariableTypes(subStep, variableTree);
                }
            }
        }