Example #1
0
        /// <summary>
        /// 获取参数列表
        /// </summary>
        /// <returns></returns>
        public static Dictionary <string, string> getCustomParamet(this testCase _testCaseModel)
        {
            Dictionary <string, string> Paramets = new Dictionary <string, string>();

            Regex reg = new Regex("{.*?}");

            //获得定义的变量
            foreach (var step in _testCaseModel.steps)
            {
                if (step.attrs == null)
                {
                    continue;
                }
                foreach (var attr in step.attrs)
                {
                    if (attr.Value == null)
                    {
                        continue;
                    }
                    MatchCollection matches = reg.Matches(attr.Value); // 在字符串中匹配
                    foreach (Match match in matches)
                    {
                        string name = match.Value.Substring(1, match.Value.Count() - 2);
                        //确认没有重复的参数
                        if (!Paramets.ContainsKey(name))
                        {
                            Paramets.Add(name, "");
                        }
                    }
                }
            }

            return(Paramets);
        }
Example #2
0
        /// <summary>
        /// 替换block节点
        /// </summary>
        public static void blockChannge(this testCase _testCaseModel, blockPlayDBContext db)
        {
            var blocksteps = _testCaseModel.steps.Where(t => t.blockID > 0).ToList();

            foreach (var bs in blocksteps)
            {
                var _blockstep = db.BlockStep.FirstOrDefault(t => t.Id == bs.blockID);

                var insertSteps = _blockstep.blockSteps();
                setAttrs(insertSteps, bs.attrs);

                var index = _testCaseModel.steps.IndexOf(bs);
                _testCaseModel.steps.Remove(bs);
                _testCaseModel.steps.InsertRange(index, insertSteps);
            }
        }
Example #3
0
        public static void ConvertForRun(this testCase _testCaseModel, blockPlayDBContext db, Dictionary <string, string> attrs)
        {
            setAttrs(_testCaseModel.steps, attrs);

            _testCaseModel.blockChannge(db);
        }
Example #4
0
 public static string toBodyString(this testCase _testCaseModel)
 {
     return(JsonConvert.SerializeObject(_testCaseModel));
 }