private void DoTestJobs() { DateTime sdt = DateTime.Now; DateTime edt = DateTime.Now; try { if (DatabaseConnected) { string pname = _curPorjectDB; string spname = _curSubProjectDB; sdt = DateTime.Now; string strdt = sdt.Year.ToString() + "-" + sdt.Month.ToString() + "-" + sdt.Day.ToString() + " " + sdt.Hour.ToString() + ":" + sdt.Minute.ToString() + ":" + sdt.Second.ToString(); _testViewID = Environment.MachineName + Environment.UserName + strdt; string sql = "INSERT INTO itester.testview(id,pspname,prate,tcount,fecount,stime,etime,duration,testpc,tester) " + "VALUES('" + _testViewID + "','" + pname + spname + "','0%','0','0','" + strdt + "','" + strdt + "','0.0hours','" + System.Environment.MachineName + "','" + System.Environment.UserName + "')"; MySqlCommand cmd = new MySqlCommand(); cmd.Connection = _mysqlConn; cmd.CommandText = sql; cmd.ExecuteNonQuery(); } SendMessageCategory("Begin Test Collection", false); SendMessageData("Hostname", System.Environment.MachineName, false); SendMessageData("Username", System.Environment.UserName, false); SendMessageData("Test ID", GetTestID(), false); SendMessageData("Start time", DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString(), false); foreach (TestGroupCase tgc in TestColInstance.TestGroupCaseOc) { Dispatcher.Invoke((ThreadStart)delegate() { if (tgc.IsCase == false && tgc.IsExpanded == false) tgc.IsExpanded = true; }, null); DoConcreteTestJobsWrapper(tgc); tgc.AlreadyRun = true; } } catch (Exception ex) { MessageBox.Show("Test is terminated.\nError message :\n" + ex.Message, "Jobs Error", MessageBoxButton.OK, MessageBoxImage.Error); SendMessage(iTestBase.iTestBase.TestStateEnum.Error, "", "Exception", "Test is terminated.", "", "", false); SendMessage(iTestBase.iTestBase.TestStateEnum.Error, "", "Exception", "Error message", ex.Message, "", false); string[] sa = Get255Lentring(ex.Message); foreach (string s in sa) { SendMessage(iTestBase.iTestBase.TestStateEnum.Error, "", "", s, "", ""); } SendMessage(iTestBase.iTestBase.TestStateEnum.Error, "", "Exception", "Stack Trace", "", "", false); sa = Get255Lentring(ex.StackTrace); foreach (string s in sa) { SendMessage(iTestBase.iTestBase.TestStateEnum.Error, "", "", s, "", "", false); } } finally { InRun = false; InPause = false; ReadyString = "Ready"; _curTgcUnderTest = null; SendMessageData("Stop time", DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString(), false); SendMessageCategory("Test Collection Ends.", false); if (DatabaseConnected) { edt = DateTime.Now; TimeSpan ts = edt.Subtract(sdt); string sth = ts.TotalHours.ToString("F2") + "hours"; string strdt = edt.Year.ToString() + "-" + edt.Month.ToString() + "-" + edt.Day.ToString() + " " + edt.Hour.ToString() + ":" + edt.Minute.ToString() + ":" + edt.Second.ToString(); string sql = "UPDATE itester.testview SET prate='" + PassRateString + "',tcount='" + AllCaseCountString + "',fecount='" + (ErrorCaseCount + FailCaseCount).ToString() + "',etime='" + strdt + "',duration='" + sth + "' " + "WHERE id='" + _testViewID + "'"; MySqlCommand cmd = new MySqlCommand(); cmd.Connection = _mysqlConn; cmd.CommandText = sql; cmd.ExecuteNonQuery(); } foreach (TestGroupCase tgc in TestColInstance.TestGroupCaseOcDisp) { tgc.InRun = false; } _timer.Stop(); } }
private void DoConcreteTestJobsWrapper(TestGroupCase tgc) { try { DoConcreteTestJobs(tgc); } catch (Exception ex) { SendMessage(iTestBase.iTestBase.TestStateEnum.Error, tgc.GroupCaseName, "Exception", "Test Case is terminated.", "", "", false); SendMessage(iTestBase.iTestBase.TestStateEnum.Error, tgc.GroupCaseName, "Exception", "Error message", ex.Message, "", false); string[] sa = Get255Lentring(ex.Message); foreach (string s in sa) { SendMessage(iTestBase.iTestBase.TestStateEnum.Error, tgc.GroupCaseName, "", s, "", ""); } SendMessage(iTestBase.iTestBase.TestStateEnum.Error, tgc.GroupCaseName, "Exception", "Stack Trace", "", "", false); sa = Get255Lentring(ex.StackTrace); foreach (string s in sa) { SendMessage(iTestBase.iTestBase.TestStateEnum.Error, tgc.GroupCaseName, "", s, "", "", false); } } }
private void DoSaveTestGroupCase(StreamWriter sw, TestGroupCase tgc, int level) { if (tgc.IsCase) { //XmlSerializer formatter = new XmlSerializer(typeof(TestGroupCase)); #region Calculate Relative Path int idx = tgc.TestFilePath.LastIndexOf(@"\"); string strName = tgc.TestFilePath.Substring(idx + 1); string strPath = tgc.TestFilePath.Substring(0, idx); idx = CurrentFilePath.LastIndexOf(@"\"); string strApp = CurrentFilePath.Substring(0, idx); string strFinal = ""; if (string.Compare(strPath.Substring(0, 1), strApp.Substring(0, 1)) != 0) strFinal = tgc.TestFilePath; else if (strPath.StartsWith(@"\") || strPath.StartsWith(@"\")) strFinal = tgc.TestFilePath; else { string[] saPath = strPath.Split(new string[] { @"\" }, StringSplitOptions.None); string[] saApp = strApp.Split(new string[] { @"\" }, StringSplitOptions.None); int lsaP = saPath.Length; int lsaA = saApp.Length; int minLen = Math.Min(lsaP, lsaA); int i = 0; for (; i < minLen; i++) { if (string.Compare(saPath[i], saApp[i]) != 0) break; } lsaA = lsaA - i; for (; i < lsaP; i++) { strFinal = strFinal + saPath[i] + @"\"; } for (i = 0; i < lsaA; i++) { strFinal = @"..\" + strFinal; } strFinal = strFinal + strName; } #endregion sw.WriteLine(GetLevelPadding(level) + "<groupcase type=\"case\"" + " selected=\"" + ((tgc.SelectedState== true)? "true" : "false")+ "\" name=\"" + CommonOperations.ConvertFileString2XmlString(tgc.GroupCaseName) + "\" path=\"" + CommonOperations.ConvertFileString2XmlString(strFinal) + "\">");//tgc.TestFilePath) + "\">"); Type t = tgc.TestBaseInstance.GetType(); PropertyInfo[] pia = t.GetProperties(); foreach (PropertyInfo pi in pia) { object obj = pi.GetValue(tgc.TestBaseInstance, null); Type to = obj.GetType(); if (to.IsValueType || string.Compare(to.Name, "string") == 0) { sw.WriteLine(GetLevelPadding(level + 1) + "<item name=\"" + CommonOperations.ConvertFileString2XmlString(pi.Name) + "\" value=\"" + CommonOperations.ConvertFileString2XmlString(obj.ToString()) + "\"/>"); } } sw.WriteLine(GetLevelPadding(level) + "</groupcase>"); } else { sw.WriteLine(GetLevelPadding(level) + "<groupcase type=\"group\"" + " selected=\"" + ((tgc.SelectedState == true) ? "true" : "false") + "\" name=\"" + CommonOperations.ConvertFileString2XmlString(tgc.GroupCaseName) + "\">"); foreach (TestGroupCase tgci in tgc.TestGroupCaseOc) { DoSaveTestGroupCase(sw, tgci, level + 1); } sw.WriteLine(GetLevelPadding(level) + "</groupcase>"); } }
private void Add_Click(object sender, RoutedEventArgs e) { OneLineEditor ole = new OneLineEditor("New Group", "Group Name"); if (ole.ShowDialog() != true) return; int index = 0; string sc = ""; while (true) { bool bFound = false; foreach (TestGroupCase tgct in TestColInstance.TestGroupCaseOc) { sc = ole.UserContent + ((index == 0) ? "" : " (" + index.ToString() + ")"); if (string.Compare(sc, tgct.GroupCaseName) == 0) { bFound = true; break; } } if (bFound == true) index++; else break; } if (string.IsNullOrWhiteSpace(sc)) sc = ole.UserContent; TestGroupCase tgc = new TestGroupCase(TestColInstance, null, sc, false, null, null); CurrentDirtyFlag = true; UpdateTotalTestCases(); }
private void DoConcreteTestJobs(TestGroupCase tgc) { if (tgc.IsCase == true) { #region Case if (tgc.SelectedState == false) return; DateTime sdt = DateTime.Now; if (DatabaseConnected) { _testColID = System.Environment.MachineName + "_" + System.Environment.UserName + "_" + sdt.ToLongDateString() + "_" + sdt.ToLongTimeString() + "_" + sdt.Millisecond.ToString() + "_" + tgc.GroupCaseName; string strdt = sdt.Year.ToString() + "-" + sdt.Month.ToString() + "-" + sdt.Day.ToString() + " " + sdt.Hour.ToString() + ":" + sdt.Minute.ToString() + ":" + sdt.Second.ToString(); string sql = "INSERT INTO itester.testcol(id,tvid,tname,stime,duration,ecount,fcount,pcount,icount) " + "VALUES('" + _testColID + "','" + _testViewID + "','" + tgc.GroupCaseName + "','" + strdt + "','0.0hours','0','0','0','0')"; MySqlCommand cmd = new MySqlCommand(); cmd.Connection = _mysqlConn; cmd.CommandText = sql; cmd.ExecuteNonQuery(); } SendMessage(iTestBase.iTestBase.TestStateEnum.None, tgc.GroupCaseName, "Enter case", "", "", "", false); _testResultIndex = 0; _curTgcUnderTest = tgc; Dispatcher.Invoke((ThreadStart)delegate() { int index = TestColInstance.GetGroupCaseIndex(tgc); ListViewItem lvi = (ListViewItem)lvGroupCase.ItemContainerGenerator.ContainerFromIndex(index); if (lvi != null) { lvi.IsSelected = true; lvGroupCase.ScrollIntoView(lvi); } }, null); InformationCountSingle = 0; PassCountSingle = 0; FailCountSingle = 0; ErrorCountSingle = 0; TotalCountSingle = 0; ReadyString = tgc.GroupCaseName; try { SendMessage(iTestBase.iTestBase.TestStateEnum.None, tgc.GroupCaseName, "Case Setup", ""); tgc.TestBaseInstance.Setup(); for (int i = 0; i < tgc.TestBaseInstance.RunCount; i++) { SendMessage(iTestBase.iTestBase.TestStateEnum.None, tgc.GroupCaseName, "Case Run", ""); if (tgc.TestBaseInstance.RunCount > 1) { SendMessage(iTestBase.iTestBase.TestStateEnum.None, tgc.GroupCaseName, "Loop " + (i + 1).ToString() + " / " + tgc.TestBaseInstance.RunCount.ToString(), ""); Dispatcher.Invoke((ThreadStart)delegate() { ReadyString = tgc.GroupCaseName + " ( " + (i + 1).ToString() + " / " + tgc.TestBaseInstance.RunCount.ToString() + " )"; }, null); } tgc.TestBaseInstance.Run(); } SendMessage(iTestBase.iTestBase.TestStateEnum.None, tgc.GroupCaseName, "Case Clean", ""); tgc.TestBaseInstance.Clean(); } catch (Exception ex) { SendMessage(iTestBase.iTestBase.TestStateEnum.Error, tgc.GroupCaseName, "Exception", "Test Case is terminated.", ""); SendMessage(iTestBase.iTestBase.TestStateEnum.Error, tgc.GroupCaseName, "Exception", "Error message", ""); string[] sa = Get255Lentring(ex.Message); foreach (string s in sa) { SendMessage(iTestBase.iTestBase.TestStateEnum.Error, tgc.GroupCaseName, "", s, "", ""); } SendMessage(iTestBase.iTestBase.TestStateEnum.Error, tgc.GroupCaseName, "Exception", "Stack Trace", "", ""); sa = Get255Lentring(ex.StackTrace); foreach (string s in sa) { SendMessage(iTestBase.iTestBase.TestStateEnum.Error, tgc.GroupCaseName, "", s, "", ""); } } SendMessage(iTestBase.iTestBase.TestStateEnum.None, tgc.GroupCaseName, "Exit case", "", "", "", false); Dispatcher.Invoke((ThreadStart)delegate() { if (tgc.FailCount < 1 && tgc.ErrorCount < 1) { tgc.PassImage = new BitmapImage(); tgc.PassImage.BeginInit(); tgc.PassImage.UriSource = new Uri("pack://application:,,,/Testempo;component/resources/status_ok.png"); tgc.PassImage.EndInit(); TestGroupCase tgct = tgc.TestGroupCaseParent; while (tgct != null) { //tgct.PassBackground = new SolidColorBrush(Colors.Green); tgct.PassCount++; tgct = tgct.TestGroupCaseParent; } } if (tgc.FailCount > 0) { tgc.FailImage = new BitmapImage(); tgc.FailImage.BeginInit(); tgc.FailImage.UriSource = new Uri("pack://application:,,,/Testempo;component/resources/status_error.png"); tgc.FailImage.EndInit(); TestGroupCase tgct = tgc.TestGroupCaseParent; while (tgct != null) { //tgct.FailBackground = new SolidColorBrush(Colors.Red); tgct.FailCount++; tgct = tgct.TestGroupCaseParent; } } if (tgc.ErrorCount > 0) { tgc.ErrorImage = new BitmapImage(); tgc.ErrorImage.BeginInit(); tgc.ErrorImage.UriSource = new Uri("pack://application:,,,/Testempo;component/resources/status_ques.ico"); tgc.ErrorImage.EndInit(); TestGroupCase tgct = tgc.TestGroupCaseParent; while (tgct != null) { //tgct.ErrorBackground = new SolidColorBrush(Colors.Yellow); tgct.ErrorCount++; tgct = tgct.TestGroupCaseParent; } } PassCaseCount = 0; FailCaseCount = 0; ErrorCaseCount = 0; foreach (TestGroupCase tgcit in TestColInstance.TestGroupCaseOc) { PassCaseCount = PassCaseCount + tgcit.PassCount; FailCaseCount = FailCaseCount + tgcit.FailCount; ErrorCaseCount = ErrorCaseCount + tgcit.ErrorCount; } }, null); _curTgcUnderTest = null; tgc.Duration = DateTime.Now.Subtract(sdt); if (DatabaseConnected) { string sth = tgc.Duration.TotalHours.ToString("F2") + "hours"; string sql = "UPDATE itester.testcol SET duration='" + sth + "',ecount='" + ErrorCountSingleString + "',fcount='" + FailCountSingleString + "',pcount='" + PassCountSingleString + "',icount='" + InformationCountSingleString + "' " + "WHERE id='" + _testColID + "'"; MySqlCommand cmd = new MySqlCommand(); cmd.Connection = _mysqlConn; cmd.CommandText = sql; cmd.ExecuteNonQuery(); } #endregion } else { DateTime dt = DateTime.Now; foreach (TestGroupCase tgci in tgc.TestGroupCaseOc) { Dispatcher.Invoke((ThreadStart)delegate() { if (tgci.IsCase == false && tgci.IsExpanded == false) tgci.IsExpanded = true; }, null); DoConcreteTestJobs(tgci); tgci.AlreadyRun = true; } tgc.Duration = DateTime.Now.Subtract(dt); } }
public void DeleteTestGroupCase(TestGroupCase tgc) { if (tgc == null) return; if (tgc.TestGroupCaseParent != null) tgc.TestGroupCaseParent.TestGroupCaseOc.Remove(tgc); else TestGroupCaseOc.Remove(tgc); TestGroupCaseOcDisp.Remove(tgc); Stack<TestGroupCase> tcStack = new Stack<TestGroupCase>(); foreach (TestGroupCase tgci in tgc.TestGroupCaseOc) { tcStack.Push(tgci); } for (; ; ) { if (tcStack.Count < 1) return; TestGroupCase tgci = tcStack.Pop(); TestGroupCaseOcDisp.Remove(tgci); if (tgci.IsCase == false) { foreach (TestGroupCase tgct in tgci.TestGroupCaseOc) { tcStack.Push(tgct); } } } }
private void AddSubCase_Click(object sender, RoutedEventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Multiselect = false; dlg.Filter = "Test Data (*.dll)|*.dll"; dlg.InitialDirectory = GlobalSettings[NameStrings.ApplicationFolder] + @"\data"; dlg.Title = "Select a test binary"; if (dlg.ShowDialog() != true) return; #region iTestBase.iTestBase tb = LoadTestBaseDllFromFile(dlg.FileName, false); if (tb == null) return; #endregion TestGroupCase tgc = (TestGroupCase)lvGroupCase.SelectedItem; int index = 0; string sc = ""; while (true) { bool bFound = false; foreach (TestGroupCase tgci in tgc.TestGroupCaseOc) { sc = tb.TestName + ((index == 0) ? "" : " (" + index.ToString() + ")"); if (string.Compare(sc, tgci.GroupCaseName) == 0) { bFound = true; break; } } if (bFound == true) index++; else break; } if (string.IsNullOrWhiteSpace(sc)) sc = tb.TestName; #region Create Relative Path //int idx = dlg.FileName.LastIndexOf(@"\"); //string strName = dlg.FileName.Substring(idx + 1); //string strPath = dlg.FileName.Substring(0, idx); //string strApp = (string)GlobalSettings[NameStrings.ApplicationFolder]; string strFinal = ""; //if (string.Compare(strPath.Substring(0, 1), strApp.Substring(0, 1), true) != 0) strFinal = dlg.FileName; //else if (strPath.StartsWith(@"\") || strPath.StartsWith(@"\")) // strFinal = dlg.FileName; //else //{ // string[] saPath = strPath.Split(new string[] { @"\" }, StringSplitOptions.None); // string[] saApp = strApp.Split(new string[] { @"\" }, StringSplitOptions.None); // int lsaP = saPath.Length; // int lsaA = saApp.Length; // int minLen = Math.Min(lsaP, lsaA); // int i = 0; // for (; i < minLen; i++) // { // if (string.Compare(saPath[i], saApp[i], true) != 0) // break; // } // lsaA = lsaA - i; // for (; i < lsaP; i++) // { // strFinal = strFinal + saPath[i] + @"\"; // } // for (i = 0; i < lsaA; i++) // { // strFinal = @"..\" + strFinal; // } // strFinal = strFinal + strName; //} #endregion TestGroupCase tgct = new TestGroupCase(TestColInstance, tgc, sc, true, tb, strFinal); if(tgct.IsCase == true) tgct.TestBaseInstance.TestName = sc; CurrentDirtyFlag = true; UpdateTotalTestCases(); }
public void UpdateParentChildSelectedState(TestGroupCase tgc) { UpdateChildSelectedState(tgc); UpdateParentSelectedState(tgc); }
public void UpdateParentSelectedState(TestGroupCase tgc) { bool hasChecked = false; bool hasUnchecked = false; TestGroupCase tgcp = tgc.TestGroupCaseParent; while (tgcp != null) { foreach (TestGroupCase tgci in tgcp.TestGroupCaseOc) { if (tgci.SelectedState == true) hasChecked = true; else if (tgci.SelectedState == false) hasUnchecked = true; } if (hasChecked && hasUnchecked) tgcp.SelectedStateBackColor = new SolidColorBrush(Colors.DarkGray); else tgcp.SelectedStateBackColor = new SolidColorBrush(Colors.Transparent); if (hasChecked) tgcp.SelectedState = true; else tgcp.SelectedState = false; tgcp = tgcp.TestGroupCaseParent; } }
/// <summary> /// /// </summary> /// <param name="tgc"></param> /// <returns></returns> public int GetGroupCaseIndex(TestGroupCase tgc) { for (int i = 0; i < TestGroupCaseOcDisp.Count; i++) { if (TestGroupCaseOcDisp[i] == tgc) return i; } return -1; }
/// <summary> /// /// </summary> public void UpdateChildSelectedState(TestGroupCase tgc) { if (tgc.IsCase == true) return; Stack<TestGroupCase> tcStack = new Stack<TestGroupCase>(); foreach (TestGroupCase tgci in tgc.TestGroupCaseOc) { tcStack.Push(tgci); } for (; ; ) { if (tcStack.Count < 1) return; TestGroupCase tgci = tcStack.Pop(); tgci.SelectedState = tgc.SelectedState; tgci.SelectedStateBackColor = new SolidColorBrush(Colors.Transparent); if (tgci.IsCase == false) { foreach (TestGroupCase tgct in tgci.TestGroupCaseOc) { tcStack.Push(tgct); } } } }
public int FindTestGroupCaseIndex(TestGroupCase tgc) { if (tgc == null) return -1; if (tgc.TestGroupCaseParent == null) { for (int i = 0; i < TestGroupCaseOc.Count; i++) { if (TestGroupCaseOc[i] == tgc) return i; } } else { for (int i = 0; i < tgc.TestGroupCaseParent.TestGroupCaseOc.Count; i++) { if (tgc.TestGroupCaseParent.TestGroupCaseOc[i] == tgc) return i; } } return -1; }
public int FindTestGroupCaseDisplayIndex(TestGroupCase tgc) { if (tgc == null) return -1; for (int i = 0; i < TestGroupCaseOcDisp.Count; i++) { if (TestGroupCaseOcDisp[i] == tgc) return i; } return -1; }
public int FindLastSubGroupCaseDisplayIndex(TestGroupCase tgc) { if (tgc == null) return -1; if (tgc.IsCase == true) return FindTestGroupCaseDisplayIndex(tgc); if (tgc.TestGroupCaseOc.Count < 1) return FindTestGroupCaseDisplayIndex(tgc); TestGroupCase tgcp = tgc.TestGroupCaseOc[tgc.TestGroupCaseOc.Count - 1]; while (tgcp.IsCase == false && tgcp.TestGroupCaseOc.Count > 0) { tgcp = tgcp.TestGroupCaseOc[tgcp.TestGroupCaseOc.Count - 1]; } return FindTestGroupCaseDisplayIndex(tgcp); }
private void ParseXMlToTestGroupCase(TestGroupCase tgc, XElement xeSuite) { string groupOrCase = CommonOperations.ConvertXmlString2FileString(xeSuite.Attribute("type").Value); string groupCaseSelected = "true"; if(xeSuite.Attribute("selected") != null) groupCaseSelected = xeSuite.Attribute("selected").Value; string groupCaseName = CommonOperations.ConvertXmlString2FileString(xeSuite.Attribute("name").Value); if (string.Compare(groupOrCase, "case") == 0) { string filePath = CommonOperations.ConvertXmlString2FileString(xeSuite.Attribute("path").Value); iTestBase.iTestBase tb = LoadTestBaseDllFromFile(filePath); if (tb == null) return; TestGroupCase tgct = null; if (tgc == null) tgct = new TestGroupCase(TestColInstance, null, groupCaseName, true, tb, filePath); else tgct = new TestGroupCase(TestColInstance, tgc, groupCaseName, true, tb, filePath); if (string.Compare(groupCaseSelected, "false") == 0) tgct.SelectedState = false; else tgct.SelectedState = true; TestColInstance.ConfigTestGroupCaseFromXML(tgct, xeSuite); } else { TestGroupCase tgct = null; if (tgc == null) tgct = new TestGroupCase(TestColInstance, null, groupCaseName, false, null, null); else tgct = new TestGroupCase(TestColInstance, tgc, groupCaseName, false, null, null); foreach (XElement xe in xeSuite.Elements("groupcase")) { ParseXMlToTestGroupCase(tgct, xe); } } }
/// <summary> /// /// </summary> /// <param name="testColInst"></param> /// <param name="groupCaseName"></param> /// <param name="level"></param> /// <param name="isCase"></param> /// <param name="testBaseInst"></param> /// <param name="testFilePath"></param> public TestGroupCase(TestCollection testColInst, TestGroupCase parent, string groupCaseName, bool isCase, iTestBase testBaseInst, string testFilePath) { if (testColInst == null) throw new ArgumentNullException("Cannot initialize TestGroupCase() because of the null parameter."); GlobalIndex = TestCollection.GetGlobalIndex(); TestColInstance = testColInst; GroupCaseName = groupCaseName; int level = 0; TestGroupCase tgc = parent; while (tgc != null) { level++; tgc = tgc.TestGroupCaseParent; } DisplayLevel = level; IsCase = isCase; TestBaseInstance = testBaseInst; if (IsCase == true) TestBaseInstance.TestGroupCaseLocal = this; TestFilePath = testFilePath; GroupCaseImage = new BitmapImage(); GroupCaseImage.BeginInit(); if (IsCase == true) GroupCaseImage.UriSource = new Uri("pack://application:,,,/Testempo;component/resources/group_case.png"); else { if (TestGroupCaseOc.Count > 1) { GroupCaseImage.UriSource = new Uri("pack://application:,,,/Testempo;component/resources/group_expand.png"); _isExpanded = true; } else { GroupCaseImage.UriSource = new Uri("pack://application:,,,/Testempo;component/resources/group_collaps.png"); _isExpanded = false; } } GroupCaseImage.EndInit(); //if (IsCase == true) //{ // PassImage = new BitmapImage(); // PassImage.BeginInit(); // PassImage.UriSource = new Uri("pack://application:,,,/Testempo;component/resources/status_ok.png"); // PassImage.EndInit(); // FailImage = new BitmapImage(); // FailImage.BeginInit(); // FailImage.UriSource = new Uri("pack://application:,,,/Testempo;component/resources/status_error.png"); // FailImage.EndInit(); //} if (parent != null) { TestGroupCaseParent = parent; int index = TestColInstance.FindLastSubGroupCaseDisplayIndex(parent); parent.TestGroupCaseOc.Add(this); TestGroupCaseParent.IsExpanded = true; TestColInstance.TestGroupCaseOcDisp.Insert(index + 1, this); } else { TestColInstance.TestGroupCaseOc.Add(this); TestColInstance.TestGroupCaseOcDisp.Add(this); } if (IsCase == true) TestBaseInstance.RunCountChangedEvent += new EventHandler<RunCountChangedEventArgs>(TestBaseInstance_RunCountChangedEvent_EventHandler); }
private void Start_Button_Click(object sender, RoutedEventArgs e) { if (TestColInstance.TestGroupCaseOc.Count < 1) return; if (DatabaseConnected == true && (string.IsNullOrWhiteSpace(_curProject) || string.IsNullOrWhiteSpace(_curSubProject))) { MessageBox.Show("Project Name/Sub Project Name error.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (InRun == true) InPause = false; else { InRun = true; InPause = false; TestResultOc.Clear(); PassCountSingle = 0; PassCount = 0; FailCountSingle = 0; FailCount = 0; ErrorCountSingle = 0; ErrorCount = 0; InformationCountSingle = 0; InformationCount = 0; TotalCountSingle = 0; TotalCount = 0; PassCaseCount = 0; FailCaseCount = 0; ErrorCaseCount = 0; //dgTestResults.Focus(); //_canSendMessage = true; _curTgcUnderTest = null; foreach (TestGroupCase tgc in TestColInstance.TestGroupCaseOcDisp) { tgc.PassCount = 0; tgc.PassImage = null; //tgc.PassBackground = new SolidColorBrush(Colors.Transparent); tgc.FailCount = 0; tgc.FailImage = null; //tgc.FailBackground = new SolidColorBrush(Colors.Transparent); tgc.ErrorCount = 0; tgc.ErrorImage = null; //tgc.ErrorBackground = new SolidColorBrush(Colors.Transparent); //tgc.PassRate = 0; tgc.Duration = new TimeSpan(); tgc.AlreadyRun = false; tgc.InRun = true; } _intMSec = 0; _intSec = 0; _intMin = 0; _intHour = 0; _intDay = 0; UpdateTimerLabel(); _timer.Start(); _thWorker = new Thread(new ThreadStart(DoTestJobs)); _thWorker.Start(); } }
public void ConfigTestGroupCaseFromXML(TestGroupCase tgc, XElement xeCofig) { iTestBase tb = tgc.TestBaseInstance; Type t = tb.GetType(); PropertyInfo[] pia = t.GetProperties(); //FieldInfo[] fia = t.GetFields(); foreach (XElement xe in xeCofig.Elements("item")) { string sn = CommonOperations.ConvertXmlString2FileString(xe.Attribute("name").Value); string sv = CommonOperations.ConvertXmlString2FileString(xe.Attribute("value").Value); foreach (PropertyInfo pi in pia) { string pt = pi.PropertyType.Name; string ptb = pi.PropertyType.BaseType.Name; if (string.Compare(ptb, "Enum") != 0 && !pi.PropertyType.IsValueType && string.Compare(pt, "string") != 0) break; if (string.Compare(pi.Name, sn, true) == 0) { try { if (string.Compare(pt, "SByte") == 0) { pi.SetValue(tb, sbyte.Parse(sv), null); } else if (string.Compare(pt, "Byte") == 0) { pi.SetValue(tb, byte.Parse(sv), null); } else if (string.Compare(pt, "Char") == 0) { pi.SetValue(tb, char.Parse(sv), null); } else if (string.Compare(pt, "Int16") == 0) { pi.SetValue(tb, Int16.Parse(sv), null); } else if (string.Compare(pt, "UInt16") == 0) { pi.SetValue(tb, UInt16.Parse(sv), null); } else if (string.Compare(pt, "Int32") == 0) { pi.SetValue(tb, Int32.Parse(sv), null); } else if (string.Compare(pt, "UInt32") == 0) { pi.SetValue(tb, UInt32.Parse(sv), null); } else if (string.Compare(pt, "Int64") == 0) { pi.SetValue(tb, Int64.Parse(sv), null); } else if (string.Compare(pt, "UInt64") == 0) { pi.SetValue(tb, UInt64.Parse(sv), null); } else if (string.Compare(pt, "Decimal") == 0) { pi.SetValue(tb, decimal.Parse(sv), null); } else if (string.Compare(pt, "float") == 0) { pi.SetValue(tb, float.Parse(sv), null); } else if (string.Compare(pt, "double") == 0) { pi.SetValue(tb, double.Parse(sv), null); } else if (string.Compare(pt, "Boolean") == 0) { pi.SetValue(tb, bool.Parse(sv), null); } else if (string.Compare(ptb, "Enum") == 0) { pi.SetValue(tb, Enum.Parse(pi.PropertyType, sv), null); } else if (string.Compare(pt, "String") == 0) { pi.SetValue(tb, sv, null); } } catch (Exception ex) { MessageBox.Show("Cannot parse \"" + sv + "\" for \" " + sn + "\".\nError message :\n" + ex.Message, "Parse Error", MessageBoxButton.OK, MessageBoxImage.Error); } } } //foreach (FieldInfo fi in fia) //{ // string pt = fi.FieldType.ToString(); // if (!fi.FieldType.IsValueType && string.Compare(pt, "string", true) != 0) // break; // if (string.Compare(fi.Name, sn, true) == 0) // { // } //} } }