public virtual void ProcessRecord(ICommandAdapter adapter, string tableName, string actionName, string[] columnCaptions, string[] cellValues) { if (!adapter.IsControlExist(TestControlType.Table, tableName)) { throw new CommandException( string.Format("Cannot find the '{0}' control, OperationTag:'{1}'", tableName, TestControlType.Table), StartPosition); } ITestControl testTable = adapter.CreateTestControl(TestControlType.Table, tableName); var table = testTable.GetInterface <IGridBase>(); IGridColumn actionColumn = null; int rowCount = table.GetRowCount(); if (rowCount == 0 && cellValues.Length > 0) { string message = string.IsNullOrEmpty(tableName) ? "The table is empty" : string.Format("The '{0}' table is empty", tableName); throw new AdapterOperationException(message); } int rowIndex = -1; if (cellValues.Length > 0) { var testControl = testTable.FindInterface <IGridRowsSelection>(); if (testControl != null && !string.IsNullOrEmpty(actionName)) { testControl.ClearSelection(); //B158392 rowIndex = GetRowIndex(testTable, rowCount, columnCaptions, cellValues); testControl.SelectRow(rowIndex); } else { rowIndex = GetRowIndex(testTable, rowCount, columnCaptions, cellValues); } if (rowIndex == -1) { throw new AdapterOperationException( string.Format("The record with the '{0}' value was not found. Checked values: {1}", string.Join(", ", cellValues), GridControlHelper.GetFormatTableValues(null))); } var gridHelper = new GridControlHelper(testTable); List <IGridColumn> columnList = gridHelper.GetColumnIndexes(columnCaptions, false); if (columnList.Count > 0) { actionColumn = columnList[0]; } } Act(actionName, rowIndex, actionColumn, testTable); }
private int GetRowIndex(ITestControl testTable, int rowCount, string[] columnCaptions, string[] cellValues) { var gridHelper = new GridControlHelper(testTable); int rowIndex = -1; if (cellValues.Length > 0) { string[,] tableValues = null; List <IGridColumn> columnList = gridHelper.GetColumnIndexes(columnCaptions, false); rowIndex = gridHelper.SearchRowIndex(columnList, cellValues, rowCount, ref tableValues); if (rowIndex == -1) { throw new AdapterOperationException( string.Format("The record with the '{0}' value was not found. Checked values: {1}", string.Join(", ", cellValues), GridControlHelper.GetFormatTableValues(tableValues))); } } return(rowIndex); }