Exemple #1
0
        private IWarningInfo FindVariablesCheckPropertyType(ISequenceFlowContainer[] arr, string variableString, ITypeData CheckType, bool overwriteType)
        {
            IWarningInfo warnInfo = null;

            foreach (ISequenceFlowContainer cont in arr)
            {
                warnInfo = CheckPropertyType(cont, variableString, CheckType, overwriteType);
                //表示没有错误信息,成功找到variable并通过
                if (warnInfo == null)
                {
                    return(null);
                }
                //表示找到variable并且type不合
                if (warnInfo.WarnCode == WarnCode.TypeInvalid)
                {
                    return(warnInfo);
                }
                //表示没找到Variable,继续循环去找
                if (warnInfo.WarnCode == WarnCode.VariableDNE)
                {
                    //continue;
                }
            }
            //最终还是没找到
            return(warnInfo);
        }
Exemple #2
0
        public IList <IWarningInfo> CheckStep(ISequenceStep Step, ISequenceFlowContainer[] arr, bool overwriteType)
        {
            IList <IWarningInfo> warningList = new List <IWarningInfo>();
            IFunctionData        function    = Step.Function;

            #region 空function, 空step
            if (function == null)
            {
                return(warningList);
            }
            #endregion

            IWarningInfo warnInfo = null;

            #region Instance
            warnInfo = CheckInstance(Step, arr, overwriteType);
            if (warnInfo != null)
            {
                warningList.Add(warnInfo);
            }
            #endregion

            #region Return
            warnInfo = CheckReturn(Step, arr, overwriteType);
            if (warnInfo != null)
            {
                warningList.Add(warnInfo);
            }
            #endregion

            #region Parameters
            if (function.Parameters == null)
            {
            }
            else
            {
                for (int n = 0; n < function.Parameters.Count; n++)
                {
                    warnInfo = CheckParameterData(function, n, arr, overwriteType);
                    if (warnInfo != null)
                    {
                        warningList.Add(warnInfo);
                    }
                }
            }
            #endregion

            foreach (IWarningInfo info in warningList)
            {
                info.SequenceStep = Step;
            }

            return(warningList);
        }
Exemple #3
0
        //todo I18n
        public IWarningInfo CheckVariableValue(ISequenceFlowContainer parent, string name)
        {
            IVariable variable;

            #region TestProject
            if (parent is ITestProject)
            {
                variable = ((ITestProject)parent).Variables.FirstOrDefault(item => item.Name.Equals(name));
                if (variable == null)
                {
                    throw new TestflowDataException(ModuleErrorCode.VariableNotFound, $"Variable {name} not found in TestProject {parent.Name}");
                }
                IWarningInfo warnInfo = CheckVariableValue(variable);
                if (warnInfo != null)
                {
                    warnInfo.SequenceGroup = null;
                    warnInfo.Sequence      = null;
                }

                return(warnInfo);
            }
            #endregion

            #region SequenceGroup
            else if (parent is ISequenceGroup)
            {
                variable = ((ISequenceGroup)parent).Variables.FirstOrDefault(item => item.Name.Equals(name));
                if (variable == null)
                {
                    throw new TestflowDataException(ModuleErrorCode.VariableNotFound, $"Variable {name} not found in SequenceGroup {parent.Name}");
                }
                IWarningInfo warnInfo = CheckVariableValue(variable);
                if (warnInfo != null)
                {
                    warnInfo.SequenceGroup = (ISequenceGroup)parent;
                    warnInfo.Sequence      = null;
                }
                return(warnInfo);
            }
            #endregion

            #region Sequence
            else if (parent is ISequence)
            {
                variable = ((ISequence)parent).Variables.FirstOrDefault(item => item.Name.Equals(name));
                if (variable == null)
                {
                    throw new TestflowDataException(ModuleErrorCode.VariableNotFound, $"Variable {name} not found in Sequence {parent.Name}");
                }
                IWarningInfo warnInfo = CheckVariableValue(variable);
                if (warnInfo != null)
                {
                    warnInfo.SequenceGroup = (ISequenceGroup)((ISequence)parent).Parent;
                    warnInfo.Sequence      = (ISequence)parent;
                }
                return(warnInfo);
            }
            #endregion

            else
            {
                throw new TestflowDataException(ModuleErrorCode.InvalidParent, "Parent must be ITestProject, ISequenceGroup, or ISequence");
            }
        }