Пример #1
0
 /// <summary>
 /// 请在UI资源被释放前,释放CaseTreeActionControl
 /// </summary>
 public void Dispose()
 {
     if (ActionActuator != null)
     {
         if (ActionActuator.MyCaseTreeAction != null)
         {
             ActionActuator.MyCaseTreeAction.OnCaseTreeChange -= MyCaseTreeAction_OnCaseTreeChange;
         }
         ActionActuator = null;
     }
 }
Пример #2
0
        public void TestMethod1()
        {
            CaseActionActuator myCAA = new CaseActionActuator();
            Type t = myCAA.GetType();

            foreach (System.Reflection.MemberInfo mi in t.GetMembers(BindingFlags.NonPublic))
            {
                Console.WriteLine("{0}/{1}", mi.MemberType, mi.Name);
            }

            Assert.IsTrue(true);
        }
Пример #3
0
 /// <summary>
 /// CaseRunner构造函数(用于克隆当前对象)
 /// </summary>
 /// <param name="yourNmae">用户标识名</param>
 /// <param name="yourCaseActuator">克隆需要的深度复制的新执行器</param>
 private CaseRunner(string yourNmae, CaseActionActuator yourCaseActuator)
 {
     runnerName = yourNmae;
     yourCaseActuator.MyName = yourNmae;
     runerActuator           = yourCaseActuator;
     runerActuator.OnActuatorStateChanged += runerActuator_OnActuatorStateChanged;
     runerActuator.OnExecutiveResult      += runerActuator_OnExecutiveResult;
     runerProgressBar = new ProgressBarList();
     runnerButton     = new PlayButton();
     runnerButton.ButtonSetClickEvent     += runnerButton_ButtonSetClickEvent;
     runnerButton.ButtonOutClickEvent     += runnerButton_ButtonOutClickEvent;
     runnerButton.ButtonDelClickEvent     += runnerButton_ButtonDelClickEvent;
     runnerButton.ButtonStateChangedEvent += runnerButton_ButtonStateChangedEvent;
 }
Пример #4
0
 /// <summary>
 /// CaseRunner构造函数
 /// </summary>
 /// <param name="yourNmae">用户标识名</param>
 public CaseRunner(string yourNmae)
 {
     runnerName     = yourNmae;
     runnerCasePath = "";
     runerActuator  = new CaseActionActuator(yourNmae);
     runerActuator.OnActuatorStateChanged += runerActuator_OnActuatorStateChanged;
     runerActuator.OnExecutiveResult      += runerActuator_OnExecutiveResult;
     runerProgressBar = new ProgressBarList();
     runnerButton     = new PlayButton();
     runnerButton.ButtonSetClickEvent     += runnerButton_ButtonSetClickEvent;
     runnerButton.ButtonOutClickEvent     += runnerButton_ButtonOutClickEvent;
     runnerButton.ButtonDelClickEvent     += runnerButton_ButtonDelClickEvent;
     runnerButton.ButtonStateChangedEvent += runnerButton_ButtonStateChangedEvent;
 }
Пример #5
0
        private bool AnalysisXmlCase(string myCasePath, CaseActionActuator caseActuator, Hashtable checkDataHt, bool isWithSouseXml, out string errorMessage, out List <string> loadErrorList)
        {
            bool tempIsScriptRunTimeDeal = false;

            errorMessage  = null;
            loadErrorList = new List <string>();
            CaseFileXmlAnalysis xmlAnalysis = new CaseFileXmlAnalysis();

            if (caseActuator == null)
            {
                return(false);
            }
            if (caseActuator.Runstate != CaseActuatorState.Stop)
            {
                errorMessage = "The TestCase not stop";
                return(false);
            }
            if (!File.Exists(myCasePath))
            {
                errorMessage = "用例文件不存在,请重新选择";
                return(false);
            }
            if (!xmlAnalysis.LoadFile(myCasePath))
            {
                errorMessage = "该脚本数据格式错误,请修正错误。详情请查看错误日志";
                return(false);
            }

            XmlNodeList myCaseProject = xmlAnalysis.xml.ChildNodes[1].ChildNodes;

            #region check case data
            if (checkDataHt != null)
            {
                foreach (DictionaryEntry de in checkDataHt)
                {
                    string tempStr = CaseTool.CheckCase(xmlAnalysis.xml.ChildNodes[1], (string)de.Key, (string[])de.Value);
                    if (tempStr != "")
                    {
                        errorMessage = tempStr;
                        return(false);
                    }
                }
            }
            #endregion

            Dictionary <int, Dictionary <int, CaseCell> > myProjectCaseDictionary = new Dictionary <int, Dictionary <int, CaseCell> >();

            caseActuator.DisconnectExecutionDevice();
            caseActuator.Dispose();

            ProjctCollection myProjctCollection = new ProjctCollection();
            try
            {
                #region Project analyze

                foreach (XmlNode tempNode in myCaseProject)
                {
                    myCaseLaodInfo tempProjectLoadInfo = MyCaseScriptAnalysisEngine.GetCaseLoadInfo(tempNode);
                    string         thisErrorTitle      = "Project ID:" + tempProjectLoadInfo.id;
                    if (tempProjectLoadInfo.ErrorMessage != "")
                    {
                        loadErrorList.Add(string.Format("【{1}】:{0}", tempProjectLoadInfo.ErrorMessage, thisErrorTitle));
                    }
                    if (tempProjectLoadInfo.caseType == CaseType.ScriptRunTime)
                    {
                        //deal with ScriptRunTime
                        if (!tempIsScriptRunTimeDeal)
                        {
                            caseActuator.LoadScriptRunTime(tempNode);
                            tempIsScriptRunTimeDeal = true;
                        }
                        else
                        {
                            thisErrorTitle = "ScriptRunTime";
                            loadErrorList.Add(string.Format("【{1}】:{0}", "find another ScriptRunTime ,ScriptRunTime is unique so it will be skip", thisErrorTitle));
                        }
                        continue;
                    }
                    if (tempProjectLoadInfo.caseType != CaseType.Project)
                    {
                        loadErrorList.Add(string.Format("【{1}】:{0}", "not legal Project ,it will be skip", "legal"));
                        continue;
                    }

                    #region deal this Project

                    CaseCell tempProjctCell = new CaseCell(tempProjectLoadInfo.caseType, tempNode, null);
                    myProjctCollection.Add(tempProjctCell);

                    Dictionary <int, CaseCell> tempCaseDictionary = new Dictionary <int, CaseCell>();
                    if (myProjectCaseDictionary.ContainsKey(tempProjectLoadInfo.id))
                    {
                        loadErrorList.Add(string.Format("【{1}】:{0}", "find the same project id in this file ,it will make [Goto] abnormal", thisErrorTitle));
                    }
                    else
                    {
                        myProjectCaseDictionary.Add(tempProjectLoadInfo.id, tempCaseDictionary);
                    }

                    //myTargetCaseList 将包含当前project或repeat集合元素
                    List <KeyValuePair <CaseCell, XmlNode> > myTargetCaseList = new List <KeyValuePair <CaseCell, XmlNode> >();
                    myTargetCaseList.Add(new KeyValuePair <CaseCell, XmlNode>(tempProjctCell, tempNode));
                    while (myTargetCaseList.Count > 0)
                    {
                        //Case analyze
                        foreach (XmlNode tempChildNode in myTargetCaseList[0].Value)
                        {
                            //load Show Info
                            myCaseLaodInfo tempCaseLoadInfo = MyCaseScriptAnalysisEngine.GetCaseLoadInfo(tempChildNode);
                            thisErrorTitle = "Case ID:" + tempCaseLoadInfo.id;
                            if (tempCaseLoadInfo.ErrorMessage != "")
                            {
                                loadErrorList.Add(string.Format("【{1}】:{0}", tempCaseLoadInfo.ErrorMessage, thisErrorTitle));
                                loadErrorList.Add(string.Format("【{1}】:{0}", "this error can not be repair so drop it", thisErrorTitle));
                            }
                            else
                            {
                                if (tempCaseLoadInfo.caseType == CaseType.Case)
                                {
                                    //load Run Data
                                    var tempCaseRunData = MyCaseScriptAnalysisEngine.GetCaseRunData(tempChildNode);
                                    if (tempCaseRunData.errorMessages != null)
                                    {
                                        foreach (string tempErrorMes in tempCaseRunData.errorMessages)
                                        {
                                            loadErrorList.Add(string.Format("【{1}】:{0}", tempErrorMes, thisErrorTitle));
                                        }
                                    }
                                    CaseCell tempChildCell = new CaseCell(tempCaseLoadInfo.caseType, tempChildNode, tempCaseRunData);
                                    if (tempCaseDictionary.ContainsKey(tempCaseLoadInfo.id))
                                    {
                                        loadErrorList.Add(string.Format("【{1}】:{0}", "find the same case id in this project ,it will make [Goto] abnormal", thisErrorTitle));
                                    }
                                    else
                                    {
                                        tempCaseDictionary.Add(tempCaseLoadInfo.id, tempChildCell);
                                    }
                                    myTargetCaseList[0].Key.Add(tempChildCell);
                                }
                                else if (tempCaseLoadInfo.caseType == CaseType.Repeat)
                                {
                                    CaseCell tempChildCell = new CaseCell(tempCaseLoadInfo.caseType, tempChildNode, null);

                                    myTargetCaseList[0].Key.Add(tempChildCell);
                                    myTargetCaseList.Add(new KeyValuePair <CaseCell, XmlNode>(tempChildCell, tempChildNode));
                                }
                                else
                                {
                                    //it will cant be project and if it is unknow i will not show it
                                    loadErrorList.Add(string.Format("【{1}】:{0}", "find unkown case so drop it", thisErrorTitle));
                                }
                            }
                        }
                        myTargetCaseList.Remove(myTargetCaseList[0]);
                    }
                    #endregion
                }
                #endregion

                if (!tempIsScriptRunTimeDeal)
                {
                    loadErrorList.Add(string.Format("【{1}】:{0}", "ScriptRunTime is not find ", "ScriptRunTime"));
                    errorMessage = "ScriptRunTime is not find ,the case will cannot run";
                    return(false);
                }
                else
                {
                    caseActuator.SetCaseRunTime(myProjectCaseDictionary, myProjctCollection);
                    //启动数据呈现
                    return(true);
                }
            }
            //严重错误
            catch (Exception ex)
            {
                ErrorLog.PutInLog(ex);
                errorMessage = ex.Message;
                caseActuator.DisconnectExecutionDevice();
                caseActuator.Dispose();
                return(false);
            }
        }
Пример #6
0
 public myNewTestInfo(MyCaseRunTime yourRunTime, CaseActionActuator yourActuator)
 {
     caseRunTime    = yourRunTime;
     actionActuator = yourActuator;
 }
Пример #7
0
 public CaseTreeActionControl(CaseActionActuator yourActionActuator)
 {
     yourActionActuator.MyCaseTreeAction.OnCaseTreeChange += MyCaseTreeAction_OnCaseTreeChange;
     ActionActuator = yourActionActuator;
 }