/// <summary> /// Checks the calculation model after calculation. /// </summary> /// <returns><c>true</c> if it either shows power law, exponential or polynomial, <c>false</c> otherwise.</returns> private bool CheckCalculationModelAfterCalculation() { bool result; Element calculationModel = new ResultElements().EditControlCalculationModel; if (calculationModel == null) { Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "The element 'Calculation Model' is null."); result = false; } else { string calculationModelText = calculationModel.GetAttributeValueText("Text"); if (calculationModelText.Contains("Power Law") || calculationModelText.Contains("Exponential") || calculationModelText.Contains("Polynomial")) { Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Calculation Model = " + calculationModelText + "."); result = true; } else { Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Calculation Model = " + calculationModelText + "."); result = false; } } return(result); }
/// <summary> /// Checks the calculation model after calculation. /// </summary> /// <returns><c>true</c> if it either shows power law, exponential or polynomial, <c>false</c> otherwise.</returns> private bool CheckCalculationModelAfterCalculation() { bool result; Element calculationModel = new ResultElements().EditControlCalculationModel; if (calculationModel == null) { Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "The element 'Calculation Model' is null."); result = false; } else { string calculationModelText = calculationModel.GetAttributeValueText("Text"); if (calculationModelText != string.Empty) { Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Calculation Model = " + calculationModelText + "."); result = true; } else { Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Calculation Model not shown correctly"); result = false; } } return(result); }
/// <summary> /// Scrolls to top via page up button of event list so that first event is visible /// </summary> private void ScrollToTop() { try { Button button = new ResultElements().ButtonPageUp; while (button.Visible) { button.Click(); } } catch (Exception) { Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Page Up button not found, no problem if event list is not scrollable (only a few entries)"); } }
/// <summary> /// Checks the compensation coefficients after calculation. /// </summary> /// <returns><c>true</c> if they represent float values, <c>false</c> otherwise.</returns> private bool CheckCompensationCoefficientsAfterCalculation() { bool result; Element coefficientX1 = new ResultElements().EditControlCoefficientX1; Element coefficientX2 = new ResultElements().EditControlCoefficientX2; if (coefficientX1 == null) { Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "The element 'Compensation Coefficient X1' is null."); result = false; } else if (coefficientX2 == null) { Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "The element 'Compensation Coefficient X2' is null."); result = false; } else { string coefficientX1Text = coefficientX1.GetAttributeValueText("Text"); string coefficientX2Text = coefficientX2.GetAttributeValueText("Text"); const string Pattern = @"(\d{1,}\.\d{1,})"; var regex = new Regex(Pattern); if (regex.IsMatch(coefficientX1Text) && regex.IsMatch(coefficientX2Text)) { Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Compensation coefficient X1 = " + coefficientX1Text + "." + " Compensation coefficient X2 = " + coefficientX2Text + "."); result = true; } else { Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Compensation coefficient X1 = " + coefficientX1Text + "." + " Compensation coefficient X2 = " + coefficientX2Text + "."); result = false; } } return(result); }
/// <summary> /// Reads the entire event list and creates a list with the events /// </summary> /// <returns> /// <br>IList: if event list was created successfully</br> /// <br>Null: if an error occurred</br> /// </returns> public IList <IEvent> ReadEvents() { try { IList <IEvent> listEvent = new List <IEvent>(); IList <TreeItem> treeItemsEventList = new ResultElements().Entries(); if (treeItemsEventList != null && treeItemsEventList.Count != 0) { Button cachedLineDownButton; /*check if scrollDown button is available * exception thrown if it isn't, reading list without scrolling down */ try { cachedLineDownButton = new ResultElements().ButtonLineDown; } catch (Exception) { Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Scroll down button not found, no problem if event list is not scrollable (only a few entries)"); cachedLineDownButton = null; } // make sure first event is visible this.ScrollToTop(); int index; for (index = 0; index < treeItemsEventList.Count; index++) { TreeItem treeItemEvent = treeItemsEventList[index]; IList <Unknown> listCells = treeItemEvent.Children; /*Checks if first cell of actual tree item has no text * This is the case if the description of an event needs more than one row */ if (listCells[Id].As <Cell>().Text.Equals(string.Empty)) { // check if list is empty if it is, cell of first row (event) is empty -> failure if (listEvent.Count == 0) { Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "List empty ?,First cell of first row is empty"); } else { // cell "row" is empty, list is not empty ->add description to previous event: int lastEventIndex = listEvent.Count - 1; this.CreateEventDescription(listCells, listEvent[lastEventIndex]); } } else { // normal event, add to list : listEvent.Add(this.CreateEvent(listCells)); } // if null, no scroll needed if (cachedLineDownButton != null) { this.ScrollDown(cachedLineDownButton); } } return(listEvent); } Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "List is empty!"); return(null); } catch (Exception exception) { Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message); return(null); } }