コード例 #1
0
 public override void Single()
 {
     if (ColumnTable == null)
     {
         return;
     }
     foreach (LoopTestItem item in ItemList)
     {
         item.ItemResult.Rows.Clear();
     }
     for (int i = 0; i < ColumnTable.Rows.Count; i++)
     {
         SelectedIndex = i;
         System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(ShowWindow));
         if (SelectedIndex > i)
         {
             break;
         }
         i = SelectedIndex;
         List <object> RowValuelist = new List <object>();
         for (int k = 0; k < ColumnTable.Columns.Count; k++)
         {
             RowValuelist.Add(ColumnTable.Rows[SelectedIndex][k]);
         }
         foreach (var childStep in ChildTestStepList)
         {
             if (GetRunState() == false)
             {
                 return;
             }
             childStep.Single();
             if (childStep is ManualLoopTestStep)
             {
                 for (int j = 0; j < childStep.ItemList.Count; j++)
                 {
                     LoopTestItem childStepItem = childStep.ItemList[j] as LoopTestItem;
                     LoopTestItem item          = GetItem(childStepItem.TestStepName, childStepItem.ItemIndex);
                     foreach (DataRow itemrow in childStepItem.ItemResult.Rows)
                     {
                         List <object> resList = new List <object>();
                         resList.AddRange(RowValuelist);
                         resList.AddRange(itemrow.ItemArray);
                         item.ItemResult.Rows.Add(resList.ToArray());
                     }
                 }
             }
             else
             {
                 for (int j = 0; j < childStep.ItemList.Count; j++)
                 {
                     LoopTestItem item          = GetItem(childStep.Name, j);
                     TestItem     childStepItem = childStep.ItemList[j];
                     if (childStepItem is PointTestItem)
                     {
                         List <object> reslist = new List <object>();
                         reslist.AddRange(RowValuelist);
                         reslist.Add((childStepItem as PointTestItem).Y);
                         item.ItemResult.Rows.Add(reslist.ToArray());
                     }
                     if (childStepItem is TestTrace)
                     {
                         foreach (var pRes in (childStepItem as TestTrace).ResultData)
                         {
                             List <object> reslist = new List <object>();
                             reslist.AddRange(RowValuelist);
                             reslist.Add(pRes.Y);
                             item.ItemResult.Rows.Add(reslist.ToArray());
                         }
                     }
                 }
             }
             if (UpdateChildTestStep != null && childStep as LoopTestStep != null && childStep.ItemList.Count() > 0)
             {
                 UpdateChildTestStep.Invoke(childStep.Name);
             }
         }
     }
     if (UpdateChildTestStep != null)
     {
         UpdateChildTestStep.Invoke("");
     }
 }
コード例 #2
0
        public override void Single()
        {
            //foreach row in datatable
            //set property of childTestStep from this row
            //childStep.Single
            //get childSteps itemvalue
            //set item of parent step
            if (Table == null)
            {
                return;
            }
            Steplist.Clear();
            GetValidTestStep(this);
            //InitTestItem();
            foreach (LoopTestItem item in ItemList)
            {
                item.ItemResult.Rows.Clear();
            }

            foreach (DataRow row in Table.Rows)
            {
                //set all desendent childStep property
                var           paramInfoList  = CacheParamInfoList.Where(x => x.IsChecked);
                List <object> paramValueList = new List <object>();
                if (paramInfoList != null)
                {
                    int aa = paramInfoList.Count();
                    foreach (var paramInfo in paramInfoList)
                    {
                        var allchildstep = Steplist.Where(x => x.Name == paramInfo.TestStepName).FirstOrDefault();
                        if (allchildstep != null)
                        {
                            var propInfo   = allchildstep.GetType().GetProperty(paramInfo.PropertyName);
                            var paramValue = row[paramInfo.DisplayName];
                            if (string.IsNullOrWhiteSpace(paramValue.ToString()))
                            {
                                TestStep step = this;
                                if (UpdateChildTestStep != null)
                                {
                                    UpdateChildTestStep.Invoke("");
                                }
                                return;
                            }
                            propInfo.SetValue(allchildstep, paramValue);
                            // zyl add below
                            var bindParam = CacheParamInfoList.Where(x => x.IsChecked == false && x.SelectedLoopParamInfo != null && x.SelectedLoopParamInfo.DisplayName == paramInfo.DisplayName);
                            if (bindParam != null)
                            {
                                foreach (var param in bindParam)
                                {
                                    var allChildstep2 = Steplist.Where(x => x.Name == param.TestStepName).FirstOrDefault();
                                    if (allChildstep2 != null)
                                    {
                                        var propInfo2 = allChildstep2.GetType().GetProperty(param.PropertyName);
                                        propInfo2.SetValue(allChildstep2, paramValue);
                                    }
                                }
                            }
                        }
                        paramValueList.Add(row[paramInfo.DisplayName]);
                    }
                }
                //single all direct child steps
                foreach (var childstep in ChildTestStepList)
                {
                    if (GetRunState() == false)
                    {
                        return;
                    }
                    childstep.Single();
                    DataUtils.LOGINFO.WriteLog(DateTime.Now.ToString() + childstep.DisplayName + " single finish");
                    if (paramValueList.Count == 0)
                    {
                        continue;
                    }
                    if (childstep is LoopTestStep)
                    {
                        for (int i = 0; i < childstep.ItemList.Count; i++)
                        {
                            LoopTestItem childStepItem = childstep.ItemList[i] as LoopTestItem;
                            LoopTestItem item          = GetItem(childStepItem.TestStepName, childStepItem.ItemIndex);
                            foreach (DataRow itemrow in childStepItem.ItemResult.Rows)
                            {
                                List <object> resList = new List <object>();
                                resList.AddRange(paramValueList);
                                resList.AddRange(itemrow.ItemArray);
                                item.ItemResult.Rows.Add(resList.ToArray());
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < childstep.ItemList.Count; i++)
                        {
                            LoopTestItem item          = GetItem(childstep.Name, i);
                            TestItem     childStepItem = childstep.ItemList[i];
                            if (childStepItem is PointTestItem)
                            {
                                List <object> resList = new List <object>();
                                resList.AddRange(paramValueList);
                                resList.Add((childStepItem as PointTestItem).Y);
                                item.ItemResult.Rows.Add(resList.ToArray());
                            }
                            if (childStepItem is TestTrace)
                            {
                                foreach (var pRes in (childStepItem as TestTrace).ResultData)
                                {
                                    List <object> resList = new List <object>();
                                    resList.AddRange(paramValueList);
                                    resList.Add(pRes.X);
                                    resList.Add(pRes.Y);
                                    item.ItemResult.Rows.Add(resList.ToArray());
                                }
                            }
                        }
                    }
                    if (UpdateChildTestStep != null && childstep as LoopTestStep != null && childstep.ItemList.Count() > 0)
                    {
                        UpdateChildTestStep.Invoke(childstep.Name);
                    }
                }
            }
            if (UpdateChildTestStep != null)
            {
                UpdateChildTestStep.Invoke("");
            }
        }