public void TestDDNodeLostNodesAfterDeserializationEmptyStringArray3IsEmptyElementFalse() { var nExpected = new DDNode("Root"); var attr = nExpected.Add("1").Attributes; attr.Add("a1", new Guid()); attr.Add("a2", new string[] { "1" }); attr.Add("a3", new string[] {}); attr = nExpected.Add("2").Attributes; attr.Add("a1", new Guid()); attr.Add("a3", new string[] {}); attr.Add("a2", new string[] { "2" }); var nSource = DDNodeSxe.Deserialize(@"<?xml version='1.0'?> <n n='Root'> <n n='1'> <a n='a1' t='System.Guid'>00000000-0000-0000-0000-000000000000</a> <a n='a2' t='System.String[]'> <i>1</i> </a> <a n='a3' t='System.String[]'></a> </n> <n n='2'> <a n='a1' t='System.Guid'>00000000-0000-0000-0000-000000000000</a> <a n='a3' t='System.String[]'></a> <a n='a2' t='System.String[]'> <i>2</i> </a> </n> </n>"); ValidateDeserialization(nSource, nExpected); }
private static DDNode getTestFileNode() { return(DDNodeSxe.Deserialize ( @"<n n='TestFile'> <a n='File' t='System.String'>c:\text.txt</a> <a n='Expected' t='System.Boolean'>false</a> </n>" )); }
public void TestDeserializationFromXMLAndAutoNameGeneration() { var n = DDNodeSxe.Deserialize(UTestDrDataCommon.GetMemoryStreamFromFile()); Assert.IsTrue(n.Type == String.Empty, "Type of nodes are not equals after deserialization with auto node name generation."); foreach (var c in n) { Assert.IsTrue(c.Value.Type == "Type", "Type of nodes are not equals after deserialization with auto node name generation."); var en = c.Value.Attributes.GetEnumerator(); en.MoveNext(); } }
private static DDNode getTestStartProcess() { return(DDNodeSxe.Deserialize ( @"<n n='StartCalc'> <a n='FileName' t='System.String'>calc.exe</a> <a n='TimeOut' t='System.Int32'>12</a> <a n='UseShellExecute' t='System.Boolean'>false</a> <a n='RedirectStandardOutput' t='System.Boolean'>true</a> <a n='RedirectStandardError' t='System.Boolean'>true</a> </n>" )); }
/// <summary> /// Loads data from xml file in the DDNode format to temporary node and merge temporary data with base node /// </summary> /// <param name="path">path to xml file</param> public void Load(string path) { DDNode tmpNode; using (var sf = new FileStream(path, FileMode.Open, FileAccess.Read)) { using (var sr = new StreamReader(sf)) { tmpNode = DDNodeSxe.Deserialize(sr); // gets data from xml file to temporary node } } this.tNode.Merge(tmpNode, DDNode.DDNODE_MERGE_OPTION.ALL, ResolveConflict.SKIP); // merge stub node with data from file }
public void TestSerialyzeDeserialyze() { DDNode n = new DDNode("my favorite node"); using (var fs = new FileStream("node.xml", FileMode.Create, FileAccess.Write)) { n.Serialize(fs); } using (var fs = new FileStream("node.xml", FileMode.Open, FileAccess.Read)) { n = DDNodeSxe.Deserialize(fs); } }
public void TestDDNodeXmlDirectSerialization() { var n = new DDNode("name", "type"); n.Attributes.Add("bool", false); n.Attributes.Add("int", -1); n.Add("ChildNode").Add("SubChildNode").Attributes.Add("string", "string"); StringBuilder sb = new StringBuilder(); n.Serialize(sb); var d = DDNodeSxe.Deserialize(sb.ToString()); ValidateDeserialization(n, d); }
private static DDNode getTestScript() { return(DDNodeSxe.Deserialize ( @"<n n='StartSampleVbs'> <a n='FileName' t='System.String'>wscript.exe</a> <a n='FileName' t='System.String'>wscript.exe</a> <a n='TimeOut' t='System.Int32'>10</a> <a n='UseShellExecute' t='System.Boolean'>true</a> <a n='RedirectStandardOutput' t='System.Boolean'>false</a> <a n='RedirectStandardError' t='System.Boolean'>false</a> </n>" )); }
private static DDNode getTestFilesNode() { return(DDNodeSxe.Deserialize ( @"<n n='TestFiles'> <n n='TestFile1'> <a n='File' t='System.String'>c:\text.txt</a> <a n='Expected' t='System.Boolean'>false</a> </n> <n n='TestFile2'> <a n='File' t='System.String'>c:\pagefile.sys</a> <a n='Expected' t='System.Boolean'>true</a> </n> <n n='TestFile3'> <a n='File' t='System.String'>c:\doesntexistfile.txt</a> <a n='Expected' t='System.Boolean'>false</a> </n> </n>" )); }
static void Serialize2File() { var n = new DDNode("nodeName", "nodeType"); n.Attributes.Add("valueInt", -1); using (var sw = new StreamWriter("file.xml")) n.Serialize(sw); DDNode k; //= new DDNode(); using (var st = new StreamReader("file.xml")) k = DDNodeSxe.Deserialize(st); var ch1 = k.Add("1"); var ch2 = k.Add("2"); ch1.Rename("1"); ch1.Rename("2"); }
private static DDNode getTestService() { return(DDNodeSxe.Deserialize ( @" <n n='CheckServices' t='TASrv.ValidateServiceConfigurationAndStateCollection'> <a n='ServerName' t='System.String'></a> <a n='ErrorControl' t='System.String'>^SERVICE_ERROR_NORMAL$</a> <a n='ServiceType' t='System.String'>^272$</a> <a n='StartName' t='System.String'>^LocalSystem$</a> <a n='StartType' t='System.String'>^SERVICE_AUTO_START$</a> <a n='TagID' t='System.String'>^0$</a> <a n='CheckPoint' t='System.String'>^0$</a> <a n='ControlsAccepted' t='System.String'>1217</a> <a n='ServiceSpecificExitCode' t='System.String'>^0$</a> <a n='ServiceState' t='System.String'>^SERVICE_RUNNING$</a> <a n='WaitHint' t='System.String'>^0$</a> <a n='Win32ExitCode' t='System.String'>^0$</a> <a n='DelayedAutoStart' t='System.String'>^false$</a> <n n='CheckSpooler' t='TASrv.ValidateServiceConfigurationAndState'> <a n='ServiceName' t='System.String'>Spooler</a> <a n='BinaryPathName' t='System.String'>^C:\\Windows\\System32\\spoolsv.exe$</a> <a n='Description' t='System.String'>^This service spools print jobs and handles interaction with the printer. If you turn off this service, you won’t be able to print or see your printers.$</a> <a n='DisplayName' t='System.String'>Print Spooler</a> <a n='LoadOrderGroup' t='System.String'>^SpoolerGroup$</a> <a n='Dependencies' t='System.String'>^RPCSS\0http$</a> </n> <n n='CheckSpoolerAgain' t='TASrv.ValidateServiceConfigurationAndState'> <a n='ServiceName' t='System.String'>Spooler</a> <a n='BinaryPathName' t='System.String'>^C:\\Windows\\System32\\spoolsv.exe$</a> <a n='Description' t='System.String'>^This service spools print jobs and handles interaction with the printer. If you turn off this service, you won’t be able to print or see your printers.$</a> <a n='DisplayName' t='System.String'>Print Spooler</a> <a n='LoadOrderGroup' t='System.String'>^SpoolerGroup$</a> <a n='Dependencies' t='System.String'>^RPCSS\0http$</a> </n> </n> " )); }