private SaveData() { CopyStepEntities = new ScriptObj(); CopyTestEntities = new TestObj(); Test = new TestObj(); Script = new ScriptObj(); TestSuite = new TestSuite(); ClientMessages = new ObservableCollection<AutomationCommon.ClientMessage>(); }
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("&", "&").Replace("<", "<").Replace(">", ">");//encode special characters -The characters &, <, and > are replaced with &, <, and >, 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("&", "&").Replace("<", "<").Replace(">", ">");//encode special characters -The characters &, <, and > are replaced with &, <, and >, 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("&", "&").Replace("<", "<").Replace(">", ">");//encode special characters -The characters &, <, and > are replaced with &, <, and >, respectively testSuiteEntity = new TestSuiteEntity(ExtructTestFromFile(tmpEntityName), tmpEntityName); testSuiteEntity.Enable = tmpEntityEnable; testSuite.Entities.Add(testSuiteEntity); break; case "Params": detail = reader.ReadInnerXml(); detail = detail.Replace("&", "&").Replace("<", "<").Replace(">", ">");//encode special characters -The characters &, <, and > are replaced with &, <, and >, respectively testSuiteEntity.Params = detail; break; case "Comment": detail = reader.ReadInnerXml(); detail = detail.Replace("&", "&").Replace("<", "<").Replace(">", ">");//encode special characters -The characters &, <, and > are replaced with &, <, and >, respectively testSuiteEntity.Comment = detail; break; } } } } return testSuite; }