Ejemplo n.º 1
0
 public void AddTestSuiteEntity(TestSuiteEntity entity)
 {
     entity.Enable = true;
     if (IsSelectedStepEntity)
         SelectedTestSuiteEntity = entity;
     else
         TestSuite.Entities.Add(entity);
 }
Ejemplo n.º 2
0
        public static TestSuite ExtructTestSuiteFromFile(string fileName)
        {
            string detail = string.Empty;
            if (string.IsNullOrEmpty(fileName))
                return null;

            var testSuite = new TestSuite();
            TestSuiteEntity testSuiteEntity = null;
            bool tmpEntityEnable = false;
            string tmpEntityName = string.Empty;
            fileName = fileName.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");//encode special characters -The characters &, <, and > are replaced with &amp;, &lt;, and &gt;, respectively

            using (XmlReader reader = XmlReader.Create(fileName))
            {
                while (reader.Read())
                {
                    // Only detect start elements.
                    if (reader.IsStartElement())
                    {
                        // Get element name and switch on it.
                        switch (reader.Name)
                        {
                            case "TestSuite":
                                testSuite = new TestSuite();
                                break;

                            case "Enable":
                                tmpEntityEnable = bool.Parse(reader.ReadInnerXml());
                                break;

                            case "Description":
                                detail = reader.ReadInnerXml();
                                detail.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");//encode special characters -The characters &, <, and > are replaced with &amp;, &lt;, and &gt;, respectively
                                testSuite.Description = detail;
                                break;
                            case "TearDownScript":
                                testSuite.TearDownScript = reader.ReadInnerXml();
                                break;
                            case "Test":
                                tmpEntityEnable = false;
                                tmpEntityName = string.Empty;
                                break;

                            case "Name"://here we add the new test entity (on the last property of the entity)
                                tmpEntityName = reader.ReadInnerXml();
                                tmpEntityName = tmpEntityName.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");//encode special characters -The characters &, <, and > are replaced with &amp;, &lt;, and &gt;, respectively
                                testSuiteEntity = new TestSuiteEntity(ExtructTestFromFile(tmpEntityName), tmpEntityName);
                                testSuiteEntity.Enable = tmpEntityEnable;
                                testSuite.Entities.Add(testSuiteEntity);
                                break;

                            case "Params":
                                detail = reader.ReadInnerXml();
                                detail = detail.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");//encode special characters -The characters &, <, and > are replaced with &amp;, &lt;, and &gt;, respectively
                                testSuiteEntity.Params = detail;
                                break;

                            case "Comment":
                                detail = reader.ReadInnerXml();
                                detail = detail.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");//encode special characters -The characters &, <, and > are replaced with &amp;, &lt;, and &gt;, respectively
                                testSuiteEntity.Comment = detail;
                                break;
                            
                        }
                    }
                }
            }

            return testSuite;
        }
Ejemplo n.º 3
0
        private void AddNodeToList(string name)
        {
            if (string.IsNullOrEmpty(name))
                return;
            //add scripts to test list
            if (name.Contains(StaticFields.SCRIPT_EXTENTION)) //filter other buttons
            {
                var s = new TestEntity(FileHandler.ExtructScriptFromFile(name), name);
                s.Enable = true;
                Singleton.Instance<SaveData>().Test.Entities.Add(s);
                OnPropertyChanged("TestEntitiesList");
            }

            //add test to suite
            if (name.Contains(StaticFields.TEST_EXTENTION)) //filter other buttons
            {
                var t = new TestSuiteEntity(FileHandler.ExtructTestFromFile(name), name);
                t.Enable = true;
                Singleton.Instance<SaveData>().TestSuite.Entities.Add(t);
                //  SelectedSuiteName = null;//reseting the suite name (the user can't execute un saved suite)
                OnPropertyChanged("TestGroupList");
            }
        }