Example #1
0
        /// <summary>
        /// Imports the subsequence stored in the database
        /// </summary>
        /// <param name="frame"></param>
        private void importSubSequence(DataDictionary.Tests.Frame frame)
        {
            string sql = "SELECT TestSequenceID, TestSequenceName FROM TSW_TestSequence";

            OleDbDataAdapter adapter = new OleDbDataAdapter(sql, Connection);
            DataSet          dataSet = new DataSet();

            adapter.Fill(dataSet);

            if (dataSet.Tables.Count > 0)
            {
                foreach (DataRow dataRow in dataSet.Tables[0].Rows)
                {
                    int    subSequenceID   = (int)dataRow.ItemArray.GetValue(0);
                    string subSequenceName = (string)dataRow.ItemArray.GetValue(1);

                    DataDictionary.Tests.SubSequence newSubSequence = (DataDictionary.Tests.SubSequence)DataDictionary.Generated.acceptor.getFactory().createSubSequence();
                    newSubSequence.Name = subSequenceName;
                    importInitialValues(newSubSequence, subSequenceID);
                    importSteps(newSubSequence);

                    DataDictionary.Tests.SubSequence oldSubSequence = frame.findSubSequence(subSequenceName);
                    if (oldSubSequence != null)
                    {
                        int cnt = 0;
                        foreach (DataDictionary.Tests.TestCase oldTestCase in oldSubSequence.TestCases)
                        {
                            if (cnt < newSubSequence.TestCases.Count)
                            {
                                DataDictionary.Tests.TestCase newTestCase = newSubSequence.TestCases[cnt] as DataDictionary.Tests.TestCase;
                                if (newTestCase != null)
                                {
                                    if (oldTestCase.Name.Equals(newTestCase.Name))
                                    {
                                        newTestCase.Merge(oldTestCase);
                                    }
                                    else
                                    {
                                        throw new Exception(newTestCase.FullName + " is found instead of " + oldTestCase.FullName + " while importing sub-sequence " + newSubSequence.FullName);
                                    }
                                }
                            }
                            else
                            {
                                throw new Exception("The test case " + oldTestCase.FullName + " is not present in the new data base");
                            }
                            cnt++;
                        }

                        oldSubSequence.Delete();
                    }

                    frame.appendSubSequences(newSubSequence);
                }
            }
            else
            {
                Log.Error("Cannot find table TSW_TestSequence in database");
            }
        }
Example #2
0
 /// <summary>
 /// Sets the current sub sequence window parameters
 /// </summary>
 /// <param name="subSequence"></param>
 public void setSubSequence(DataDictionary.Tests.SubSequence subSequence)
 {
     Invoke((MethodInvoker) delegate
     {
         subSequenceSelectorComboBox.Text = subSequence.Name;
         setFrame(subSequence.Frame);
         Refresh();
     });
 }
Example #3
0
        /// <summary>
        ///     Creates a test case in the enclosing test sub sequence
        /// </summary>
        /// <param name="enclosing"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        protected TestCase CreateTestCase(SubSequence enclosing, string name)
        {
            TestCase retVal = (TestCase)Factory.createTestCase();

            enclosing.appendTestCases(retVal);
            retVal.Name = name;

            return(retVal);
        }
Example #4
0
        /// <summary>
        ///     Creates a test sub sequence in the enclosing test frame
        /// </summary>
        /// <param name="enclosing"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        protected SubSequence CreateSubSequence(Frame enclosing, string name)
        {
            SubSequence retVal = (SubSequence)Factory.createSubSequence();

            enclosing.appendSubSequences(retVal);
            retVal.Name = name;

            return(retVal);
        }
Example #5
0
 /// <summary>
 /// Constructor: creates a report for the selected sub sequence
 /// </summary>
 /// <param name="aSubSequence"></param>
 public TestReport(DataDictionary.Tests.SubSequence aSubSequence)
 {
     InitializeComponent();
     EFSSystem                 = aSubSequence.EFSSystem;
     reportHandler             = new TestsCoverageReportHandler(aSubSequence.Dictionary);
     reportHandler.SubSequence = aSubSequence;
     InitializeCheckBoxes(2);
     TxtB_Path.Text = reportHandler.FileName;
 }
Example #6
0
        /// <summary>
        ///     Indicates whether the timeline should display the element
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        public override bool ShouldDisplayModelElement(IModelElement element)
        {
            bool retVal = element == null;

            retVal = retVal || (Translation != null && Translation.IsParent(element));
            retVal = retVal || (SubSequence != null && SubSequence.IsParent(element));
            retVal = retVal || (TestCase != null && TestCase.IsParent(element));

            return(retVal);
        }
Example #7
0
 /// <summary>
 /// Selects the current test sequence by clicking on the label
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void toolStripLabel2_Click(object sender, EventArgs e)
 {
     if (EFSSystem.Runner != null)
     {
         DataDictionary.Tests.SubSequence subSequence = EFSSystem.Runner.SubSequence;
         if (subSequence != null)
         {
             MDIWindow.Select(subSequence);
         }
     }
 }
        /// <summary>
        /// Creates a new sub sequence in the corresponding frame
        /// </summary>
        /// <param name="subSequenceName"></param>
        /// <returns></returns>
        public SubSequenceTreeNode createSubSequence(DataDictionary.Tests.SubSequence subSequence)
        {
            SubSequenceTreeNode retVal;

            subSequence.Enclosing = Item;
            Item.appendSubSequences(subSequence);

            retVal = new SubSequenceTreeNode(subSequence);
            Nodes.Add(retVal);
            SortSubNodes();

            return(retVal);
        }
Example #9
0
 /// <summary>
 /// Ensures that the runner is not empty
 /// </summary>
 private void CheckRunner()
 {
     if (EFSSystem.Runner == null)
     {
         if (Frame != null)
         {
             DataDictionary.Tests.SubSequence subSequence = Frame.findSubSequence(subSequenceSelectorComboBox.Text);
             if (subSequence != null)
             {
                 EFSSystem.Runner = new DataDictionary.Tests.Runner.Runner(subSequence);
             }
         }
     }
 }
Example #10
0
        /// <summary>
        /// The runner
        /// </summary>
        public DataDictionary.Tests.Runner.Runner getRunner(DataDictionary.Tests.SubSequence subSequence)
        {
            if (EFSSystem.Runner == null)
            {
                foreach (DataDictionary.Dictionary dictionary in EFSSystem.Dictionaries)
                {
                    if (subSequence != null)
                    {
                        EFSSystem.Runner = new DataDictionary.Tests.Runner.Runner(subSequence);
                        break;
                    }
                }
            }

            return(EFSSystem.Runner);
        }
        /// <summary>
        /// Creates the description of the sub sequence
        /// </summary>
        /// <param name="subSequence"></param>
        private void CreateSubSequenceDescription(SubSequence subSequence)
        {
            Report.AddSubParagraph(subSequence.Name);
            Report.AddParagraph("Subsequence description");

            Report.AddTable(new[] { "Step", "Description", "Comment" }, new[] { 10, 80, 80 });
            foreach (TestCase testCase in subSequence.TestCases)
            {
                bool testCaseIntroduced = false;

                // Report test cases where requirements have been associated to
                if (testCase.Requirements.Count > 0)
                {
                    IntroduceTestCase(testCase);
                    testCaseIntroduced = true;
                }

                foreach (Step step in testCase.Steps)
                {
                    if (step.getTCS_Order() != 0 || step.Requirements.Count > 0)
                    {
                        if (!testCaseIntroduced)
                        {
                            // Report test cases when there are relevant steps in it
                            IntroduceTestCase(testCase);
                            testCaseIntroduced = true;
                        }

                        Report.AddRow(
                            step.getTCS_Order().ToString(CultureInfo.InvariantCulture),
                            step.getDescription(),
                            step.Comment);

                        ReportIssue(step);
                    }
                }
            }

            Report.CloseSubParagraph();
        }
        /// <summary>
        /// Describes a specific Subset-076 specification issue
        /// </summary>
        /// <param name="paragraph"></param>
        private void DescribeSpecIssue(Paragraph paragraph)
        {
            if (paragraph.SubParagraphs.Count > 0)
            {
                Report.AddSubParagraph(paragraph.Name);
                Report.AddTable(new[] { "SubSequence", "Test case", "Step", "Comment" }, new[] { 60, 20, 10, 80 });
                foreach (Paragraph subParagraph in paragraph.SubParagraphs)
                {
                    DescribeSpecIssue(subParagraph);
                }
                Report.CloseSubParagraph();
            }
            else
            {
                Report.AddRow(paragraph.ExpressionText);
                Report.SetLastRowColor(IssueColor(paragraph));

                if (paragraph.Implementations.Count > 0)
                {
                    foreach (ReqRef reqRef in paragraph.Implementations)
                    {
                        SubSequence subSequence = EnclosingFinder <SubSequence> .find(reqRef, true);

                        TestCase testCase = EnclosingFinder <TestCase> .find(reqRef, true);

                        Step step = EnclosingFinder <Step> .find(reqRef, true);

                        Report.AddRow(
                            subSequence != null ? subSequence.Name : "",
                            testCase != null ? testCase.getFeature().ToString(CultureInfo.InvariantCulture) : "",
                            step != null ? step.getTCS_Order().ToString(CultureInfo.InvariantCulture) : "",
                            reqRef.Comment);
                    }
                }
            }
        }
        /// <summary>
        ///     Creates a test case in the enclosing test sub sequence
        /// </summary>
        /// <param name="enclosing"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        protected TestCase CreateTestCase(SubSequence enclosing, string name)
        {
            TestCase retVal = (TestCase) Factory.createTestCase();
            enclosing.appendTestCases(retVal);
            retVal.Name = name;

            return retVal;
        }
        /// <summary>
        ///     Imports the subsequence stored in the database
        /// </summary>
        /// <param name="frame"></param>
        private void importInitialValues(SubSequence subSequence, int subSequenceID)
        {
            // Level is a reserved word...
            string sql =
                "SELECT D_LRBG, TSW_TestSeqSCItl.Level, Mode, NID_LRBG, Q_DIRLRBG, Q_DIRTRAIN, Q_DLRBG, RBC_ID, RBCPhone FROM TSW_TestSeqSCItl WHERE TestSequenceID = " +
                subSequenceID;

            OleDbDataAdapter adapter = new OleDbDataAdapter(sql, Connection);
            DataSet dataSet = new DataSet();

            adapter.Fill(dataSet);
            if (dataSet.Tables.Count > 0)
            {
                foreach (DataRow dataRow in dataSet.Tables[0].Rows)
                {
                    int i = 0;
                    string D_LRBG = dataRow.ItemArray.GetValue(i++) as string;
                    string Level = dataRow.ItemArray.GetValue(i++) as string;
                    string Mode = dataRow.ItemArray.GetValue(i++) as string;
                    string NID_LRBG = dataRow.ItemArray.GetValue(i++) as string;
                    string Q_DIRLRBG = dataRow.ItemArray.GetValue(i++) as string;
                    string Q_DIRTRAIN = dataRow.ItemArray.GetValue(i++) as string;
                    string Q_DLRBG = dataRow.ItemArray.GetValue(i++) as string;
                    string RBC_ID = dataRow.ItemArray.GetValue(i++) as string;
                    string RBCPhone = dataRow.ItemArray.GetValue(i++) as string;

                    subSequence.setD_LRBG(D_LRBG);
                    subSequence.setLevel(Level);
                    subSequence.setMode(Mode);
                    subSequence.setNID_LRBG(NID_LRBG);
                    subSequence.setQ_DIRLRBG(Q_DIRLRBG);
                    subSequence.setQ_DIRTRAIN(Q_DIRTRAIN);
                    subSequence.setQ_DLRBG(Q_DLRBG);
                    subSequence.setRBC_ID(RBC_ID);
                    subSequence.setRBCPhone(RBCPhone);

                    TestCase testCase = (TestCase) acceptor.getFactory().createTestCase();
                    testCase.Name = "Setup";
                    subSequence.appendTestCases(testCase);

                    Step initializeTrainDataStep = (Step) acceptor.getFactory().createStep();
                    ;
                    initializeTrainDataStep.setTCS_Order(0);
                    initializeTrainDataStep.setDistance(0);
                    initializeTrainDataStep.setDescription("Initialize train data");
                    initializeTrainDataStep.setTranslationRequired(true);
                    testCase.appendSteps(initializeTrainDataStep);

                    Step DefaultValuesStep = (Step) acceptor.getFactory().createStep();
                    ;
                    DefaultValuesStep.setTCS_Order(0);
                    DefaultValuesStep.setDistance(0);
                    DefaultValuesStep.setDescription("Set default values");
                    DefaultValuesStep.setTranslationRequired(true);
                    testCase.appendSteps(DefaultValuesStep);

                    Step manualSetupStep = (Step) acceptor.getFactory().createStep();
                    ;
                    manualSetupStep.setTCS_Order(0);
                    manualSetupStep.setDistance(0);
                    manualSetupStep.setDescription("Manual setup test sequence");
                    manualSetupStep.setTranslationRequired(false);
                    testCase.appendSteps(manualSetupStep);
                }
            }
            else
            {
                Log.Error("Cannot find entry in table TSW_TestSeqSCItl WHERE TestSequenceID = " + subSequenceID);
            }
        }
 public void AddHandler(object sender, EventArgs args)
 {
     DataDictionary.Tests.SubSequence subSequence = (DataDictionary.Tests.SubSequence)DataDictionary.Generated.acceptor.getFactory().createSubSequence();
     subSequence.Name = "Sequence" + (GetNodeCount(false) + 1);
     createSubSequence(subSequence);
 }
        /// <summary>
        ///     Imports the steps in a sub sequence
        /// </summary>
        /// <param name="subSequence"></param>
        private void ImportSteps(SubSequence subSequence)
        {
            const string sql = "SELECT TCSOrder, Distance, FT_NUMBER, TC_NUMBER, ST_STEP, ST_DESCRIPTION, UserComment, ST_IO, ST_INTERFACE, ST_COMMENTS, TestLevelIn, TestLevelOut, TestModeIn, TestModeOut FROM TSW_TCStep ORDER BY TCSOrder";

            OleDbDataAdapter adapter = new OleDbDataAdapter(sql, Connection);
            DataSet dataSet = new DataSet();

            adapter.Fill(dataSet);
            if (dataSet.Tables.Count > 0)
            {
                TestCase testCase = null;
                int previousDistance = 0;

                foreach (DataRow dataRow in dataSet.Tables[0].Rows)
                {
                    object[] items = dataRow.ItemArray;
                    int order = (int) items[0];
                    string distance = ((int) items[1]).ToString(CultureInfo.InvariantCulture) + ".0";
                    int feature = (int) items[2];
                    int testCaseNr = (int) items[3];
                    string stepType = items[4] as string;
                    string description = items[5] as string;
                    string userComment = items[6] as string;
                    string io = items[7] as string;
                    string intrface = items[8] as string;
                    string comment = items[9] as string;
                    string testLevelIn = items[10] as string;
                    string testLevelOut = items[11] as string;
                    string testModeIn = items[12] as string;
                    string testModeOut = items[13] as string;

                    // we do not want to import steps "Followed by" or "Preceded by"
                    if (io != null && stepType != null && !stepType.Equals("Followed by") &&
                        !stepType.Equals("Preceded by"))
                    {
                        if (testCase != null)
                        {
                            if (testCase.getFeature() != feature || testCase.getCase() != testCaseNr)
                            {
                                testCase = null;
                            }
                        }

                        if (testCase == null)
                        {
                            testCase = (TestCase) acceptor.getFactory().createTestCase();
                            testCase.Name = "Feature " + feature + " Test case " + testCaseNr;
                            testCase.setCase(testCaseNr);
                            testCase.setFeature(feature);
                            subSequence.appendTestCases(testCase);
                            Step setupTestCaseStep = (Step) acceptor.getFactory().createStep();
                            setupTestCaseStep.Name = "Setup test case";
                            setupTestCaseStep.setDistance(distance);
                            setupTestCaseStep.setDescription(setupTestCaseStep.Name);
                            setupTestCaseStep.setComment("This step is used to setup the test case " + testCaseNr +
                                                         " feature " + feature);
                            setupTestCaseStep.setTranslationRequired(true);
                            testCase.appendSteps(setupTestCaseStep);
                        }

                        Step step = (Step) acceptor.getFactory().createStep();
                        step.Name = "Step " + order;
                        step.setTCS_Order(order);
                        step.setDistance(distance);
                        step.setDescription(description);
                        step.setUserComment(userComment);
                        step.setIO_AsString(io);
                        if (intrface != null)
                        {
                            step.setInterface_AsString(intrface);
                        }
                        step.setComment(comment);
                        if (testLevelIn != null)
                        {
                            step.setLevelIN_AsString(testLevelIn);
                        }
                        if (testLevelOut != null)
                        {
                            step.setLevelOUT_AsString(testLevelOut);
                        }
                        if (testModeIn != null)
                        {
                            step.setModeIN_AsString(testModeIn);
                        }
                        if (testModeOut != null)
                        {
                            step.setModeOUT_AsString(testModeOut);
                        }

                        //Steps who's distance goes back to 0 are steps that don't exist in the related word file. We import them immediately as manual translations linked to the appropriate comment.
                        if (previousDistance > 0 && (int)items[1] == 0)
                        {
                            step.setTranslationRequired(false);
                            step.setTranslated(true);
                            DataDictionary.ModelElement modelElement = GuidCache.Instance.GetModel("1c0febd1-8736-452d-9d17-14971b39b5b5");
                            if (modelElement != null)
                            {
                                Paragraph paragraph = modelElement as Paragraph;

                                if (paragraph != null)
                                {
                                    step.FindOrCreateReqRef(paragraph);
                                }
                                else
                                {
                                    throw new Exception("Guid error : the Guid for \"Step not translated. It does not appear in the test description\" does not reference a paragraph.");
                                }
                            }
                            else
                            {
                                throw new Exception("Guid error : the Guid for \"Step not translated. It does not appear in the test description\" does not reference anything.");
                            }
                        }
                        else
                        {
                            step.setTranslationRequired(true);
                            previousDistance = (int)items[1];
                        }

                        ImportStepMessages(step);

                        testCase.appendSteps(step);

                    }
                }
            }
            else
            {
                throw new Exception("Cannot find sub sequence table in database");
            }
        }
Example #17
0
        /// <summary>
        ///     Imports the subsequence stored in the database
        /// </summary>
        /// <param name="subSequence"></param>
        /// <param name="subSequenceId"></param>
        private void ImportInitialValues(SubSequence subSequence, int subSequenceId)
        {
            // Level is a reserved word...
            string sql =
                "SELECT D_LRBG, TSW_TestSeqSCItl.Level, Mode, NID_LRBG, Q_DIRLRBG, Q_DIRTRAIN, Q_DLRBG, RBC_ID, RBCPhone FROM TSW_TestSeqSCItl WHERE TestSequenceID = " +
                subSequenceId;

            OleDbDataAdapter adapter = new OleDbDataAdapter(sql, Connection);
            DataSet          dataSet = new DataSet();

            adapter.Fill(dataSet);
            if (dataSet.Tables.Count > 0)
            {
                foreach (DataRow dataRow in dataSet.Tables[0].Rows)
                {
                    int i = 0;
                    // ReSharper disable InconsistentNaming
                    string D_LRBG     = dataRow.ItemArray.GetValue(i++) as string;
                    string Level      = dataRow.ItemArray.GetValue(i++) as string;
                    string Mode       = dataRow.ItemArray.GetValue(i++) as string;
                    string NID_LRBG   = dataRow.ItemArray.GetValue(i++) as string;
                    string Q_DIRLRBG  = dataRow.ItemArray.GetValue(i++) as string;
                    string Q_DIRTRAIN = dataRow.ItemArray.GetValue(i++) as string;
                    string Q_DLRBG    = dataRow.ItemArray.GetValue(i++) as string;
                    string RBC_ID     = dataRow.ItemArray.GetValue(i++) as string;
                    string RBCPhone   = dataRow.ItemArray.GetValue(i++) as string;
                    // ReSharper restore InconsistentNaming

                    subSequence.setD_LRBG(D_LRBG);
                    subSequence.setLevel(Level);
                    subSequence.setMode(Mode);
                    subSequence.setNID_LRBG(NID_LRBG);
                    subSequence.setQ_DIRLRBG(Q_DIRLRBG);
                    subSequence.setQ_DIRTRAIN(Q_DIRTRAIN);
                    subSequence.setQ_DLRBG(Q_DLRBG);
                    subSequence.setRBC_ID(RBC_ID);
                    subSequence.setRBCPhone(RBCPhone);

                    TestCase testCase = (TestCase)acceptor.getFactory().createTestCase();
                    testCase.Name = "Setup";
                    subSequence.appendTestCases(testCase);

                    Step initializeTrainDataStep = (Step)acceptor.getFactory().createStep();

                    initializeTrainDataStep.setTCS_Order(0);
                    initializeTrainDataStep.setDistance("0");
                    initializeTrainDataStep.setDescription("Initialize train data");
                    initializeTrainDataStep.setTranslationRequired(true);
                    testCase.appendSteps(initializeTrainDataStep);

                    Step defaultValuesStep = (Step)acceptor.getFactory().createStep();

                    defaultValuesStep.setTCS_Order(0);
                    defaultValuesStep.setDistance("0");
                    defaultValuesStep.setDescription("Set default values");
                    defaultValuesStep.setTranslationRequired(true);
                    testCase.appendSteps(defaultValuesStep);

                    Step manualSetupStep = (Step)acceptor.getFactory().createStep();

                    manualSetupStep.setTCS_Order(0);
                    manualSetupStep.setDistance("0");
                    manualSetupStep.setDescription("Manual setup test sequence");
                    manualSetupStep.setTranslationRequired(false);
                    testCase.appendSteps(manualSetupStep);
                }
            }
            else
            {
                throw new Exception("Cannot find entry in table TSW_TestSeqSCItl WHERE TestSequenceID = " + subSequenceId);
            }
        }
Example #18
0
        /// <summary>
        ///     Imports the subsequence stored in the database
        /// </summary>
        /// <param name="frame"></param>
        /// <param name="keepManualTranslations">Indicates that manual translation for be kept during import</param>
        private void ImportSubSequence(Frame frame, bool keepManualTranslations)
        {
            const string sql = "SELECT TestSequenceID, TestSequenceName FROM TSW_TestSequence";

            OleDbDataAdapter adapter = new OleDbDataAdapter(sql, Connection);
            DataSet          dataSet = new DataSet();

            adapter.Fill(dataSet);

            if (dataSet.Tables.Count > 0)
            {
                foreach (DataRow dataRow in dataSet.Tables[0].Rows)
                {
                    int    subSequenceId   = (int)dataRow.ItemArray.GetValue(0);
                    string subSequenceName = (string)dataRow.ItemArray.GetValue(1);

                    SubSequence newSubSequence = (SubSequence)acceptor.getFactory().createSubSequence();
                    newSubSequence.Name = subSequenceName;
                    ImportInitialValues(newSubSequence, subSequenceId);
                    ImportSteps(newSubSequence);
                    newSubSequence.setCompleted(false);

                    SubSequence previousSubSequence = frame.findSubSequence(subSequenceName);
                    if (previousSubSequence != null)
                    {
                        newSubSequence.setGuid(previousSubSequence.getGuid());
                        newSubSequence.setCompleted(previousSubSequence.getCompleted());
                        int cnt = 0;
                        foreach (TestCase previousTestCase in previousSubSequence.TestCases)
                        {
                            if (cnt < newSubSequence.TestCases.Count)
                            {
                                TestCase newTestCase = newSubSequence.TestCases[cnt] as TestCase;
                                if (newTestCase != null)
                                {
                                    if (previousTestCase.Name.Equals(newTestCase.Name))
                                    {
                                        newTestCase.Merge(previousTestCase, keepManualTranslations);
                                    }
                                    else
                                    {
                                        throw new Exception(newTestCase.FullName + " is found instead of " +
                                                            previousTestCase.FullName + " while importing sub-sequence " +
                                                            newSubSequence.FullName);
                                    }
                                }
                            }
                            else
                            {
                                throw new Exception("The test case " + previousTestCase.FullName +
                                                    " is not present in the new data base");
                            }
                            cnt++;
                        }

                        previousSubSequence.Delete();
                    }

                    frame.appendSubSequences(newSubSequence);
                }
            }
            else
            {
                throw new Exception("Cannot find table TSW_TestSequence in database");
            }
        }
        // The sheets of the workbook are:                       \\
        //                                                       \\
        // Sheet number 1,  name: Train (main)                   \\
        // Sheet number 2,  name: Track                          \\
        // Sheet number 3,  name: National values                \\
        // Sheet number 4,  name: Fixed values                   \\
        // Sheet number 5,  name: Brake parameters (lambda)      \\  L
        // Sheet number 6,  name: Brake parameters (gamma)       \\  G
        // Sheet number 7,  name: Correction factor Kdry_rst     \\  G
        // Sheet number 8,  name: Integrated correction factors  \\  L
        // Sheet number 9,  name: Lambda train deceleration      \\  L
        // Sheet number 10, name: Gamma train deceleration       \\  G
        // Sheet number 11, name: Curves Gamma train             \\  G
        // Sheet number 12, name: Calc Gamma                     \\  G (hidden)
        // Sheet number 13, name: Curves Lambda train            \\  L
        // Sheet number 14, name: Calc Lambda                    \\  L (hidden)
        /// <summary>
        ///     Launches import of the excel file in the background task
        /// </summary>
        /// <param name="arg"></param>
        public override void ExecuteWork()
        {
            if (TheDictionary != null)
            {
                Application application = new Application();
                try
                {
                    Workbook workbook = application.Workbooks.Open(FileName);
                    Worksheet trainData = workbook.Sheets[1] as Worksheet;
                    Range aRange = trainData.UsedRange;
                    string trainTypeName = (string)(aRange.Cells[14, 4] as Range).Value2;
                    bool trainIsGamma = false;
                    if (trainTypeName.Equals("Gamma"))
                    {
                        trainIsGamma = true;
                    }
                    else if (!trainTypeName.Equals("Lambda"))
                    {
                        new Exception("Unknown train type");
                    }

                    Frame newFrame = new Frame();
                    newFrame.Name = FrameName;
                    newFrame.setCycleDuration("Kernel.CycleDuration");
                    TheDictionary.AddModelElement(newFrame);

                    SubSequence newSubSequence = new SubSequence();
                    newSubSequence.Name = FrameName;
                    newFrame.AddModelElement(newSubSequence);

                    TestCase aTestCase = new TestCase();
                    aTestCase.Name = "Setup";
                    aTestCase.NeedsRequirement = false;
                    newSubSequence.AddModelElement(aTestCase);

                    intializeEFS(aTestCase, workbook);

                    aTestCase = new TestCase();
                    aTestCase.Name = "Initialize input";
                    aTestCase.NeedsRequirement = false;
                    newSubSequence.AddModelElement(aTestCase);
                    if (trainIsGamma)
                    {
                        initializeInputForGamma(aTestCase, workbook);
                    }
                    else
                    {
                        initializeInputForLambda(aTestCase, workbook);
                    }

                    aTestCase = new TestCase();
                    aTestCase.Name = "Verify input";
                    aTestCase.NeedsRequirement = false;
                    newSubSequence.AddModelElement(aTestCase);
                    if (trainIsGamma)
                    {
                        verifyInputForGamma(aTestCase, workbook);
                    }
                    else
                    {
                        verifyInputForLambda(aTestCase, workbook);
                    }

                    aTestCase = new TestCase();
                    aTestCase.Name = "Verify output";
                    aTestCase.NeedsRequirement = false;
                    newSubSequence.AddModelElement(aTestCase);
                    verifyOutputForTrains(trainIsGamma, aTestCase, workbook);
                }
                catch (Exception e)
                {
                    Log.ErrorFormat(e.Message);
                }
                application.Quit();
            }
        }
        /// <summary>
        ///     Creates a section for a given sub-sequence
        /// </summary>
        /// <param name="aSubSequence">A sub-sequence to be displayed</param>
        /// <param name="aReportConfig">The report configuration containing display details</param>
        /// <param name="activatedRules">The list that will contain the rules activated by this sub-sequence</param>
        /// <param name="createPdf">Indicates if the information about this sub-sequence has to be added to the pdf</param>
        public void CreateSubSequenceSection(SubSequence aSubSequence, TestsCoverageReportHandler aReportConfig,
            HashSet<RuleCondition> activatedRules, bool createPdf)
        {
            string title = "Sub sequence " + aSubSequence.Name;
            if (createPdf)
            {
                AddSubParagraph(title);
            }

            HashSet<RuleCondition> rules = new HashSet<RuleCondition>();
            aSubSequence.EFSSystem.Runner = new Runner(aSubSequence, false, false, true);
            foreach (TestCase testCase in aSubSequence.TestCases)
            {
                // SIDE EFFECT:
                // each test case will calculate the list of rules it activates
                // and add them to activatedRules list
                CreateTestCaseSection(aSubSequence.EFSSystem.Runner, testCase, aReportConfig, rules,
                    createPdf && aReportConfig.AddTestCases);
            }
            activatedRules.UnionWith(rules);

            // now we  can create the table with the current sub sequence statistics
            if (createPdf)
            {
                CreateActivatedRulesSection(title,
                    rules,
                    aReportConfig.Dictionary.ImplementedRules,
                    aReportConfig.AddActivatedRulesInSubSequences);

                CloseSubParagraph();
            }
        }
Example #21
0
 public void AddHandler(object sender, EventArgs args)
 {
     Item.appendSubSequences(SubSequence.CreateDefault(Item.SubSequences));
 }
        /// <summary>
        ///     Imports the steps in a sub sequence
        /// </summary>
        /// <param name="subSequence"></param>
        private void importSteps(SubSequence subSequence)
        {
            string sql =
                "SELECT TCSOrder, Distance, FT_NUMBER, TC_NUMBER, ST_STEP, ST_DESCRIPTION, UserComment, ST_IO, ST_INTERFACE, ST_COMMENTS, TestLevelIn, TestLevelOut, TestModeIn, TestModeOut FROM TSW_TCStep ORDER BY TCSOrder";

            OleDbDataAdapter adapter = new OleDbDataAdapter(sql, Connection);
            DataSet dataSet = new DataSet();

            adapter.Fill(dataSet);
            if (dataSet.Tables.Count > 0)
            {
                TestCase testCase = null;

                foreach (DataRow dataRow in dataSet.Tables[0].Rows)
                {
                    object[] items = dataRow.ItemArray;
                    int order = (int) items[0];
                    int distance = (int) items[1];
                    int feature = (int) items[2];
                    int testCaseNr = (int) items[3];
                    string stepType = items[4] as string;
                    string description = items[5] as string;
                    string userComment = items[6] as string;
                    string io = items[7] as string;
                    string intrface = items[8] as string;
                    string comment = items[9] as string;
                    string testLevelIn = items[10] as string;
                    string testLevelOut = items[11] as string;
                    string testModeIn = items[12] as string;
                    string testModeOut = items[13] as string;

                    // we do not want to import steps "Followed by" or "Preceded by"
                    if (io != null && stepType != null && !stepType.Equals("Followed by") &&
                        !stepType.Equals("Preceded by"))
                    {
                        if (testCase != null)
                        {
                            if (testCase.getFeature() != feature || testCase.getCase() != testCaseNr)
                            {
                                testCase = null;
                            }
                        }

                        if (testCase == null)
                        {
                            testCase = (TestCase) acceptor.getFactory().createTestCase();
                            testCase.Name = "Feature " + feature + " Test case " + testCaseNr;
                            testCase.setCase(testCaseNr);
                            testCase.setFeature(feature);
                            subSequence.appendTestCases(testCase);
                            Step setupTestCaseStep = (Step) acceptor.getFactory().createStep();
                            setupTestCaseStep.Name = "Setup test case";
                            setupTestCaseStep.setDescription(setupTestCaseStep.Name);
                            setupTestCaseStep.setComment("This step is used to setup the test case " + testCaseNr +
                                                         " feature " + feature);
                            setupTestCaseStep.setTranslationRequired(true);
                            testCase.appendSteps(setupTestCaseStep);
                        }

                        Step step = (Step) acceptor.getFactory().createStep();
                        step.Name = "Step " + order;
                        step.setTCS_Order(order);
                        step.setDistance(distance);
                        step.setDescription(description);
                        step.setUserComment(userComment);
                        step.setIO_AsString(io);
                        if (intrface != null)
                        {
                            step.setInterface_AsString(intrface);
                        }
                        step.setComment(comment);
                        if (testLevelIn != null)
                        {
                            step.setLevelIN_AsString(testLevelIn);
                        }
                        if (testLevelOut != null)
                        {
                            step.setLevelOUT_AsString(testLevelOut);
                        }
                        if (testModeIn != null)
                        {
                            step.setModeIN_AsString(testModeIn);
                        }
                        if (testModeOut != null)
                        {
                            step.setModeOUT_AsString(testModeOut);
                        }
                        step.setTranslationRequired(true);

                        importStepMessages(step);

                        testCase.appendSteps(step);
                    }
                }
            }
            else
            {
                Log.Error("Cannot find sub sequence table in database");
            }
        }
Example #23
0
        /// <summary>
        /// Imports the subsequence stored in the database
        /// </summary>
        /// <param name="frame"></param>
        private void importInitialValues(DataDictionary.Tests.SubSequence subSequence, int subSequenceID)
        {
            // Level is a reserved word...
            string sql = "SELECT D_LRBG, TSW_TestSeqSCItl.Level, Mode, NID_LRBG, Q_DIRLRBG, Q_DIRTRAIN, Q_DLRBG, RBC_ID, RBCPhone FROM TSW_TestSeqSCItl WHERE TestSequenceID = " + subSequenceID;

            OleDbDataAdapter adapter = new OleDbDataAdapter(sql, Connection);
            DataSet          dataSet = new DataSet();

            adapter.Fill(dataSet);
            if (dataSet.Tables.Count > 0)
            {
                foreach (DataRow dataRow in dataSet.Tables[0].Rows)
                {
                    int    i          = 0;
                    string D_LRBG     = dataRow.ItemArray.GetValue(i++) as string;
                    string Level      = dataRow.ItemArray.GetValue(i++) as string;
                    string Mode       = dataRow.ItemArray.GetValue(i++) as string;
                    string NID_LRBG   = dataRow.ItemArray.GetValue(i++) as string;
                    string Q_DIRLRBG  = dataRow.ItemArray.GetValue(i++) as string;
                    string Q_DIRTRAIN = dataRow.ItemArray.GetValue(i++) as string;
                    string Q_DLRBG    = dataRow.ItemArray.GetValue(i++) as string;
                    string RBC_ID     = dataRow.ItemArray.GetValue(i++) as string;
                    string RBCPhone   = dataRow.ItemArray.GetValue(i++) as string;

                    subSequence.setD_LRBG(D_LRBG);
                    subSequence.setLevel(Level);
                    subSequence.setMode(Mode);
                    subSequence.setNID_LRBG(NID_LRBG);
                    subSequence.setQ_DIRLRBG(Q_DIRLRBG);
                    subSequence.setQ_DIRTRAIN(Q_DIRTRAIN);
                    subSequence.setQ_DLRBG(Q_DLRBG);
                    subSequence.setRBC_ID(RBC_ID);
                    subSequence.setRBCPhone(RBCPhone);

                    DataDictionary.Tests.TestCase testCase = (DataDictionary.Tests.TestCase)DataDictionary.Generated.acceptor.getFactory().createTestCase();
                    testCase.Name = "Setup";
                    subSequence.appendTestCases(testCase);

                    DataDictionary.Tests.Step initializeTrainDataStep = (DataDictionary.Tests.Step)DataDictionary.Generated.acceptor.getFactory().createStep();;
                    initializeTrainDataStep.setTCS_Order(0);
                    initializeTrainDataStep.setDistance(0);
                    initializeTrainDataStep.setDescription("Initialize train data");
                    initializeTrainDataStep.setTranslationRequired(true);
                    testCase.appendSteps(initializeTrainDataStep);

                    DataDictionary.Tests.Step setupStep = (DataDictionary.Tests.Step)DataDictionary.Generated.acceptor.getFactory().createStep();;
                    setupStep.setTCS_Order(0);
                    setupStep.setDistance(0);
                    setupStep.setDescription("Setup test sequence");
                    setupStep.setTranslationRequired(true);
                    testCase.appendSteps(setupStep);

                    DataDictionary.Tests.Step manualSetupStep = (DataDictionary.Tests.Step)DataDictionary.Generated.acceptor.getFactory().createStep();;
                    manualSetupStep.setTCS_Order(0);
                    manualSetupStep.setDistance(0);
                    manualSetupStep.setDescription("Manual setup test sequence");
                    manualSetupStep.setTranslationRequired(true);
                    testCase.appendSteps(manualSetupStep);
                }
            }
            else
            {
                Log.Error("Cannot find entry in table TSW_TestSeqSCItl WHERE TestSequenceID = " + subSequenceID);
            }
        }
Example #24
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="subSequence"></param>
 public ApplyTranslationRulesHandler(SubSequence subSequence)
 {
     SubSequence = subSequence;
 }
Example #25
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="window"></param>
 /// <param name="subSequence"></param>
 public ExecuteTestsHandler(Window window, SubSequence subSequence)
 {
     Window      = window;
     SubSequence = subSequence;
 }
Example #26
0
        /// <summary>
        /// Imports the steps in a sub sequence
        /// </summary>
        /// <param name="subSequence"></param>
        private void importSteps(DataDictionary.Tests.SubSequence subSequence)
        {
            string sql = "SELECT TCSOrder, Distance, FT_NUMBER, TC_NUMBER, ST_STEP, ST_DESCRIPTION, UserComment, ST_IO, ST_INTERFACE, ST_COMMENTS, TestLevelIn, TestLevelOut, TestModeIn, TestModeOut FROM TSW_TCStep ORDER BY TCSOrder";

            OleDbDataAdapter adapter = new OleDbDataAdapter(sql, Connection);
            DataSet          dataSet = new DataSet();

            adapter.Fill(dataSet);
            if (dataSet.Tables.Count > 0)
            {
                DataDictionary.Tests.TestCase testCase = null;

                foreach (DataRow dataRow in dataSet.Tables[0].Rows)
                {
                    object[] items        = dataRow.ItemArray;
                    int      order        = (int)items[0];
                    int      distance     = (int)items[1];
                    int      feature      = (int)items[2];
                    int      testCaseNr   = (int)items[3];
                    string   stepType     = items[4] as string;
                    string   description  = items[5] as string;
                    string   userComment  = items[6] as string;
                    string   io           = items[7] as string;
                    string   intrface     = items[8] as string;
                    string   comment      = items[9] as string;
                    string   testLevelIn  = items[10] as string;
                    string   testLevelOut = items[11] as string;
                    string   testModeIn   = items[12] as string;
                    string   testModeOut  = items[13] as string;

                    // we do not want to import steps "Followed by" or "Preceded by"
                    if (io != null && stepType != null && !stepType.Equals("Followed by") && !stepType.Equals("Preceded by"))
                    {
                        if (testCase != null)
                        {
                            if (testCase.getFeature() != feature || testCase.getCase() != testCaseNr)
                            {
                                testCase = null;
                            }
                        }

                        if (testCase == null)
                        {
                            testCase      = (DataDictionary.Tests.TestCase)DataDictionary.Generated.acceptor.getFactory().createTestCase();
                            testCase.Name = "Feature " + feature + " Test case " + testCaseNr;
                            testCase.setCase(testCaseNr);
                            testCase.setFeature(feature);
                            subSequence.appendTestCases(testCase);
                        }

                        DataDictionary.Tests.Step step = (DataDictionary.Tests.Step)DataDictionary.Generated.acceptor.getFactory().createStep();
                        step.Name = "Step " + order;
                        step.setTCS_Order(order);
                        step.setDistance(distance);
                        step.setDescription(description);
                        step.setUserComment(userComment);
                        step.setIO_AsString(io);
                        if (intrface != null)
                        {
                            step.setInterface_AsString(intrface);
                        }
                        step.setComment(comment);
                        if (testLevelIn != null)
                        {
                            step.setLevelIN_AsString(testLevelIn);
                        }
                        if (testLevelOut != null)
                        {
                            step.setLevelOUT_AsString(testLevelOut);
                        }
                        if (testModeIn != null)
                        {
                            step.setModeIN_AsString(testModeIn);
                        }
                        if (testModeOut != null)
                        {
                            step.setModeOUT_AsString(testModeOut);
                        }
                        step.setTranslationRequired(true);

                        importStepMessages(step);

                        testCase.appendSteps(step);
                    }
                }
            }
            else
            {
                Log.Error("Cannot find sub sequence table in database");
            }
        }
        /// <summary>
        /// Creates the description of the sub sequence
        /// </summary>
        /// <param name="subSequence"></param>
        private void CreateSubSequenceDescription(SubSequence subSequence)
        {
            Report.AddSubParagraph(subSequence.Name);
            Report.AddParagraph("Subsequence description");

            Report.AddTable(new[] { "Step", "Description", "Comment" }, new[] { 10, 80, 80 });
            foreach (TestCase testCase in subSequence.TestCases)
            {
                bool testCaseIntroduced = false;

                // Report test cases where requirements have been associated to
                if (testCase.Requirements.Count > 0)
                {
                    IntroduceTestCase(testCase);
                    testCaseIntroduced = true;
                }

                foreach (Step step in testCase.Steps)
                {
                    if (step.getTCS_Order() != 0 || step.Requirements.Count > 0)
                    {
                        if (!testCaseIntroduced)
                        {
                            // Report test cases when there are relevant steps in it
                            IntroduceTestCase(testCase);
                            testCaseIntroduced = true;
                        }

                        Report.AddRow(
                            step.getTCS_Order().ToString(CultureInfo.InvariantCulture),
                            step.getDescription(),
                            step.Comment);

                        ReportIssue(step);
                    }
                }
            }

            Report.CloseSubParagraph();
        }