internal void SetCaseNodeContentWarning(CaseCell yourCell) { if (yourCell != null && OnCaseTreeChange != null) { this.OnCaseTreeChange(yourCell, null, CaseTreeActionType.CaseNodeContentWarning); } }
/// <summary> /// 进行下一个loop刷新/清除当前loop的节点执行结果(最后的loop请不要调用该方法) /// </summary> /// <param name="yourCell">CaseCell</param> internal void SetCaseNodeLoopRefresh(CaseCell yourCell) { if (yourCell != null && OnCaseTreeChange != null) { this.OnCaseTreeChange(yourCell, null, CaseTreeActionType.CaseNodeLoopRefresh); } }
/// <summary> /// 为TreeNode添加额外运行时消息以表示loop的变化(额外消息原则上为【···】这种格式或者为空"",处理时替换原有【···】,如果没有则直接添加) /// </summary> /// <param name="yourCell">CaseCell</param> /// <param name="yourMessage">Message (请务必保证数据为【···】这种格式,或为空"")</param> internal void SetCaseNodeLoopChange(CaseCell yourCell, string yourMessage) { if (yourCell != null && OnCaseTreeChange != null) { this.OnCaseTreeChange(yourCell, new CaseTreeActionEventArgs(yourMessage), CaseTreeActionType.CaseNodeLoopChange); } }
internal void SetCaseNodePause(CaseCell yourCell) { if (yourCell != null && OnCaseTreeChange != null) { this.OnCaseTreeChange(yourCell, null, CaseTreeActionType.CaseNodePause); } }
/// <summary> /// i will report the QueueAction to his user /// </summary> /// <param name="yourTarget">your CaseCell Target</param> /// <param name="yourMessage">your Message</param> private void ReportQueueAction(CaseCell yourTarget, string yourMessage) { if (OnQueueChangeEvent != null) { OnQueueChangeEvent(yourTarget, yourMessage); } }
/// <summary> /// i will trigger 【OnLoopChangeEvent】 and this lood is end /// </summary> /// <param name="yourTarget"></param> private void ReportLoopEnd(CaseCell yourTarget) { if (OnLoopChangeEvent != null) { this.OnLoopChangeEvent(yourTarget.ParentCell, ""); } }
/// <summary> /// i will trigger 【OnLoopChangeEvent】 /// </summary> /// <param name="yourTarget"></param> private void ReportLoopProgress(CaseCell yourTarget) { if (OnLoopChangeEvent != null) { OnLoopChangeEvent(yourTarget.ParentCell, string.Format("{0}/{1}", totalTimes, totalTimes - myTimes + 1)); } }
/// <summary> /// 进行下一个loop刷新/清除当前loop的节点执行结果(最后的loop请不要调用该方法) /// </summary> /// <param name="yourCell">CaseCell</param> public static void SetCaseNodeLoopRefresh(CaseCell yourCell) { if (yourCell.UiTag == null) { return; } if (yourCell.UiTag is TreeNode) { TreeNode yourTreeNode = (TreeNode)yourCell.UiTag; yourTreeNode.TreeView.BeginUpdate(); if (yourTreeNode.Nodes.Count > 0) { foreach (TreeNode tempNode in yourTreeNode.Nodes) { if (((CaseCell)tempNode.Tag).CaseType != CaseType.Case) { continue; } if (((CaseCell)(tempNode.Tag)).CaseRunData.actions != null) { if (((CaseCell)(tempNode.Tag)).CaseRunData.actions.Count > 0) { CaseTreeNodeChangeState(tempNode, 16); continue; } } CaseTreeNodeChangeState(tempNode, 1); } } yourTreeNode.TreeView.EndUpdate(); } }
/// <summary> /// 展开当前执行节点脚本 /// </summary> /// <param name="yourCell">your CaseCell</param> public static void SetCaseNodeExpand(CaseCell yourCell) { if (yourCell.UiTag == null) { return; } if (yourCell.UiTag is TreeNode) { TreeNode yourTreeNode = (TreeNode)yourCell.UiTag; if (yourTreeNode.Nodes.Count > 0) { //CaseType.Repeat if (!yourTreeNode.IsExpanded) { CaseTreeNodeChangeExpand(yourTreeNode); } } else { //CaseType.Case TreeNode tempParentNode = yourTreeNode.Parent; while (tempParentNode != null) { if (!tempParentNode.IsExpanded) { CaseTreeNodeChangeExpand(tempParentNode); } tempParentNode = tempParentNode.Parent; } } } //若要支持更多的ui请在后面添加 }
internal void SetCaseNodeConnectInterrupt(CaseCell yourCell) { if (yourCell != null && OnCaseTreeChange != null) { this.OnCaseTreeChange(yourCell, null, CaseTreeActionType.CaseNodeConnectInterrupt); } }
/// <summary> /// myCsaeQueue initialize /// </summary> /// <param name="yourStartCase">your StartCase and make sure it is not null</param> public MyCsaeQueue(CaseCell yourStartCase) { queueTotalCount = RunCaseCount.GetCount(yourStartCase); startCaseNode = yourStartCase; nowCaseNode = null; myCaseLoopList = new List <MyCaseLoop>(); }
/// <summary> /// get main task case count(just main but not Include the goto case) /// </summary> /// <param name="startNode">start Node</param> /// <returns>count</returns> public static int GetCount(CaseCell startNode) { int nowCount = 0; List <CaseLoopCountInfo> nowLoops = new List <CaseLoopCountInfo>(); while (startNode != null) { if (startNode.CaseType == CaseType.Case) { nowCount++; } else if (startNode.CaseType == CaseType.Repeat) { if (startNode.IsHasChild) { myCaseLaodInfo tempProjectLoadInfo = MyCaseScriptAnalysisEngine.GetCaseLoadInfo(startNode.CaseXmlNode); nowLoops.Add(new CaseLoopCountInfo(startNode.ChildCells[0], tempProjectLoadInfo.times)); } } else if (startNode.CaseType == CaseType.Project) { if (startNode.IsHasChild) { startNode = startNode.ChildCells[0]; } continue; } startNode = startNode.NextCell; } while (nowLoops.Count != 0) { startNode = nowLoops[nowLoops.Count - 1].LoopNode; int tempRate = nowLoops[nowLoops.Count - 1].CaseRate; nowLoops.Remove(nowLoops[nowLoops.Count - 1]); while (startNode != null) { if (startNode.CaseType == CaseType.Case) { nowCount += tempRate; } else if (startNode.CaseType == CaseType.Repeat) { if (startNode.IsHasChild) { myCaseLaodInfo tempProjectLoadInfo = MyCaseScriptAnalysisEngine.GetCaseLoadInfo(startNode.CaseXmlNode); nowLoops.Add(new CaseLoopCountInfo(startNode.ChildCells[0], tempProjectLoadInfo.times * tempRate)); } } startNode = startNode.NextCell; } } return(nowCount); }
public static void SetCaseNodeContentEdit(CaseCell yourCell) { if (yourCell.UiTag == null) { return; } if (yourCell.UiTag is TreeNode) { TreeNode yourTreeNode = (TreeNode)yourCell.UiTag; CaseTreeNodeChangeState(yourTreeNode, Color.PaleGoldenrod); } }
public static void SetCaseNodePass(CaseCell yourCell) { if (yourCell.UiTag == null) { return; } if (yourCell.UiTag is TreeNode) { TreeNode yourTreeNode = (TreeNode)yourCell.UiTag; CaseTreeNodeChangeState(yourTreeNode, 15); } }
public static void SetCaseNodeContentWarning(CaseCell yourCell) { if (yourCell.UiTag == null) { return; } if (yourCell.UiTag is TreeNode) { TreeNode yourTreeNode = (TreeNode)yourCell.UiTag; CaseTreeNodeChangeState(yourTreeNode, Color.LightGoldenrodYellow); } }
public static void SetCaseNodeConnectInterrupt(CaseCell yourCell) { if (yourCell.UiTag == null) { return; } if (yourCell.UiTag is TreeNode) { TreeNode yourTreeNode = (TreeNode)yourCell.UiTag; CaseTreeNodeChangeState(yourTreeNode, 23); } }
public bool LoadCase(string casePath, out string errorMessage, out List <string> errorList) { if (AnalysisXmlCase(casePath, runerActuator, null, true, out errorMessage, out errorList)) { runnerCasePath = casePath; startCell = runerActuator.RunCellProjctCollection[0, 0]; return(true); } else { runnerCasePath = ""; startCell = null; return(false); } }
/// <summary> /// i will get the next myTreeTagInfo in myCaseRunTime /// </summary> /// <returns>the CaseCell you want</returns> public CaseCell nextCase() { if (myCsaeQueueList.Count > 0) { CaseCell tempTreeNodeCase = myCsaeQueueList[myCsaeQueueList.Count - 1].nextCase(); if (tempTreeNodeCase == null) { DelCsaeQueue(myCsaeQueueList[myCsaeQueueList.Count - 1]); return(nextCase()); } else { return(tempTreeNodeCase); } } else { return(null); } }
/// <summary> /// 为TreeNode添加额外运行时消息以表示loop的变化(额外消息原则上为【···】这种格式或者为空"",处理时替换原有【···】,如果没有则直接添加) /// </summary> /// <param name="yourCell">CaseCell</param> /// <param name="yourMessage">Message (请务必保证数据为【···】这种格式,或为空"")</param> public static void SetCaseNodeLoopChange(CaseCell yourCell, string yourMessage) { if (yourCell.UiTag == null) { return; } if (yourCell.UiTag is TreeNode) { TreeNode yourTreeNode = (TreeNode)yourCell.UiTag; if (yourTreeNode.Text.StartsWith("【")) { int tempEnd = yourTreeNode.Text.IndexOf('】'); CaseTreeNodeChangeText(yourTreeNode, yourMessage + yourTreeNode.Text.Remove(0, tempEnd + 1)); } else { CaseTreeNodeChangeText(yourTreeNode, yourMessage + yourTreeNode.Text); } } }
/// <summary> /// i will get the next myTreeTagInfo in my loop /// </summary> /// <returns>the CaseCell you want</returns> public CaseCell nextCase() { if (myTimes > 0) { if (nowCaseNode == null) //起始节点 { nowCaseNode = startCaseNode; //report position ReportLoopProgress(nowCaseNode); return(nowCaseNode); } else { if (nowCaseNode.NextCell == null) { myTimes--; if (myTimes > 0) { nowCaseNode = startCaseNode; ReportLoopProgress(nowCaseNode); return(nowCaseNode); } else { ReportLoopEnd(nowCaseNode); return(null); //此处为null,指示当前【Loop】结束 } } else { nowCaseNode = nowCaseNode.NextCell; return(nowCaseNode); //此处caseType可能为case或repeat,该类的拥有者将会分别处理 } } } else { return(null); } }
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); } }
/// <summary> /// i will get the next myTreeTagInfo in my queue /// </summary> /// <returns>the CaseCell you want</returns> public CaseCell nextCase() { if (nowCaseNode == null) //起始节点 { nowCaseNode = startCaseNode; if (nowCaseNode.CaseType == CaseType.Repeat) { if (nowCaseNode.IsHasChild) { myCaseLaodInfo tempProjectLoadInfo = MyCaseScriptAnalysisEngine.GetCaseLoadInfo(nowCaseNode.CaseXmlNode); AddCaseLoop(nowCaseNode.ChildCells[0], tempProjectLoadInfo.times); } return(nextCase()); } else if (nowCaseNode.CaseType == CaseType.Case) { queueNowCount++; return(nowCaseNode); } else if (nowCaseNode.CaseType == CaseType.Project) { if (nowCaseNode.IsHasChild) { startCaseNode = nowCaseNode.ChildCells[0]; nowCaseNode = null; return(nextCase()); } return(null); //空Project } else { return(null); //当前设计不会有这种情况 } } else { if (myCaseLoopList.Count > 0) { int tempNowListIndex = myCaseLoopList.Count - 1; CaseCell tempNextLoopTreeNode = myCaseLoopList[tempNowListIndex].nextCase(); if (tempNextLoopTreeNode == null) { DelCaseLoop(myCaseLoopList[tempNowListIndex]); return(nextCase()); } else { if (tempNextLoopTreeNode.CaseType == CaseType.Repeat) { if (tempNextLoopTreeNode.IsHasChild) { myCaseLaodInfo tempProjectLoadInfo = MyCaseScriptAnalysisEngine.GetCaseLoadInfo(tempNextLoopTreeNode.CaseXmlNode); AddCaseLoop(tempNextLoopTreeNode.ChildCells[0], tempProjectLoadInfo.times); } return(nextCase()); } else if (tempNextLoopTreeNode.CaseType == CaseType.Case) { queueNowCount++; return(tempNextLoopTreeNode); } else { return(null); //当前设计不会有这种情况 } } } else { if (nowCaseNode.NextCell == null) { return(null); //当前 【Queue】 结束 } else { nowCaseNode = nowCaseNode.NextCell; if (nowCaseNode.CaseType == CaseType.Repeat) { if (nowCaseNode.IsHasChild) { myCaseLaodInfo tempProjectLoadInfo = MyCaseScriptAnalysisEngine.GetCaseLoadInfo(nowCaseNode.CaseXmlNode); AddCaseLoop(nowCaseNode.ChildCells[0], tempProjectLoadInfo.times); } return(nextCase()); } else if (nowCaseNode.CaseType == CaseType.Case) { queueNowCount++; return(nowCaseNode); } else { return(null); //当前设计不会有这种情况 } } } } }
/// <summary> /// myCaseLoop initialize /// </summary> /// <param name="yourStartCase">your StartCase and make sure it is not null</param> /// <param name="yourTimes">your Times </param> public MyCaseLoop(CaseCell yourStartCase, int yourTimes) { totalTimes = myTimes = yourTimes; startCaseNode = yourStartCase; nowCaseNode = null; }
/// <summary> /// Initialization the CaseLoopCountInfo /// </summary> /// <param name="yourLoopNode">your LoopNode</param> /// <param name="yourCaseRate">your CaseRate</param> public CaseLoopCountInfo(CaseCell yourLoopNode, int yourCaseRate) { loopNode = yourLoopNode; caseRate = yourCaseRate; }
/// <summary> /// you must readyStart before get nextCase (and here also can reset the StartCase) /// </summary> /// <param name="yourStartCase">your StartCase</param> public void readyStart(CaseCell yourStartCase) { myCsaeQueueList.Clear(); AddCsaeQueue(new MyCsaeQueue(yourStartCase)); ReportQueueAction(yourStartCase, MyConfiguration.CaseShowCaseNodeStart); }
/// <summary> /// you must readyStart before get nextCase (and here also can reset the StartCase) /// </summary> /// <param name="yourStartCase">your StartCase</param> /// <param name="yourIsThrough">it will change the behaviour that is it will go through all case(now it is replaced by [goto])</param> public void readyStart(CaseCell yourStartCase, bool yourIsThrough) { readyStart(yourStartCase); isThroughAllCase = yourIsThrough; }
/// <summary> /// i will add new CaseLoop and Subscribe 【OnLoopChangeEvent】 /// </summary> /// <param name="yourStartCase">your StartCase</param> /// <param name="yourTimes">your Times</param> private void AddCaseLoop(CaseCell yourStartCase, int yourTimes) { myCaseLoopList.Add(new MyCaseLoop(yourStartCase, yourTimes)); myCaseLoopList[myCaseLoopList.Count - 1].OnLoopChangeEvent += OnLoopChangeEvent; }