private CTest parseAsTest(string title) { logger.Debug(String.Format("Extracting columns for action table.")); Excel.ListColumns lcActionsTableColumns = loActionsTable.ListColumns; tableStructure = checkAndDetermineTablecolumns(lcActionsTableColumns); object[,] actionsValues = preloadTable(this.actionTableName); logger.Debug(String.Format("Extracting columns for checks table.")); Excel.ListColumns lcChecksTableColumns = loChecksTable.ListColumns; object[,] checksValues = preloadTable(this.checkTableName); CTest parseSingleTest = new CTest(title, "Description"); logger.Debug(String.Format("Creating Test : {0}", parseSingleTest.ToString())); //''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' //' Writing inputs //''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' logger.Debug(String.Format("Found {0} Excel columns to process.", lcActionsTableColumns.Count)); for (int CurrentColumn = tableStructure.FirstColumnIndex; CurrentColumn < lcActionsTableColumns.Count; CurrentColumn++) { logger.Info(String.Format("Processing Column {0}.", lcActionsTableColumns[CurrentColumn+1].Name)); CStep o_step = new CStep(lcActionsTableColumns[CurrentColumn+1].Name+" : Title retrieval " + getComment(), "Action comment retrieval " + getComment(), "Checks comment retrieval " + getComment()); logger.Debug(String.Format("Processing Actions table.")); fillWithActions(o_step, TableTypes.TABLE_ACTIONS, loActionsTable, actionsValues, CurrentColumn); logger.Debug(String.Format("Processing Timer table.")); addTempoIfExists(o_step, loActionsTable, CurrentColumn); logger.Debug(String.Format("Processing Checks table.")); fillWithActions(o_step, TableTypes.TABLE_CHECKS, loChecksTable, checksValues, CurrentColumn); logger.Debug(String.Format("Adding step to results.")); parseSingleTest.Add(o_step); } return parseSingleTest; }
private TableColumnsStructure checkAndDetermineTablecolumns(Excel.ListColumns lcActionsTableColumns) { TableColumnsStructure tableStructure = new TableColumnsStructure(); for (int CurrentColumn = 1; CurrentColumn < 5; CurrentColumn++) { if (lcActionsTableColumns[CurrentColumn].Name.Equals("Target")) tableStructure.TargetColumnIndex = CurrentColumn - 1; // Indexes from Excel are starting from 1, and we are using 0 based indexes if (lcActionsTableColumns[CurrentColumn].Name.Equals("Location")) tableStructure.LocationColumnIndex = CurrentColumn - 1; // Indexes from Excel are starting from 1, and we are using 0 based indexes if (lcActionsTableColumns[CurrentColumn].Name.Equals("Path")) tableStructure.PathColumnIndex = CurrentColumn - 1; // Indexes from Excel are starting from 1, and we are using 0 based indexes } tableStructure.setFirstColumnIndex(); if(!tableStructure.isValid()) throw new FormatException(String.Format("Table doesn't contains all necessary columns headers : {0}", tableStructure.ToString())); return tableStructure; }