Ejemplo n.º 1
0
        public void query2(MdoQuery mq)
        {
            string request = "";
            string xpath   = "";

            getRequestIdentifiers(mq, ref xpath, ref request);

            XmlDocument doc = new XmlDocument();

            doc.Load(Path.Combine(XmlResourcePath, "MockConnection" + siteId + ".xml"));

            XmlNodeList list = doc.SelectNodes("//query");

            foreach (XmlNode node in list)
            {
                string  value        = node.SelectSingleNode("value").InnerText;
                XmlNode responseNode = node.SelectSingleNode("response");

                if (value.Equals(request))
                {
                    String response = responseNode.InnerText;
                    if (null != responseNode.Attributes["type"])
                    {
                        response = FileIOUtils.readFromFile(Path.Combine(DataResourcePath, response));
                    }

                    addRequest(mq, response, false);
                    return;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get the response from the selected query node
        /// </summary>
        /// <param name="query">a valid query node</param>
        /// <returns>the response string</returns>
        private string getResponse(XmlNode query)
        {
            string rpcName = query.Attributes.GetNamedItem(RPC_ATTR).Value;

            XmlNode result = query.SelectSingleNode(RESPONSE_NODE);

            if (null != result)
            {
                if (null == result.Attributes.GetNamedItem("type", ""))
                {
                    return(result.InnerText);
                }
                else
                {
                    return(FileIOUtils.readFromFile(Path.Combine(DataResourcePath, result.InnerText)));
                }
            }

            throw new DataException(String.Format("response for rpc: {0} is missing from the mock data", rpcName));
        }