Пример #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");
            }
        }
Пример #2
0
        /// <summary>
        ///     Imports the database
        /// </summary>
        public override void ExecuteWork()
        {
            if (ImportMode == Mode.File)
            {
                Frame frame = GetFrame(FileName);
                if (frame != null)
                {
                    TestImporter importer = new TestImporter(FileName, DbPassword);
                    importer.Import(frame, KeepManualTranslations);
                }
            }
            else
            {
                foreach (string fName in Directory.GetFiles(FileName, "*.mdb"))
                {
                    Frame frame = GetFrame(fName);
                    if (frame != null)
                    {
                        TestImporter importer = new TestImporter(fName, DbPassword);
                        importer.Import(frame, KeepManualTranslations);
                    }
                }
            }

            RefreshModel.Execute();
        }
Пример #3
0
 /// <summary>
 /// Sets the current frame parameters
 /// </summary>
 /// <param name="frame"></param>
 public void setFrame(DataDictionary.Tests.Frame frame)
 {
     Invoke((MethodInvoker) delegate
     {
         frameToolStripComboBox.Text = frame.Name;
         Refresh();
     });
 }
Пример #4
0
        /// <summary>
        ///     Creates a test frame in the enclosing dictionary
        /// </summary>
        /// <param name="enclosing"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        protected Frame CreateTestFrame(Dictionary enclosing, string name)
        {
            Frame retVal = (Frame)Factory.createFrame();

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

            return(retVal);
        }
Пример #5
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);
        }
Пример #6
0
 /// <summary>
 /// Constructor: creates a report for the selected frame
 /// </summary>
 /// <param name="aFrame"></param>
 public TestReport(DataDictionary.Tests.Frame aFrame)
 {
     InitializeComponent();
     EFSSystem           = aFrame.EFSSystem;
     reportHandler       = new TestsCoverageReportHandler(aFrame.Dictionary);
     reportHandler.Frame = aFrame;
     InitializeCheckBoxes(1);
     TxtB_Path.Text = reportHandler.FileName;
 }
Пример #7
0
 /// <summary>
 ///     Imports the database into the corresponding frame by creating a new subsequence
 /// </summary>
 /// <param name="frame"></param>
 /// <param name="keepManualTranslations">Indicates that manual translation for be kept during import</param>
 public void Import(Frame frame, bool keepManualTranslations)
 {
     try
     {
         ImportSubSequence(frame, keepManualTranslations);
     }
     finally
     {
         Connection = null;
     }
 }
Пример #8
0
 /// <summary>
 /// Imports the database into the corresponding frame by creating a new subsequence
 /// </summary>
 /// <param name="frame"></param>
 public void Import(DataDictionary.Tests.Frame frame)
 {
     try
     {
         importSubSequence(frame);
     }
     finally
     {
         Connection = null;
     }
 }
Пример #9
0
        /// <summary>
        /// Creates a new frame
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public FrameTreeNode createFrame(string name)
        {
            FrameTreeNode retVal;

            DataDictionary.Tests.Frame frame = (DataDictionary.Tests.Frame)DataDictionary.Generated.acceptor.getFactory().createFrame();
            frame.Name = name;
            Item.appendTests(frame);

            retVal = new FrameTreeNode(frame);
            Nodes.Add(retVal);
            SortSubNodes();

            return(retVal);
        }
Пример #10
0
        /// <summary>
        ///     Loads a frame and locks the file
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="enclosing"></param>
        /// <param name="lockFiles"></param>
        /// <param name="allowErrors"></param>
        /// <returns></returns>
        public static Frame LoadFrame(string filePath, ModelElement enclosing, bool lockFiles, bool allowErrors)
        {
            Frame retVal = LoadFile <Frame>(filePath, enclosing, lockFiles);

            if (retVal == null)
            {
                if (!allowErrors)
                {
                    throw new Exception("Cannot read file " + filePath);
                }
            }

            return(retVal);
        }
Пример #11
0
            private FrameRef referenceFrame(ModelElement enclosing, Frame test)
            {
                FrameRef retVal = test.FrameRef;

                if (retVal == null)
                {
                    retVal = (FrameRef)acceptor.getFactory().createFrameRef();
                }

                retVal.Name = test.Name;
                retVal.setFather(enclosing);
                retVal.SaveFrame(test);

                return(retVal);
            }
Пример #12
0
 /// <summary>
 ///     Adds a model element in this model element
 /// </summary>
 /// <param name="element"></param>
 public override void AddModelElement(IModelElement element)
 {
     {
         Types.NameSpace item = element as Types.NameSpace;
         if (item != null)
         {
             appendNameSpaces(item);
         }
     }
     {
         Frame item = element as Frame;
         if (item != null)
         {
             appendTests(item);
         }
     }
 }
Пример #13
0
            public override void visit(Generated.Dictionary obj, bool visitSubNodes)
            {
                Dictionary dictionary = (Dictionary)obj;

                if (dictionary.allNameSpaceRefs() != null)
                {
                    foreach (NameSpaceRef nameSpaceRef in dictionary.allNameSpaceRefs())
                    {
                        Types.NameSpace nameSpace = nameSpaceRef.LoadNameSpace(LockFiles, AllowErrorsDuringLoad);
                        if (nameSpace != null)
                        {
                            dictionary.appendNameSpaces(nameSpace);
                            nameSpace.NameSpaceRef = nameSpaceRef;
                        }
                        else
                        {
                            ErrorsDuringLoad.Add(new ElementLog(ElementLog.LevelEnum.Error,
                                                                "Cannot load file " + nameSpaceRef.FileName));
                        }
                    }
                    dictionary.allNameSpaceRefs().Clear();
                }
                if (dictionary.allTestRefs() != null)
                {
                    foreach (FrameRef testRef in dictionary.allTestRefs())
                    {
                        Frame frame = testRef.LoadFrame(LockFiles, AllowErrorsDuringLoad);
                        if (frame != null)
                        {
                            dictionary.appendTests(frame);
                            frame.FrameRef = testRef;
                        }
                        else
                        {
                            ErrorsDuringLoad.Add(new ElementLog(ElementLog.LevelEnum.Error,
                                                                "Cannot load file " + testRef.FileName));
                        }
                    }
                    dictionary.allTestRefs().Clear();
                }

                base.visit(obj, visitSubNodes);
            }
Пример #14
0
        /// <summary>
        /// Provides the frame according to the sequence file name
        /// </summary>
        /// <returns></returns>
        private Frame GetFrame(string fileName)
        {
            Frame frame = null;

            string[] items = fileName.Split('_');

            if (items.Count() > 1)
            {
                string frameName = "Frame " + items[1];
                frame = _dictionary.FindFrame(frameName);
                if (frame == null)
                {
                    frame = Frame.CreateDefault(_dictionary.Tests);
                    // Do not use the default subsequence
                    frame.allSubSequences().Clear();
                    frame.Name = frameName;
                    _dictionary.appendTests(frame);
                }
            }

            return(frame);
        }
        /// <summary>
        ///     Creates an article for a given frame
        /// </summary>
        /// <param name="aFrame">Frame 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 frame</param>
        /// <returns></returns>
        public void CreateFrameArticle(Frame aFrame, TestsCoverageReportHandler aReportConfig,
            HashSet<RuleCondition> activatedRules)
        {
            string title = "Frame " + aFrame.Name;

            AddSubParagraph(title);

            foreach (SubSequence subSequence in aFrame.SubSequences)
            {
                // SIDE EFFECT:
                // each sub-sequence will calculate the list of rules it activates
                // and add them to activatedRules list
                CreateSubSequenceSection(subSequence, aReportConfig, activatedRules, aReportConfig.AddSubSequences);
            }

            // now we  can create the section containing the activated rules of the frame
            CreateActivatedRulesSection(title,
                activatedRules,
                aReportConfig.Dictionary.ImplementedRules,
                aReportConfig.AddActivatedRulesInFrames);
            CloseSubParagraph();
        }
Пример #16
0
            /// <summary>
            /// Generates the file in the background thread
            /// </summary>
            /// <param name="arg"></param>
            public override void ExecuteWork()
            {
                DataDictionary.Tests.Frame frame = Dictionary.findFrame(SUBSET_076);
                if (frame == null)
                {
                    frame      = (DataDictionary.Tests.Frame)DataDictionary.Generated.acceptor.getFactory().createFrame();
                    frame.Name = SUBSET_076;
                    Dictionary.appendTests(frame);
                }

                if (ImportMode == Mode.File)
                {
                    Importers.TestImporter importer = new Importers.TestImporter(FileName, DB_PASSWORD);
                    importer.Import(frame);
                }
                else
                {
                    foreach (string fName in System.IO.Directory.GetFiles(FileName, "*.mdb"))
                    {
                        Importers.TestImporter importer = new Importers.TestImporter(fName, DB_PASSWORD);
                        importer.Import(frame);
                    }
                }
            }
        /// <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;
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="window"></param>
 /// <param name="frame"></param>
 public ExecuteTestsOperation(Window window, DataDictionary.Tests.Frame frame)
 {
     Window = window;
     Frame  = frame;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="frame"></param>
 public ApplyRulesOperation(DataDictionary.Tests.Frame frame)
 {
     Frame = frame;
 }
Пример #20
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");
            }
        }
 /// <summary>
 ///     Imports the database into the corresponding frame by creating a new subsequence
 /// </summary>
 /// <param name="frame"></param>
 /// <param name="keepManualTranslations">Indicates that manual translation for be kept during import</param>
 public void Import(Frame frame, bool keepManualTranslations)
 {
     try
     {
         ImportSubSequence(frame, keepManualTranslations);
     }
     finally
     {
         Connection = null;
     }
 }
        // 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();
            }
        }
Пример #23
0
 /// <summary>
 ///     Imports the database into the corresponding frame by creating a new subsequence
 /// </summary>
 /// <param name="frame"></param>
 public void Import(Frame frame)
 {
     try
     {
         importSubSequence(frame);
     }
     finally
     {
         Connection = null;
     }
 }
Пример #24
0
        /// <summary>
        ///     Imports the subsequence stored in the database
        /// </summary>
        /// <param name="frame"></param>
        private void importSubSequence(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);

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

                    SubSequence oldSubSequence = frame.findSubSequence(subSequenceName);
                    if (oldSubSequence != null)
                    {
                        newSubSequence.setGuid(oldSubSequence.getGuid());
                        int cnt = 0;
                        foreach (TestCase oldTestCase in oldSubSequence.TestCases)
                        {
                            if (cnt < newSubSequence.TestCases.Count)
                            {
                                TestCase newTestCase = newSubSequence.TestCases[cnt] as 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");
            }
        }
Пример #25
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="frame"></param>
 public ApplyRulesOperation(Frame frame)
 {
     Frame = frame;
 }
Пример #26
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="window"></param>
 /// <param name="frame"></param>
 public ExecuteTestsOperation(Window window, Frame frame)
 {
     Window = window;
     Frame  = frame;
 }
Пример #27
0
            private FrameRef referenceFrame(ModelElement enclosing, Frame test)
            {
                FrameRef retVal = test.FrameRef;

                if (retVal == null)
                {
                    retVal = (FrameRef) acceptor.getFactory().createFrameRef();
                }

                retVal.Name = test.Name;
                retVal.setFather(enclosing);
                retVal.SaveFrame(test);

                return retVal;
            }