Esempio n. 1
0
        public void GenerateAllSteps()
        {
            CTsInstrFactory.loadConfiguration("C:\\macros_alstom\\Configuration\\LocationConfiguration.xml");
                CTestContainer container = new CTestContainer();

                CTest test = new CTest("Test_1", "This is my description");

                CStep step = new CStep("Step 1", null, null);
        }
Esempio n. 2
0
        public void GenerateScenario()
        {
            CTestContainer container = new CTestContainer();
                container.description = "Test container";
                for (int testIndex = 1; testIndex <= 3; testIndex++)
                {
                    CTest test = new CTest("Test_1." + testIndex, "Test descriptor #" + testIndex);

                    for (int stepIndex = 1; stepIndex < 2; stepIndex++)
                    {
                        string title = "Step " + testIndex + "." + stepIndex;
                        CStep step = new CStep(
                            title,
                             "Action description for " + title,
                             "Check description for " + title
                            );

                        for (int actionIndex = 1; actionIndex < 10; actionIndex++)
                        {
                            CInstruction action = new CInstrForce();
                            CVariableBool var = new CVariableBool("Var" + actionIndex, "Section1/ENV", "/path/to/application" + actionIndex, "true");
                            action.data = var;
                            step.actions.Add(action);
                        }

                        for (int checkIndex = 1; checkIndex < 10; checkIndex++)
                        {
                            CInstruction action = new CInstrTest();
                            CVariableBool var = new CVariableBool("Var" + checkIndex, "Section2/ENV", "/path/to/application" + checkIndex, "true");
                            action.data = var;
                            step.checks.Add(action);
                        }
                        test.Add(step);
                    }
                    container.Add(test);
                }

                string URIFilename = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase) + Path.DirectorySeparatorChar + "templates" + Path.DirectorySeparatorChar + "ST-TestStand4" + Path.DirectorySeparatorChar;
                Uri uri = new Uri(URIFilename);

                TestStandGen.TestStandGen.genSequence(container, "C:\\macros_alstom\\test\\genTest.seq", uri.LocalPath);

                Assert.IsTrue(true);
        }
Esempio n. 3
0
        private void fillWithActions(CStep o_step, TableTypes typeOfTable, Excel.ListObject tableRef, object[,] table, int ColumnIndex)
        {
            logger.Debug(String.Format("Found {0} Excel lines to process.", table.GetLength(0)));
            for (int line = 0; line < table.GetLength(0); line++)
            {
                object CellValue = table[line, ColumnIndex];

                if(!(CellValue is ExcelDna.Integration.ExcelEmpty))
                {
                    string Target = "";
                    if (table[line, tableStructure.TargetColumnIndex] is string) Target = (string)table[line, tableStructure.TargetColumnIndex];
                    string Path = "";
                    if (table[line, tableStructure.PathColumnIndex] is string) Path = (string)table[line, tableStructure.PathColumnIndex];
                    string Location = "";
                    if (table[line, tableStructure.LocationColumnIndex] is string) Location = (string)table[line, tableStructure.LocationColumnIndex];

                    logger.Debug(String.Format("Found item [Target={0}, Location={1}, Path={2}, Value={3}].", Target, Location, Path, CellValue));

                    try
                    {
                        logger.Debug(String.Format("Analysing current item."));
                        CInstruction o_instruction = detectAndBuildInstruction(Target, Location, Path, CellValue, typeOfTable);
                        if (typeOfTable == TableTypes.TABLE_ACTIONS)
                        {
                            logger.Debug("Adding item to list of actions to perform");
                            o_step.actions.Add(o_instruction);
                        }
                        else if (typeOfTable == TableTypes.TABLE_CHECKS)
                        {
                            logger.Debug("Adding item to list of checks to perform");
                            o_step.checks.Add(o_instruction);
                        }
                        else
                            throw new NotImplementedException(String.Format("This type of table ({0}) is not currently implemented", typeOfTable));
                    }
                    catch(InvalidCastException ex)
                    {
                        logger.Error("Problem when trying to find an equivalence for item.", ex);
                        report.add(new MessageReport("Invalid value in cell", tableRef.Range[line + 2, ColumnIndex + 1], ex.Message, Criticity.Error));
                    }
                    catch (Exception ex)
                    {
                        logger.Error("Invalid item processed.", ex);
                        report.add(new MessageReport("Cell problem", tableRef.Range[line + 2, ColumnIndex + 1], ex.Message, Criticity.Error));
                    }
                }
            }
        }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
        private void addTempoIfExists(CStep o_step, Excel.ListObject loSourceFiles, int ColumnIndex)
        {
            //'Delay retrieval. We know that data is contained inside Total line property
            object delay = loSourceFiles.TotalsRowRange.Cells[1, ColumnIndex + 1].Value; // We get values from excel, and array indexes begin with 1, not 0

            if (delay != null)
            {
                try
                {
                    logger.Debug(String.Format("Trying to retrieve temporisation with value \"{0}\".", delay));
                    CInstrWait o_tempo = new CInstrWait();
                    o_tempo.data = Convert.ToInt32(delay);

                    logger.Debug("Adding temporisation to results");
                    o_step.actions.Add(o_tempo);
                }
                catch(Exception ex)
                {
                    logger.Error("Failed to parse temporisation.", ex);
                    report.add(new MessageReport("Invalid value for temporisation", loSourceFiles.TotalsRowRange.Cells[1, ColumnIndex + 1], String.Format("Invalid value, an integer was expected, but we had {0}", delay ), Criticity.Error));
                }
            }
        }