public TestSuiteEntity(TestObj test, string fullName)
 {
     Test = test;
     FullName = fullName;
     var f = new FileInfo(fullName);
     if (f.Exists)
         Name = f.Name.Replace(StaticFields.SUITE_EXTENTION, string.Empty);
 }
Example #2
0
 private SaveData()
 {
     CopyStepEntities = new ScriptObj();
     CopyTestEntities = new TestObj();
     Test = new TestObj();
     Script = new ScriptObj();
     TestSuite = new TestSuite();
     ClientMessages = new ObservableCollection<AutomationCommon.ClientMessage>();
 }
Example #3
0
        public static TestObj ExtructTestFromFile(string fileName)
        {
            string detail = string.Empty;
            if (string.IsNullOrEmpty(fileName))
                return null;

            var test = new TestObj();
            TestEntity testEntity = 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 "Test":
                                test = new TestObj();
                                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
                                test.Description = detail;
                                break;

                            case "Script":
                                tmpEntityEnable = false;
                                tmpEntityName = string.Empty;
                                break;

                            case "Comment"://here we add the new test entity (on the last property of the entity)
                                tmpEntityName = tmpEntityName.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");
                                testEntity = new TestEntity(ExtructScriptFromFile(tmpEntityName), tmpEntityName);

                                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

                                testEntity.Comment = detail;
                                testEntity.Enable = tmpEntityEnable;
                                test.Entities.Add(testEntity);

                                //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
                                //testEntity = new TestEntity(ExtructScriptFromFile(tmpEntityName), tmpEntityName);
                                //testEntity.Comment = reader.ReadInnerXml();
                                //testEntity.Enable = tmpEntityEnable;
                                //test.Entities.Add(testEntity);
                                break;

                            case "Name":
                                detail = reader.ReadInnerXml();
                                detail.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");//encode special characters -The characters &, <, and > are replaced with &amp;, &lt;, and &gt;, respectively
                                tmpEntityName = detail;
                                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
                                testEntity.Params = detail;
                                break;
                        }
                    }
                }
            }

            return test;
        }