public override void executeTest( ) { Console.WriteLine("Test Case :Make Faults.xml with Faults Fault ErrorCode Value Edited to \"originalValue + testValue\""); try { string holodeckPath; holodeckPath = (string) Registry.LocalMachine.OpenSubKey ("Software\\HolodeckEE", true).GetValue ("InstallPath"); FaultsXMLFilePath = string.Concat(holodeckPath,"\\function_db\\faults.xml"); FaultsXMLBackupFilePath = string.Concat(FaultsXMLFilePath,".bak"); modifyThisFile = new FileInfo(FaultsXMLFilePath); modifyThisFile.Attributes = FileAttributes.Normal; modifyThisFile.CopyTo(FaultsXMLBackupFilePath,true); //modify xml here FaultsXMLFilePath = modifyThisFile.FullName; XmlDocument xmlDocument = new XmlDocument( ); xmlDocument.Load(FaultsXMLFilePath); XmlNode nodeFault = xmlDocument.SelectSingleNode( "/Faults/Fault[@ErrorCode]" ); EditValues editFalutReturnValue = new EditValues(); editFalutReturnValue.EditFault(nodeFault,testValue,"ErrorCode"); Console.WriteLine("Editing Fault ErrorCode Attribute of {0} fault to {1}",nodeFault.Attributes["Name"].Value.ToString(),nodeFault.Attributes["ErrorCode"].Value.ToString()); xmlDocument.Save(FaultsXMLFilePath); //add code here which will launch Holodeck Holodeck.HolodeckProcess.Start(); } catch(HolodeckExceptions.IncorrectRegistryException e) { Console.WriteLine(" Incorrect Registry Exception caught.... : " + e.Message); Console.WriteLine("Details: " + e.StackTrace); } catch(FileNotFoundException f) { Console.WriteLine(" File Not Found Exception caught.... : " + f.Message); Console.WriteLine("Details: " + f.StackTrace); } finally { if(Holodeck.HolodeckProcess.IsRunning ()) { Holodeck.HolodeckProcess.Stop(); } //reverting back to original modifyThisFile.Delete(); FileInfo regainOriginal = new FileInfo(FaultsXMLBackupFilePath); regainOriginal.MoveTo(FaultsXMLFilePath); } }
public override void executeTest( ) { Console.WriteLine("Test Case :Make Faults.xml with 'Faults Fault Function CheckResource Exists' Value Edited to \"originalValue + testValue\""); try { string holodeckPath; holodeckPath = (string) Registry.LocalMachine.OpenSubKey ("Software\\HolodeckEE", true).GetValue ("InstallPath"); FaultsXMLFilePath = string.Concat(holodeckPath,"\\function_db\\faults.xml"); FaultsXMLBackupFilePath = string.Concat(FaultsXMLFilePath,".bak"); modifyThisFile = new FileInfo(FaultsXMLFilePath); modifyThisFile.Attributes = FileAttributes.Normal; modifyThisFile.CopyTo(FaultsXMLBackupFilePath,true); //modify xml here FaultsXMLFilePath = modifyThisFile.FullName; XmlDocument xmlDocument = new XmlDocument( ); xmlDocument.Load(FaultsXMLFilePath); XmlNode nodeCheckResource = xmlDocument.SelectSingleNode( "/Faults/Fault/Function/CheckResource[@Exists]" ); EditValues editExists = new EditValues(); editExists.EditCheckResource(nodeCheckResource,testValue,"Exists"); xmlDocument.Save(FaultsXMLFilePath); try { //add code here which will launch Holodeck Holodeck.HolodeckProcess.Start(); } catch(Holodeck.HolodeckExceptions.CannotStartHolodeckException ex) { Console.WriteLine("Cannot Start Holodeck Exception thrown "); Console.WriteLine("Test Value not Found in enumeration List"); Console.WriteLine(ex.Message); } } catch(HolodeckExceptions.IncorrectRegistryException e) { Console.WriteLine(" Incorrect Registry Exception caught.... : " + e.Message); Console.WriteLine("Details: " + e.StackTrace); } catch(FileNotFoundException f) { Console.WriteLine(" File Not Found Exception caught.... : " + f.Message); Console.WriteLine("Details: " + f.StackTrace); } finally { if(Holodeck.HolodeckProcess.IsRunning ()) { Holodeck.HolodeckProcess.Stop(); } //reverting back to original modifyThisFile.Delete(); FileInfo regainOriginal = new FileInfo(FaultsXMLBackupFilePath); regainOriginal.MoveTo(FaultsXMLFilePath); } }