Пример #1
0
        public SequenceCreator()
        {
            TestflowRunner testflowRunner = TestflowRunner.GetInstance();

            _sequenceManager = testflowRunner.SequenceManager;
            IComInterfaceManager interfaceManager = testflowRunner.ComInterfaceManager;

            Type   testClassType = typeof(CoreTestClass);
            string location      = testClassType.Assembly.Location;
            IComInterfaceDescription interfaceDescription = interfaceManager.GetComponentInterface(location);

            Type intType = typeof(int);

            _intTypeData = interfaceManager.GetTypeByName(intType.Name, intType.Namespace);

            Type testCallBackType = typeof(CallBackClass);

            //同一个程序集,不需要再一次加载component
            //location = testClassType.Assembly.Location;
            //interfaceDescription = interfaceManager.GetComponentInterface(location);

            _testClassTypeData    = interfaceManager.GetTypeByName(testClassType.Name, testClassType.Namespace);
            _testCallBackTypeData = interfaceManager.GetTypeByName(testCallBackType.Name, testCallBackType.Namespace);
        }
Пример #2
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);
                }
            }
        }