Index: System tests/AutomatedSystemTests/AutomatedSystemTests/AutomatedSystemTestsRepository.rximg =================================================================== diff -u -r1924926fad6108d663390c341167697c19246d0b -r08bfbf5e4ec2bdb5d24e210fb14392ffafaca5e9 Binary files differ Index: System tests/AutomatedSystemTests/AutomatedSystemTests/AutomatedSystemTestsRepository.rxrep =================================================================== diff -u -r1924926fad6108d663390c341167697c19246d0b -r08bfbf5e4ec2bdb5d24e210fb14392ffafaca5e9 --- System tests/AutomatedSystemTests/AutomatedSystemTests/AutomatedSystemTestsRepository.rxrep (.../AutomatedSystemTestsRepository.rxrep) (revision 1924926fad6108d663390c341167697c19246d0b) +++ System tests/AutomatedSystemTests/AutomatedSystemTests/AutomatedSystemTestsRepository.rxrep (.../AutomatedSystemTestsRepository.rxrep) (revision 08bfbf5e4ec2bdb5d24e210fb14392ffafaca5e9) @@ -1258,7 +1258,7 @@ id="5a151305-72de-45f8-b2e3-6fcfc226f361" isrooted="True" name="AssemblySectionsView" - refimgid="16857980-eb80-4181-be65-0dcafebd443e" + refimgid="fb7e1e33-8ce1-42b8-9718-87cf17f5dacb" searchtimeout="30000ms" usecache="False"> allSubsections {get; set;} + + private List listAllLabelsFMs {get; set;} + + private Dictionary dictCategoriesLabels = new Dictionary { + {"-III", 0}, + {"-II", 1}, + {"-I", 2}, + {"0", 3}, + {"+I", 4}, + {"+II", 5}, + {"+III", 6}, + {"-", 7}, + {"NR", 8} + }; + /// /// Constructs a new instance. /// @@ -57,129 +72,97 @@ /// that will in turn invoke this method. void ITestModule.Run() { - Mouse.DefaultMoveTime = 0; - Keyboard.DefaultKeyPressTime = 0; - Delay.SpeedFactor = 0.0; - System.Globalization.CultureInfo currentCulture = CultureInfo.CurrentCulture; - - var trajectAssessmentInformation = TrajectResultInformation.BuildAssessmenTrajectInformation(trajectAssessmentInformationString); - var repo = global::AutomatedSystemTests.AutomatedSystemTestsRepository.Instance; - - var table = repo.RiskeerMainWindow.ContainerMultipleViews.DocumentViewContainer.AssemblySectionsView.Table.Self; - List allSubsections = new List(); - allSubsections.Add(0); - foreach (var fmTrjAssInfo in trajectAssessmentInformation.ListFMsResultInformation) { - foreach (var section in fmTrjAssInfo.SectionList) { - allSubsections.Add(section.EndDistance); - } - } - allSubsections.Sort(); - var allSubsectionsUnique = allSubsections.Distinct().ToList(); - var rowsToIterate = table.Rows.ToList(); - var headerRow = rowsToIterate[0]; - - List fmsToValidate = trajectAssessmentInformation.ListFMsResultInformation.Select(it=>it.Label).ToList(); - int indexSectionNumber = GetIndex(headerRow, "Vaknummer"); - int indexDistanceStart = GetIndex(headerRow, "van* [m]"); - int indexDistanceEnd = GetIndex(headerRow, "tot* [m]"); - int indexCombinedAssessment = GetIndex(headerRow, "Gecombineerd"); - List indecesColumnsFMsToValidate = fmsToValidate.Select(fmLabel=>GetIndex(headerRow, fmLabel)).ToList(); - - Dictionary dicAssemblyLabels = new Dictionary { - {"-", 0}, - {"Iv", 1}, - {"IIv", 2}, - {"IIIv", 3}, - {"IVv", 4}, - {"Vv", 5}, - {"VIv", 6}, - {"VIIv", 7} - }; - - rowsToIterate.RemoveAt(0); + this.trajectResultInformation = TrajectResultInformation.BuildAssessmenTrajectInformation(trajectAssessmentInformationString); + this.allSubsections = CreateSubsections(trajectResultInformation.ListFMsResultInformation); + var rowsTable = AutomatedSystemTests.AutomatedSystemTestsRepository.Instance.RiskeerMainWindow.ContainerMultipleViews.DocumentViewContainer.AssemblySectionsView.Table.Self.Rows; + this.listAllLabelsFMs = rowsTable[0].Cells.Select(cell=>cell.Text).Where(txt=>txt!="").Where(txt=>!txt.Contains("Metrering")).Where(txt=>!txt.Contains("Slechtste duidingsklasse")).ToList(); + rowsTable.RemoveAt(0); int indexRow = 0; - foreach (var row in rowsToIterate) { - var cells = row.Cells.ToList(); - double expectedDistanceStart = allSubsectionsUnique[indexRow]; - double expectedDistanceEnd = allSubsectionsUnique[indexRow + 1]; - double expectedDistanceMiddle = (expectedDistanceStart + expectedDistanceEnd)/2.0; - string CombinedAssessmentSectionLabel = ""; - int worstFMLabel = 0; - for (int i = 0; i < fmsToValidate.Count; i++) { - var currentFMAssInfo = trajectAssessmentInformation.ListFMsResultInformation[i]; - var expectedFMAssessmentLabel = GetAssessmentLabelForDistance(currentFMAssInfo, expectedDistanceMiddle); - if (dicAssemblyLabels[expectedFMAssessmentLabel]>worstFMLabel) { - worstFMLabel = dicAssemblyLabels[expectedFMAssessmentLabel]; - CombinedAssessmentSectionLabel = expectedFMAssessmentLabel; - } - } - Report.Info("Validation for row " + (indexRow + 1).ToString() + "."); - ValidateCell(cells[indexSectionNumber], (indexRow + 1).ToString(), "Validation section number."); - ValidateCell(cells[indexDistanceStart], string.Format("{0:0.00}", expectedDistanceStart), "Validation section start distance along reference line."); - ValidateCell(cells[indexDistanceEnd], string.Format("{0:0.00}", expectedDistanceEnd), "Validation section end distance along reference line."); - ValidateCell(cells[indexCombinedAssessment], CombinedAssessmentSectionLabel, "Validation combined assessment label."); - - - for (int i = 0; i < fmsToValidate.Count; i++) { - var currentFMAssInfo = trajectAssessmentInformation.ListFMsResultInformation[i]; - var expectedFMAssessmentLabel = GetAssessmentLabelForDistance(currentFMAssInfo, expectedDistanceMiddle); - - ValidateCell(cells[indecesColumnsFMsToValidate[i]], expectedFMAssessmentLabel, "Validation assessment label FM " + fmsToValidate[i]); - } + foreach (var row in rowsTable) { + ValidateRowSectionsCombinations(row, indexRow); indexRow++; } } - private void ValidateCell(Cell cell, string expectedValue, string message) + private void ValidateRowSectionsCombinations(Row row, int rowIndex) { - Report.Info(message); - cell.Select(); - string actualValue = GetAV(cell); - Validate.AreEqual(actualValue, expectedValue); + ValidateStartDistanceSubsection(row, rowIndex); + ValidateEndDistanceSubsection(row, rowIndex); + double distanceMiddlePoint = MiddlePoint(row.Cells[1].Text, row.Cells[2].Text); + int cellIndex = 3; + foreach (string labelFM in this.listAllLabelsFMs) { + ValidateCategoryFMInSubsection(row, rowIndex, cellIndex, distanceMiddlePoint, labelFM); + cellIndex++; + } + ValidateCombinedCategorySubsection(row, rowIndex); } - private string GetAssessmentLabelForDistance(FailureMechanismResultInformation fmAssInfo, double distance) + private void ValidateStartDistanceSubsection(Row row, int rowIndex) { - var endSections = fmAssInfo.SectionList.Select(it=>it.EndDistance).ToList(); - int index = endSections.FindIndex(it=> distance(trajectAssessmentInformationString, new JsonSerializerSettings - { - Error = (s, e) => - { - error = true; - e.ErrorContext.Handled = true; - } + ValidateCell(row.Cells[2], string.Format("{0:0.00}",this.allSubsections[rowIndex + 1]), "Validation subsection end distance measured along reference line " + " at row = " + (rowIndex+1).ToString() + "."); + } + + private void ValidateCategoryFMInSubsection(Row row, int rowIndex, int cellIndex, double distance, string labelFM) + { + var currentFMResultInfo = this.trajectResultInformation.ListFMsResultInformation.Where(fm=>fm.Label==labelFM).FirstOrDefault(); + var expectedCategory = currentFMResultInfo==null? "-" : GetCategoryAt(distance, currentFMResultInfo); + ValidateCell(row.Cells[cellIndex], expectedCategory, "Validation categopry for FM = " + labelFM + " at row = " + (rowIndex+1).ToString() + "."); + } + + private void ValidateCombinedCategorySubsection(Row row, int rowIndex) + { + ValidateCell(row.Cells.Last(), WorstCategoryClass(row), "Validation worst category class " + " at row = " + (rowIndex+1).ToString() + "."); + } + + private string WorstCategoryClass(Row row) + { + var fmCells = row.Cells.Select(cl=>cl.Text).ToList().GetRange(3, row.Cells.Count-3); + var worstCategoryValue = fmCells.Select(category=> this.dictCategoriesLabels[category]).Min(); + var worstCategoryClass = this.dictCategoriesLabels.FirstOrDefault(x=>x.Value==worstCategoryValue).Key; + return worstCategoryClass; + } + + private List CreateSubsections(List listFMsResultInfo) + { + var listSubsections = new List(); + listSubsections.Add(0); + foreach (var fmResultInfo in listFMsResultInfo) { + foreach (var section in fmResultInfo.SectionList) { + listSubsections.Add(section.EndDistance); } - ); - if (error==true) { - - Report.Log(ReportLevel.Error, "error unserializing json string for trajectAssessmentInformationString: " + trajectAssessmentInformationString); - } - } - return trajectAssessmentInformation; + listSubsections.Sort(); + return listSubsections.Distinct().ToList(); } - private string GetAV(Cell cl) + private void ValidateCell(Cell cell, string expectedValue, string message) { - return cl.Element.GetAttributeValueText("AccessibleValue"); + Report.Info(message); + cell.Focus(); + cell.Select(); + string actualValue = cell.Element.GetAttributeValueText("AccessibleValue"); + Validate.AreEqual(actualValue, expectedValue); } - private int GetIndex(Row row, string name) + + private double MiddlePoint(string distance1, string distance2) { - return row.Cells.ToList().FindIndex(cl=>GetAV(cl).Contains(name)); + double d1 = Double.Parse(distance1); + double d2 = Double.Parse(distance2); + return (d1+d2)/2.0; } - + + private string GetCategoryAt(double distance, FailureMechanismResultInformation fmResultInfo) + { + var endSections = fmResultInfo.SectionList.Select(it=>it.EndDistance).ToList(); + int index = endSections.FindIndex(it=> distance + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1064,6 +1134,16 @@ + + + + + + @@ -1108,6 +1188,10 @@ name="ValidateFailureProbabilityFM"> + + @@ -1160,6 +1244,16 @@ id="99662edd-33d5-47ba-b495-ace7af131f41" name="ValidateValuesInTable"> + + + + + + + + + + + + + + @@ -1579,6 +1693,28 @@ + + + + + + + + + + + + @@ -2093,6 +2234,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + public string Label{get; set;} - /// - /// The label for the assessment of this FM regarding the entire traject (It, IIt, ..., VIIt) - /// public string AssemblyGroup {get; set;} ///