コード例 #1
0
ファイル: CoreUtils.cs プロジェクト: spartajet/Testflow
        public static IVariable GetVariable(ISequence sequence, string runtimeVariable)
        {
            string[]            variableElement = runtimeVariable.Split(VarNameDelim.ToCharArray());
            IVariableCollection varCollection   = sequence.Variables;
            IVariable           variable        = varCollection.FirstOrDefault(item => item.Name.Equals(variableElement[variableElement.Length - 1]));

            if (null == variable)
            {
                varCollection = sequence.Parent is ISequenceGroup
                    ? ((ISequenceGroup)sequence.Parent).Variables
                    : ((ITestProject)sequence.Parent).Variables;
                variable = varCollection.FirstOrDefault(item => item.Name.Equals(variableElement[variableElement.Length - 1]));
            }
            return(variable);
        }
コード例 #2
0
ファイル: CoreUtils.cs プロジェクト: streamHe/Testflow-1
        public static IVariable GetVariable(ISequenceGroup sequenceGroup, string runtimeVariable)
        {
            string[]            variableElement = runtimeVariable.Split(VarNameDelim.ToCharArray());
            IVariableCollection varCollection   = null;

            if (2 == variableElement.Length)
            {
                varCollection = sequenceGroup.Variables;
            }
            else if (3 == variableElement.Length)
            {
                int sequenceIndex = int.Parse(variableElement[1]);
                if (sequenceIndex == CommonConst.SetupIndex)
                {
                    varCollection = sequenceGroup.SetUp.Variables;
                }
                else if (sequenceIndex == CommonConst.TeardownIndex)
                {
                    varCollection = sequenceGroup.TearDown.Variables;
                }
                else
                {
                    varCollection = sequenceGroup.Sequences[sequenceIndex].Variables;
                }
            }
            return(varCollection.FirstOrDefault(item => item.Name.Equals(variableElement[variableElement.Length - 1])));
        }
コード例 #3
0
ファイル: CoreUtils.cs プロジェクト: streamHe/Testflow-1
        public static IVariable GetVariable(ISequence sequence, string runtimeVariable)
        {
            string[]            variableElement = runtimeVariable.Split(VarNameDelim.ToCharArray());
            IVariableCollection varCollection   = sequence.Variables;

            return(varCollection.FirstOrDefault(item => item.Name.Equals(variableElement[variableElement.Length - 1])));
        }
コード例 #4
0
ファイル: CoreUtils.cs プロジェクト: streamHe/Testflow-1
        public static IVariable GetVariable(ITestProject testProject, string runtimeVariable)
        {
            string[]            variableElement = runtimeVariable.Split(VarNameDelim.ToCharArray());
            IVariableCollection varCollection   = null;

            if (2 == variableElement.Length)
            {
                varCollection = testProject.Variables;
            }
            else if (3 == variableElement.Length)
            {
                varCollection = variableElement[1].Equals(CommonConst.SetupIndex.ToString())?
                                testProject.SetUp.Variables : testProject.TearDown.Variables;
            }
            return(varCollection.FirstOrDefault(item => item.Name.Equals(variableElement[variableElement.Length - 1])));
        }
コード例 #5
0
        private IWarningInfo CheckPropertyType(IVariableCollection variables, string variableString, ITypeData checkType, bool overwriteType)
        {
            //split
            string[] str = variableString.Split('.');

            #region 寻找variable
            //找相同名字的variable
            IVariable variable = variables.FirstOrDefault(item => item.Name.Equals(str[0]));

            //没有此名的variable
            if (variable == null)
            {
                return(new WarningInfo()
                {
                    WarnCode = WarnCode.VariableDNE,
                    Infomation = $"Variable \"{variableString}\" does not exist."
                });
            }
            #endregion

            #region 寻找/赋予variable类型
            ITypeData type = variable.Type;

            #region 入参为varname.property1.property2
            //从varname中用模块取得属性type
            if (str.Length > 1)
            {
                type = _comInterfaceManager.GetPropertyType(type, variableString.Substring(variableString.IndexOf('.') + 1));

                //todo 万一没找到这个属性就要给warningInfo.对上面用trycatch?
            }
            #endregion

            #region 入参为varname
            else
            {
                //如果variable type为null,则赋checktype给它
                if (type == null && overwriteType)
                {
                    type = checkType;
                }
            }
            #endregion

            #endregion

            #region 比较类型
            if (type == null)
            {
                return(new WarningInfo()
                {
                    WarnCode = WarnCode.TypeInvalid,
                    Infomation = $"Variable {variableString} has Type null . Different from Type \"{checkType.Name}\" . May cause issues during runtime."
                });
            }
            else if (!type.Equals(checkType))
            {
                return(new WarningInfo()
                {
                    WarnCode = WarnCode.TypeInvalid,
                    Infomation = $"Variable {variableString} Type \"{type.Name}\" different from Type \"{checkType.Name}\". May cause issues during runtime."
                });
            }
            #endregion

            #region //检查值
            //#region 空值或不为VariableType.Value
            //if (String.IsNullOrEmpty(variable.Value) || variable.VariableType != VariableType.Value)
            //{

            //}
            //#endregion
            //#region 有值且VariableType.Value
            //else
            //{
            //    if (!Convertor.ValueConvertor.CheckValue(checkType.Name, variable.Value))
            //    {
            //        return new WarningInfo()
            //        {
            //            WarnCode = WarnCode.TypeInvalid,
            //            Infomation = $"Variable {variableString} data type and its value invalid."
            //        };
            //    }
            //}
            //#endregion
            ////如果变量是值类型,
            ////检查值是否与类型相符
            //if (variable.VariableType == VariableType.Value)
            //{

            //}

            //todo 判断variable如果是类类型,value实例是否跟type相符
            //if()
            #endregion

            return(null);
        }