Esempio n. 1
0
        public static void InitTestStepInfo()
        {
            List <TestStepInfo> stepInfoList = new List <TestStepInfo>();

            getTypeFromAssemble();
            foreach (var type in StepTypelist)
            {
                Assembly assembly  = Assembly.LoadFile(type.AssemblyPath);
                string   str       = type.Type.FullName;
                Type     modelType = assembly.GetType(str);
                TestStep step      = Activator.CreateInstance(modelType) as TestStep;
                if (step != null)
                {
                    TestStepInfo stepInfo = new TestStepInfo()
                    {
                        Assembly             = assembly,
                        TypeName             = step.GetType().Name,
                        StepType             = step.GetType(),
                        DisplayName          = type.Att.DisplayName,
                        TestStepViewModelStr = type.Att.StepTypeStr,
                        AdvUserControlStr    = type.Att.UserControlType,
                        TestTraceTypeList    = step.ItemTypeNameList,
                        IsFixedItem          = type.Att.IsFixedItem
                    };
                    if (step.SupportedMeasClsInfoList != null)
                    {
                        stepInfo.MeasClsInfoList = step.SupportedMeasClsInfoList.ToList();
                    }
                    stepInfoList.Add(stepInfo);
                    if (step.LocalSettingTypeList != null)
                    {
                        foreach (var itemType in step.LocalSettingTypeList)
                        {
                            if (!localSettingTypelist.Contains(itemType))
                            {
                                localSettingTypelist.Add(itemType);
                            }
                        }
                    }
                }
            }
            stepInfoList.Add(new TestStepInfo()
            {
                TypeName = "FormulaCalcTestStep", DisplayName = TestStepType.Cal
            });
            stepInfoList.Add(new TestStepInfo()
            {
                TypeName = "LoopTestStep", DisplayName = TestStepType.Loop
            });
            stepInfoList.Add(new TestStepInfo()
            {
                TypeName = "ManualLoopTestStep", DisplayName = TestStepType.Manual
            });

            TestStepInfoMgr.Instance.TestStepInfoList = stepInfoList.ToArray();
            TestStepInfoMgr.Instance.LoadInstruInfoFromFile();
        }
Esempio n. 2
0
        /// <summary>
        /// 获得step的ViewModel,如果在测试步骤信息中指定的ViewModel,使用该ViewModel,否则使用基类ViewModel
        /// </summary>
        /// <param name="step"></param>
        /// <returns></returns>
        public static TestStepVM GetTestStepVM(TestStep step)
        {
            if (ViewModelDict.Keys.Contains(step))
            {
                return(ViewModelDict[step] as TestStepVM);
            }
            else
            {
                TestStepVM vm     = GetViewModelFromModel(step.GetType()) as TestStepVM;
                TestStepVM vm2    = GetStepViewModelFromModel(step.GetType()) as TestStepVM;
                TestStepVM vmReal = new TestStepVM();
                if (vm != null)
                {
                    vm.TestStep = step;
                    vmReal      = vm;
                }
                else if (vm2 != null)
                {
                    vm2.TestStep = step;
                    vmReal       = vm2;
                }
                else
                {
                    vmReal          = new TestStepVM();
                    vmReal.TestStep = step;
                }
                ViewModelDict.Add(step, vmReal);
                return(vmReal);
                //if (vm != null)
                //{
                //    vm.TestStep = step;
                //    //vm.DisplayName = GetStepTypeName(step.GetType());
                //    ViewModelDict.Add(step, vm);
                //}
                //else if(vm2 !=null)
                //{
                //    vm2.TestStep = step;
                //    ViewModelDict.Add(step,vm2);
                //}
                //else
                //{
                //    vm = new TestStepVM();
                //    vm.TestStep = step;
                //    ViewModelDict.Add(step, null);
                //    //vm.DisplayName = GetStepTypeName(step.GetType());
                //}

                //return vm;
            }
        }
 public void Execute()
 {
     try
     {
         if (null != TestStep)
         {
             Logger.TestStepStart(TestStep.GetType().ToString(), DateTime.Now, true, TestStep.FailOnError);
             var step = TestStep as ImportTestCaseStep;
             if (step != null)
             {
                 ExecuteImportedTestCase(step, _context);
             }
             else
             {
                 TestStep.Execute(_context);
             }
         }
         else
         {
             Logger.TestStepStart(StepWrapper.TypeName, DateTime.Now, true, StepWrapper.FailOnError);
             StepWrapper.Execute(_context);
         }
     }
     catch (Exception e)
     {
         Logger.LogException(e);
         FailureException = e;
     }
 }
 public void Execute()
 {
     try
     {
         if (null != TestStep)
         {
             _logger.TestStepStart(TestStep.GetType().ToString(), DateTime.Now, true, TestStep.FailOnError);
             if (TestStep is ImportTestCaseStep)
             {
                 ExecuteImportedTestCase(TestStep as ImportTestCaseStep, _context);
             }
             else
             {
                 TestStep.Execute(_context);
             }
         }
     }
     catch (Exception e)
     {
         _logger.LogException(e);
         FailureException = e;
     }
 }
Esempio n. 5
0
        public static TestStepVM GetTestStepVMFromViewModel(TestStep step)
        {
            if (ViewModelDict.Keys.Contains(step))
            {
                return(ViewModelDict[step] as TestStepVM);
            }
            else
            {
                TestStepVM vm = GetViewModelFromModel(step.GetType()) as TestStepVM;
                if (vm != null)
                {
                    vm.TestStep = step;
                    ViewModelDict.Add(step, vm);
                }
                else
                {
                    vm          = new TestStepVM();
                    vm.TestStep = step;
                    ViewModelDict.Add(step, vm);
                }

                return(vm);
            }
        }
Esempio n. 6
0
        public static object GetStepUserControlFromModel(TestStep step)
        {
            var    stepInfo = TestStepInfoMgr.Instance.TestStepInfoList.Where(x => x.TypeName == step.GetType().Name).FirstOrDefault();
            object obj      = null;

            if (stepInfo != null)
            {
                if (stepInfo.AdvUserControlStr == null || string.IsNullOrWhiteSpace(stepInfo.AdvUserControlStr))
                {
                    return(obj);
                }
                string   userControlStr = stepInfo.AdvUserControlStr;
                string[] strs           = userControlStr.Split(';');
                string   fileName       = AppDomain.CurrentDomain.BaseDirectory + strs[0];
                userControlStr = userControlStr.Remove(0, strs[0].Length + 1);
                Assembly ass             = Assembly.LoadFile(fileName);
                Type     userControlType = ass.GetType(userControlStr);
                obj = Activator.CreateInstance(userControlType);
            }
            return(obj);
        }
Esempio n. 7
0
        private PropertyInfo GetProperty(Type t)
        {
            var propertiesInfo = TestStep.GetType().GetProperties();

            return(propertiesInfo.FirstOrDefault(propertyInfo => t == propertyInfo.PropertyType));
        }
Esempio n. 8
0
        private void AddUCLocalSetting(TestStep step, string displayName)
        {
            var item = TestStepInfoMgr.Instance.TestStepInfoList.Where(x => x.StepType == step.GetType()).Select(x => x.LocalSettingViewStr).FirstOrDefault();
            var temp = TestStepInfoMgr.Instance.TestStepInfoList.Where(x => x.StepType == step.GetType());

            if (item != null)
            {
                string      folderName = AppDomain.CurrentDomain.BaseDirectory;
                string[]    strs       = item.Split(';');
                string      fullName   = folderName + strs[0];
                Assembly    assembly   = Assembly.LoadFile(fullName);
                Type        modelType  = assembly.GetType(strs[1]);
                object      obj        = Activator.CreateInstance(modelType) as object;
                UserControl uc         = obj as UserControl;
                uc.DataContext = step;
                if (uc != null)
                {
                    UCLocalSetting ucLocalSetting = new UCLocalSetting()
                    {
                        StepDisplayName = displayName, UserControl = uc, DisplayName = displayName + "         " + step.PathConfigName
                    };
                    uCLocalSettingList.Add(ucLocalSetting);
                }
            }
        }