public static void RunEx(string ResultRoutineInParam, int iHardcodedInParam) { string[] readActualLines = File.ReadAllLines(ResultRoutineInParam); int iNumActualRows = readActualLines.Length; int HardcodedTime = iHardcodedInParam; // 25; // this is the expected time. With this time we compare the actual time for (int i = iNumActualRows - 1; i >= 0; i--) //this for method will work in revers order { bool bExpectedTextRow = readActualLines[i].Contains("END OF INSPECTION"); if (bExpectedTextRow) { string sFinalInspection = readActualLines[i]; string toSearch = ":"; //This will give the first postion of the : symbol. We assume, that there will be two such symbols in the whole string //- one between the hour and the minutes, and one between the minutes and the seconds int idxHourMinute = sFinalInspection.IndexOf(toSearch); string hours = new string(sFinalInspection.ToCharArray(idxHourMinute - 2, 2)); //Offset backwards with two sympols, because we found the position of : character. The second digit (2) means how many digits to take string minutes = new string(sFinalInspection.ToCharArray(idxHourMinute + 1, 2)); string seconds = new string(sFinalInspection.ToCharArray(idxHourMinute + 4, 2)); //We offset with 4, because of the second : character int hh = 0; int mm = 0; int ss = 0; int.TryParse(hours, out hh); int.TryParse(minutes, out mm); int.TryParse(seconds, out ss); int ActualTime = (3600 * hh) + (60 * mm) + ss; if (Mathematics.IsEQ(ActualTime, HardcodedTime, 4)) { ReportAction.RunPositiveResult(ActualTime); } else { if (ActualTime < HardcodedTime) { ReportAction.RunIncreasedResult(ActualTime); } else { ReportAction.RunNegativeResult(ActualTime, HardcodedTime, i); } } break; } } // for (int i = 0; i < iNumResultRows; i++) } // public static void RunEx(int iHardcodedInParam, string ResultRoutineOneInParam)
public static void RunConcentricity(string iHardcodedInParam, string ResultRoutineInParam) { string ConcentricityResult = ResultRoutineInParam; string[] ReadConcentricityResult = Regex.Split(ConcentricityResult, "[\r\n]+"); string HardcodedConcentricityResult = iHardcodedInParam; string[] ReadHardcodedConcentricityResult = Regex.Split(HardcodedConcentricityResult, "[\r\n]+"); System.Diagnostics.Debug.Assert(ReadConcentricityResult.Length - 1 == ReadHardcodedConcentricityResult.Length); //-1 because , the routine writes new line at the end of the file int iNumHardcodedRows = ReadHardcodedConcentricityResult.Length; //string[] sArrConcentricityResult = new string[iNumConcentricityRows]; //Array of strings, that contains the Actual results //string[] sArrHardcodedConcentricityResults = new string[iNumHardcodedRows]; //Array of strings, that contains the Hardcoded results bool bAllConcentricityResultsOK = true; for (int i = 0; i < iNumHardcodedRows; i++) { double dActualConcentricityValue; double dHardcodedConcentricityValue; Double.TryParse(ReadConcentricityResult[i], out dActualConcentricityValue); //Double is object and Try Parse is method in this object. The idea of this method is to convert the given string to value Double.TryParse(ReadHardcodedConcentricityResult[i], out dHardcodedConcentricityValue); Ranorex.Report.Log(Ranorex.ReportLevel.Info, "Actual=" + ReadConcentricityResult[i] + "; Expected=" + ReadHardcodedConcentricityResult[i] + ";"); try { if (!MathematicsConcentricity.IsConcentricityEQ(dActualConcentricityValue, dHardcodedConcentricityValue, 0.005)) { bAllConcentricityResultsOK = false; ReportAction.RunNegativeResult(dActualConcentricityValue, dHardcodedConcentricityValue, i); } else { ReportAction.RunPositiveResult(); } } catch (Exception) { } } }
public static void RunSize(string iHardcodedInParam, string ResultRoutineInParam) { string SizeAcrossResult = ResultRoutineInParam; //Actual results as read from the file string[] ReadSizeAcrossResult = Regex.Split(SizeAcrossResult, "[\r\n]+"); //Convert the number of rows from string to (int) number int iNumActualRows = ReadSizeAcrossResult.Length; string HardcodedSizeAcrossResults = iHardcodedInParam; //Hardcoded results as read from the file string[] ReadHardcodedSizeAcrossResults = Regex.Split(HardcodedSizeAcrossResults, "[\r\n]+"); //Convert the number of rows from string to (int) number int nNumHardcodedRows = ReadHardcodedSizeAcrossResults.Length; bool bAllSizeAcrossResultsOK = true; for (int i = 0; i < nNumHardcodedRows; i++) { double dActualSizeAcrossValue; double dHardcodedSizeAcrossValue; Double.TryParse(ReadSizeAcrossResult[i], out dActualSizeAcrossValue); //Double is object and Try Parse is method in this object. The idea of this method is to convert the given string to value Double.TryParse(ReadHardcodedSizeAcrossResults[i], out dHardcodedSizeAcrossValue); try { if (!Mathemeatics.isEQ(dActualSizeAcrossValue, dHardcodedSizeAcrossValue, 0.005)) { bAllSizeAcrossResultsOK = false; ReportAction.RunNegativeResult(dActualSizeAcrossValue, dHardcodedSizeAcrossValue, i); } else { ReportAction.RunPositiveResult(); } } catch (Exception) { } } } //public static class RunSize