public TestCaseBase() { optionType = new OptionTypes(); }
public static OptionTypes NodeToOptionTypes(XmlNode optionNode) { OptionTypes ots = new OptionTypes(); XmlNodeList xnUriPath = ((XmlElement)optionNode).GetElementsByTagName("uriPath"); if (xnUriPath != null && xnUriPath.Count > 0) { ots.UriPath = xnUriPath.Item(0).InnerText; } XmlNodeList xnUriQuery = ((XmlElement)optionNode).GetElementsByTagName("uriQuery"); if (xnUriQuery != null && xnUriQuery.Count > 0) { ots.UriQuery = xnUriQuery.Item(0).InnerText; } XmlNodeList xnAccept = ((XmlElement)optionNode).GetElementsByTagName("accept"); if (xnAccept != null && xnAccept.Count > 0) { ots.Accept = xnAccept.Item(0).InnerText; } XmlNodeList xnContent_Format = ((XmlElement)optionNode).GetElementsByTagName("content-Format"); if (xnContent_Format != null && xnContent_Format.Count > 0) { ots.Content_Format = xnContent_Format.Item(0).InnerText; } XmlNodeList xnBlock1 = ((XmlElement)optionNode).GetElementsByTagName("block1"); if (xnBlock1 != null && xnBlock1.Count > 0) { ots.Block1 = xnBlock1.Item(0).InnerText; } XmlNodeList xnBlock2 = ((XmlElement)optionNode).GetElementsByTagName("block2"); if (xnBlock2 != null && xnBlock2.Count > 0) { ots.Block2 = xnBlock2.Item(0).InnerText; } XmlNodeList xnObserve = ((XmlElement)optionNode).GetElementsByTagName("observe"); if (xnObserve != null && xnObserve.Count > 0) { ots.Observe = xnObserve.Item(0).InnerText; } XmlNodeList xnETag = ((XmlElement)optionNode).GetElementsByTagName("eTag"); if (xnETag != null && xnETag.Count > 0) { ots.ETag = xnETag.Item(0).InnerText; } XmlNodeList xnIf_Match = ((XmlElement)optionNode).GetElementsByTagName("if-Match"); if (xnIf_Match != null && xnIf_Match.Count > 0) { ots.If_Match = xnIf_Match.Item(0).InnerText; } XmlNodeList xnIf_None_Mathch = ((XmlElement)optionNode).GetElementsByTagName("if-None-Match"); if (xnIf_None_Mathch != null && xnIf_None_Mathch.Count > 0) { ots.If_None_Match = xnIf_None_Mathch.Item(0).InnerText.Trim().ToUpper(); } XmlNodeList xnUri_Host = ((XmlElement)optionNode).GetElementsByTagName("uri-Host"); if (xnUri_Host != null && xnUri_Host.Count > 0) { ots.Uri_Host = xnUri_Host.Item(0).InnerText; } XmlNodeList xnUri_Port = ((XmlElement)optionNode).GetElementsByTagName("uri-Port"); if (xnUri_Port != null && xnUri_Port.Count > 0) { ots.Uri_Port = xnUri_Port.Item(0).InnerText; } XmlNodeList xnProxy_Uri = ((XmlElement)optionNode).GetElementsByTagName("proxy-Uri"); if (xnProxy_Uri != null && xnProxy_Uri.Count > 0) { ots.Proxy_Uri = xnProxy_Uri.Item(0).InnerText; } XmlNodeList xnProxy_Scheme = ((XmlElement)optionNode).GetElementsByTagName("proxy-Scheme"); if (xnProxy_Scheme != null && xnProxy_Scheme.Count > 0) { ots.Proxy_Scheme = xnProxy_Scheme.Item(0).InnerText.Trim().ToUpper(); } XmlNodeList xnMax_Age = ((XmlElement)optionNode).GetElementsByTagName("max-Age"); if (xnMax_Age != null && xnMax_Age.Count > 0) { ots.Max_Age = xnMax_Age.Item(0).InnerText; } XmlNodeList xnLocation_Path = ((XmlElement)optionNode).GetElementsByTagName("location-Path"); if (xnLocation_Path != null && xnLocation_Path.Count > 0) { ots.Location_Path = xnLocation_Path.Item(0).InnerText; } XmlNodeList xnLocation_Query = ((XmlElement)optionNode).GetElementsByTagName("location-Query"); if (xnLocation_Query != null && xnLocation_Query.Count > 0) { ots.Location_Query = xnLocation_Query.Item(0).InnerText; } return(ots); }
public static void OptionTypesToNode(OptionTypes ots, XmlDocument doc, XmlElement tcrElement) { if (ots.UriPath != null) { XmlElement uriPathElement = doc.CreateElement("uriPath"); uriPathElement.InnerText = ots.UriPath; tcrElement.AppendChild(uriPathElement); } if (ots.UriQuery != null) { XmlElement uriQuery = doc.CreateElement("uriQuery"); uriQuery.InnerText = ots.UriQuery; tcrElement.AppendChild(uriQuery); } if (ots.Accept != null) { XmlElement accept = doc.CreateElement("accept"); accept.InnerText = ots.Accept; tcrElement.AppendChild(accept); } if (ots.Content_Format != null) { XmlElement contentFormat = doc.CreateElement("content-Format"); contentFormat.InnerText = ots.Content_Format; tcrElement.AppendChild(contentFormat); } if (ots.Block1 != null) { XmlElement block1 = doc.CreateElement("block1"); block1.InnerText = ots.Block1; tcrElement.AppendChild(block1); } if (ots.Block2 != null) { XmlElement block2 = doc.CreateElement("block2"); block2.InnerText = ots.Block2; tcrElement.AppendChild(block2); } if (ots.Observe != null) { XmlElement observe = doc.CreateElement("observe"); observe.InnerText = ots.Observe; tcrElement.AppendChild(observe); } if (ots.ETag != null) { XmlElement eTag = doc.CreateElement("eTag"); eTag.InnerText = ots.ETag; tcrElement.AppendChild(eTag); } if (ots.If_Match != null) { XmlElement ifMatch = doc.CreateElement("if-Match"); ifMatch.InnerText = ots.If_Match; tcrElement.AppendChild(ifMatch); } if (ots.If_None_Match != null) { XmlElement ifNoneMatch = doc.CreateElement("if-None-Match"); ifNoneMatch.InnerText = ots.If_None_Match; tcrElement.AppendChild(ifNoneMatch); } if (ots.Uri_Host != null) { XmlElement uriHost = doc.CreateElement("uri-Host"); uriHost.InnerText = ots.Uri_Host; tcrElement.AppendChild(uriHost); } if (ots.Uri_Port != null) { XmlElement uriPort = doc.CreateElement("uri-Port"); uriPort.InnerText = ots.Uri_Port; tcrElement.AppendChild(uriPort); } if (ots.Proxy_Uri != null) { XmlElement proxyUri = doc.CreateElement("proxy-Uri"); proxyUri.InnerText = ots.Proxy_Uri; tcrElement.AppendChild(proxyUri); } if (ots.Proxy_Scheme != null) { XmlElement proxyScheme = doc.CreateElement("proxy-Scheme"); proxyScheme.InnerText = ots.Proxy_Scheme; tcrElement.AppendChild(proxyScheme); } if (ots.Max_Age != null) { XmlElement maxAge = doc.CreateElement("max-Age"); maxAge.InnerText = ots.Max_Age; tcrElement.AppendChild(maxAge); } if (ots.Location_Path != null) { XmlElement locationPath = doc.CreateElement("location-Path"); locationPath.InnerText = ots.Location_Path; tcrElement.AppendChild(locationPath); } if (ots.Location_Query != null) { XmlElement locationQuery = doc.CreateElement("location-Query"); locationQuery.InnerText = ots.Location_Query; tcrElement.AppendChild(locationQuery); } }
public static TestCaseBase NodeToTestCaseBase(XmlNode reNode) { TestCaseBase tcb; if (reNode.Name == "testCaseRequest") { TestCaseRequest tcrq = new TestCaseRequest(); tcb = tcrq; tcb.IsRequest = true; XmlNodeList xnMethod = ((XmlElement)reNode).GetElementsByTagName("method"); if (xnMethod != null) { tcrq.Method = xnMethod.Item(0).InnerText; } } else { TestCaseResponse tcrs = new TestCaseResponse(); tcb = tcrs; tcb.IsRequest = false; XmlNodeList xnCode = ((XmlElement)reNode).GetElementsByTagName("code"); if (xnCode != null) { tcrs.Code = xnCode.Item(0).InnerText; } XmlNodeList xnSameMID = ((XmlElement)reNode).GetElementsByTagName("sameMID"); if (xnSameMID != null && xnSameMID.Count > 0) { tcrs.SameMID = xnSameMID.Item(0).InnerText; } } XmlNodeList xnMessageType = ((XmlElement)reNode).GetElementsByTagName("messageType"); if (xnMessageType != null && xnMessageType.Count > 0) { tcb.MessageType = xnMessageType.Item(0).InnerText; } XmlNodeList xnPayLoad = ((XmlElement)reNode).GetElementsByTagName("payLoad"); if (xnPayLoad != null && xnPayLoad.Count > 0) { tcb.PayLoad = xnPayLoad.Item(0).InnerText; } XmlNodeList xnToken = ((XmlElement)reNode).GetElementsByTagName("token"); if (xnToken != null && xnToken.Count > 0) { tcb.Token = xnToken.Item(0).InnerText; } OptionTypes ots = new OptionTypes(); XmlNodeList xnlOptionTypeList = ((XmlElement)reNode).GetElementsByTagName("optionType"); if (xnlOptionTypeList != null && xnlOptionTypeList.Count > 0) { XmlNode xnlOptionType = xnlOptionTypeList.Item(0); ots = NodeToOptionTypes(xnlOptionType); } tcb.OptionType = ots; return(tcb); }