Exemplo n.º 1
0
        private ObservableList <ApplicationAPIModel> GetParameters(XmlDocument doc, ObservableList <ApplicationAPIModel> AAMSList, bool avoidDuplicatesNodes)
        {
            ApplicationAPIModel AAM = new ApplicationAPIModel();

            AAM.Name = Path.GetFileNameWithoutExtension(doc.BaseURI);
            XMLDocExtended XDE = new XMLDocExtended(doc);

            if (avoidDuplicatesNodes)
            {
                XDE.RemoveDuplicatesNodes();
            }

            IEnumerable <XMLDocExtended>       NodeList = XDE.GetEndingNodes(false);
            ObservableList <AppModelParameter> AMPList  = GetParamList(NodeList);

            AAM.RequestBody        = XDE.XMLString;
            AAM.AppModelParameters = AMPList;
            AAMSList.Add(AAM);
            AllPlaceHolders.Clear();
            return(AAMSList);
        }
Exemplo n.º 2
0
        public bool ParseRespondToOutputParams()
        {
            if (Response != null)
            {
                mAct.AddOrUpdateReturnParamActual("Header: Status Code ", Response.StatusCode.ToString());
                Reporter.ToLog(eLogLevel.INFO, "Retrieve Response Status Code passed successfully", null, true, true);
                foreach (var Header in Response.Headers)
                {
                    string headerValues = string.Empty;
                    foreach (string val in Header.Value.ToArray())
                    {
                        headerValues = val + ",";
                    }
                    headerValues = headerValues.Remove(headerValues.Length - 1);
                    mAct.AddOrUpdateReturnParamActual("Header: " + Header.Key.ToString(), headerValues);
                }
                Reporter.ToLog(eLogLevel.INFO, "responseHeadersCollection passed successfully", null, true, true);
            }
            else
            {
                mAct.AddOrUpdateReturnParamActual("Respond", "Respond returned as null");
            }

            bool XMLResponseCanBeParsed = false;

            XMLResponseCanBeParsed = XMLStringCanBeParsed(ResponseMessage);

            Reporter.ToLog(eLogLevel.INFO, "XMLResponseCanBeParsed Indicator: " + XMLResponseCanBeParsed, null, true, true);

            string prettyResponse = XMLDocExtended.PrettyXml(ResponseMessage);

            mAct.AddOrUpdateReturnParamActual("Response:", prettyResponse);

            if (!ParseNodesToReturnParams(XMLResponseCanBeParsed))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        public static ObservableList <ActReturnValue> ParseXMLResponseSampleIntoReturnValues(string fileContent)
        {
            ObservableList <ActReturnValue> ReturnValues = new ObservableList <ActReturnValue>();

            if (!string.IsNullOrEmpty(fileContent))
            {
                XmlDocument docResponseBody = new XmlDocument();
                docResponseBody.LoadXml(fileContent);
                XMLDocExtended XDEResponseBody = new XMLDocExtended(docResponseBody);
                IEnumerable <XMLDocExtended> NodeListResponseBody = XDEResponseBody.GetEndingNodes(false);

                foreach (XMLDocExtended XDN in NodeListResponseBody)
                {
                    ReturnValues.Add(new ActReturnValue()
                    {
                        Param = XDN.LocalName, Path = XDN.XPathWithoutNamspaces, Active = true
                    });
                }
            }

            return(ReturnValues);
        }
Exemplo n.º 4
0
        public void PopulateTestStepPropertiesList()
        {
            ClearPropertyFromList(ActSoapUiInputValue.ePropertyType.TestStep);

            if (TestSuiteComboBox.SelectedValue == null)
            {
                return;
            }
            string testSuite = TestSuiteComboBox.SelectedValue.ToString();
            string testCase  = TestCaseComboBox.SelectedValue.ToString();

            if (string.IsNullOrEmpty(testCase))
            {
                return;
            }

            XmlDocument doc           = new XmlDocument();
            string      XMLFiledValue = mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.XMLFile);

            if (!XMLFiledValue.Equals(string.Empty))
            {
                if (XMLFiledValue.Substring(0, 1).Equals("~"))
                {
                    string SolutionFolder = mAct.SolutionFolder;
                    XMLFiledValue = System.IO.Path.Combine(SolutionFolder, XMLFiledValue.Substring(2));
                }
                if (!System.IO.File.Exists(XMLFiledValue))
                {
                    Reporter.ToUser(eUserMsgKey.FileNotExist);
                    return;
                }
                doc.Load(XMLFiledValue);
                XmlNamespaceManager manager    = XMLDocExtended.GetAllNamespaces(doc);
                XmlNodeList         properties = doc.SelectNodes("//*[local-name()='soapui-project']/*[local-name()='testSuite'][@name='" + testSuite + "']/*[local-name()='testCase'][@name='" + testCase + "']/*[local-name()='testStep'][@type='properties']/*[local-name()='config']/*[local-name()='properties']/*[local-name()='property']", manager);

                PopulatePropertiesGrid(properties, ActSoapUiInputValue.ePropertyType.TestStep);
            }
        }
        private void AddXMLValueToOptionalValuesPerParameterDict(Dictionary <Tuple <string, string>, List <string> > OptionalValuesPerParameterDict, XMLDocExtended XDN)
        {
            Tuple <string, string> tuple = new Tuple <string, string>(XDN.LocalName, XDN.XPath);
            string Value = XDN.Value;

            if (OptionalValuesPerParameterDict.ContainsKey(tuple))
            {
                OptionalValuesPerParameterDict[tuple].Add(Value);
            }
            else
            {
                OptionalValuesPerParameterDict.Add(tuple, new List <string>()
                {
                    Value
                });
            }

            foreach (XmlAttribute attribute in XDN.Attributes)
            {
                Tuple <string, string> attributetuple = new Tuple <string, string>(attribute.LocalName, XDN.XPath);
                string attributeValue = attribute.Value;

                if (OptionalValuesPerParameterDict.ContainsKey(attributetuple))
                {
                    OptionalValuesPerParameterDict[attributetuple].Add(attributeValue);
                }
                else
                {
                    OptionalValuesPerParameterDict.Add(attributetuple, new List <string> {
                        attributeValue
                    });
                }
            }
        }
Exemplo n.º 6
0
        public string UpdateXMLProperty()
        {
            string userFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            string userFolderWithGingerTemp = userFolder + @"\Temp\GingerTemp";
            string fileForCommand           = userFolder + @"\Temp\GingerTemp\fileForCommand.xml";

            if (!System.IO.Directory.Exists(userFolderWithGingerTemp))
            {
                System.IO.Directory.CreateDirectory(userFolderWithGingerTemp);
            }

            string testSuite     = mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.TestSuite);
            string testCase      = mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.TestCase);
            string XMLFiledValue = mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.XMLFile);
            ObservableList <ActInputValue> TestSuitePlaceHolder = mAct.TestSuitePlaceHolder;

            ObservableList <ActSoapUiInputValue> AllProperties = mAct.AllProperties;

            if (!XMLFiledValue.Equals(string.Empty))
            {
                if (XMLFiledValue.Substring(XMLFiledValue.Length - 4).ToUpper().Equals(".XML"))
                {
                    if (XMLFiledValue.Substring(0, 1).Equals("~"))
                    {
                        string SolutionFolder = mAct.SolutionFolder;
                        XMLFiledValue = System.IO.Path.Combine(SolutionFolder, XMLFiledValue.Substring(2));
                    }

                    XmlDocument doc = new XmlDocument();
                    doc.Load(XMLFiledValue);
                    XmlNamespaceManager manager = XMLDocExtended.GetAllNamespaces(doc);

                    XmlNodeList caseProperties    = doc.SelectNodes("//*[local-name()='soapui-project']/*[local-name()='testSuite'][@name='" + testSuite + "']/*[local-name()='testCase'][@name='" + testCase + "']/*[local-name()='properties']/*[local-name()='property']", manager);
                    XmlNodeList suiteProperties   = doc.SelectNodes("//*[local-name()='soapui-project']/*[local-name()='testSuite'][@name='" + testSuite + "']/*[local-name()='properties']/*[local-name()='property']", manager);
                    XmlNodeList stepProperties    = doc.SelectNodes("//*[local-name()='soapui-project']/*[local-name()='testSuite'][@name='" + testSuite + "']/*[local-name()='testCase'][@name='" + testCase + "']/*[local-name()='testStep'][@type='properties']/*[local-name()='config']/*[local-name()='properties']/*[local-name()='property']", manager);
                    XmlNodeList projectProperties = doc.SelectNodes("//*[local-name()='soapui-project']/*[local-name()='properties']/*[local-name()='property']", manager);

                    foreach (ActSoapUiInputValue AIV in AllProperties)
                    {
                        if (AIV.Type == ActSoapUiInputValue.ePropertyType.Project.ToString())
                        {
                            UpdateProperty(projectProperties, AIV);
                        }
                        if (AIV.Type == ActSoapUiInputValue.ePropertyType.TestSuite.ToString())
                        {
                            UpdateProperty(suiteProperties, AIV);
                        }
                        if (AIV.Type == ActSoapUiInputValue.ePropertyType.TestCase.ToString())
                        {
                            UpdateProperty(caseProperties, AIV);
                        }
                        if (AIV.Type == ActSoapUiInputValue.ePropertyType.TestStep.ToString())
                        {
                            UpdateProperty(stepProperties, AIV);
                        }
                    }

                    doc.Save(fileForCommand);

                    if (mAct.TestSuitePlaceHolder.Count > 0)
                    {
                        string fileContent;
                        if (File.ReadAllText(fileForCommand).Equals(string.Empty))
                        {
                            fileContent = File.ReadAllText(XMLFiledValue);
                        }
                        else
                        {
                            fileContent = File.ReadAllText(fileForCommand);
                        }

                        foreach (ActInputValue AIV in TestSuitePlaceHolder)
                        {
                            string propertyName  = AIV.Param;
                            string propertyValue = AIV.ValueForDriver;
                            fileContent = fileContent.Replace(propertyName, propertyValue);
                        }
                        File.WriteAllText(fileForCommand, fileContent, Encoding.ASCII);
                    }
                }
            }
            return(fileForCommand);
        }
        private void AddXMLValueToOptionalValuesPerParameterDict(Dictionary <Tuple <string, string>, List <string> > OptionalValuesPerParameterDict, XMLDocExtended XDN)
        {
            Tuple <string, string> tuple = new Tuple <string, string>(XDN.LocalName, XDN.XPath);
            string Value = XDN.Value;

            if (OptionalValuesPerParameterDict.ContainsKey(tuple))
            {
                OptionalValuesPerParameterDict[tuple].Add(Value);
            }
            else
            {
                OptionalValuesPerParameterDict.Add(tuple, new List <string>()
                {
                    Value
                });
            }
        }