Beispiel #1
0
        // 改变StepData.Function.Parameters:如果是variable,则变为运行时$格式
        protected override void InitializeParamsValues()
        {
            IArgumentCollection      argumentInfos = Function.ParameterType;
            IParameterDataCollection parameters    = Function.Parameters;

            for (int i = 0; i < argumentInfos.Count; i++)
            {
                string paramValue = parameters[i].Value;
                if (parameters[i].ParameterType == ParameterType.Value)
                {
                    Params[i] = Context.TypeInvoker.CastConstantValue(argumentInfos[i].Type, paramValue);
                }
                else
                {
                    // 如果是变量,则先获取对应的Varaible变量,真正的值在运行时才更新获取
                    string    variableName = ModuleUtils.GetVariableNameFromParamValue(paramValue);
                    IVariable variable     = ModuleUtils.GetVaraibleByRawVarName(variableName, StepData);
                    if (null == variable)
                    {
                        Context.LogSession.Print(LogLevel.Error, SequenceIndex,
                                                 $"Unexist variable '{variableName}' in sequence data.");
                        throw new TestflowDataException(ModuleErrorCode.SequenceDataError,
                                                        Context.I18N.GetFStr("UnexistVariable", variableName));
                    }
                    // 将变量的值保存到Parameter中
                    string varFullName = CoreUtils.GetRuntimeVariableName(Context.SessionId, variable);
                    parameters[i].Value = ModuleUtils.GetFullParameterVariableName(varFullName, parameters[i].Value);
                    Params[i]           = null;
                }
            }
            //todo 做同步的时候再添加对返回值的处理,代码参照StepExecutionEntity的InitializeParamsValue
        }
Beispiel #2
0
        protected override void InitializeParamsValues()
        {
            IArgumentCollection      argumentInfos = Function.ParameterType;
            IParameterDataCollection parameters    = Function.Parameters;

            for (int i = 0; i < argumentInfos.Count; i++)
            {
                string paramValue = parameters[i].Value;
                switch (parameters[i].ParameterType)
                {
                case ParameterType.Value:
                    Params[i] = Context.TypeInvoker.CastConstantValue(argumentInfos[i].Type, paramValue);
                    break;

                case ParameterType.Variable:
                    // 如果是变量,则先获取对应的Varaible变量,真正的值在运行时才更新获取
                    string    variableName = ModuleUtils.GetVariableNameFromParamValue(paramValue);
                    IVariable variable     = ModuleUtils.GetVaraibleByRawVarName(variableName, StepData);
                    if (null == variable)
                    {
                        Context.LogSession.Print(LogLevel.Error, Context.SessionId,
                                                 $"Unexist variable '{variableName}' in sequence data.");
                        throw new TestflowDataException(ModuleErrorCode.SequenceDataError,
                                                        Context.I18N.GetFStr("UnexistVariable", variableName));
                    }
                    // 将变量的值保存到Parameter中
                    string varFullName = CoreUtils.GetRuntimeVariableName(Context.SessionId, variable);
                    parameters[i].Value = ModuleUtils.GetFullParameterVariableName(varFullName, parameters[i].Value);
                    Params[i]           = null;
                    break;

                default:
                    Context.LogSession.Print(LogLevel.Error, Context.SessionId,
                                             $"The value of parameter '{argumentInfos[i].Name}' is not configured");
                    throw new TestflowDataException(ModuleErrorCode.SequenceDataError,
                                                    Context.I18N.GetStr("InvalidParamVar"));
                    break;
                }
            }
            if (null != Function.ReturnType && CoreUtils.IsValidVaraible(Function.Return))
            {
                // 如果是变量,则先获取对应的Varaible变量,真正的值在运行时才更新获取
                string    variableName = ModuleUtils.GetVariableNameFromParamValue(Function.Return);
                IVariable variable     = ModuleUtils.GetVaraibleByRawVarName(variableName, StepData);
                if (null == variable)
                {
                    Context.LogSession.Print(LogLevel.Error, SequenceIndex,
                                             $"Unexist variable '{variableName}' in sequence data.");
                    throw new TestflowDataException(ModuleErrorCode.SequenceDataError,
                                                    Context.I18N.GetFStr("UnexistVariable", variableName));
                }
                ReturnVar = CoreUtils.GetRuntimeVariableName(Context.SessionId, variable);
            }
            CommonStepDataCheck(InstanceVar);
        }
Beispiel #3
0
        protected override void InitializeParamsValues()
        {
            string instanceVarName = null;

            if (!string.IsNullOrWhiteSpace(Function.Instance))
            {
                instanceVarName = ModuleUtils.GetVariableNameFromParamValue(Function.Instance);
                _instanceVar    = ModuleUtils.GetVariableFullName(instanceVarName, StepData, Context.SessionId);
            }
            IParameterDataCollection parameters = Function.Parameters;

            for (int i = 0; i < _properties.Count; i++)
            {
                string    paramValue = parameters[i].Value;
                IArgument argument   = Function.ParameterType[i];
                if (null == _properties[i] || string.IsNullOrEmpty(paramValue))
                {
                    _params.Add(null);
                    continue;
                }
                switch (parameters[i].ParameterType)
                {
                case ParameterType.NotAvailable:
                    _params.Add(null);
                    break;

                case ParameterType.Value:
                    _params.Add(Context.TypeInvoker.CastConstantValue(argument.Type,
                                                                      paramValue));
                    break;

                case ParameterType.Variable:
                    string variableRawName = ModuleUtils.GetVariableNameFromParamValue(paramValue);
                    string varFullName     = ModuleUtils.GetVariableFullName(variableRawName, StepData,
                                                                             Context.SessionId);
                    // 将parameter的Value中,变量名称替换为运行时变量名
                    parameters[i].Value = ModuleUtils.GetFullParameterVariableName(varFullName, paramValue);
                    _params.Add(null);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            CommonStepDataCheck(instanceVarName);
        }