Пример #1
0
        /// <summary>
        /// Goes through all action elements in xml file
        /// </summary>
        /// <param name="businessActionsRepository">object that will contain all data about business actions and functions</param>
        /// <param name="xmlReader">Xml reader provides access to xml file</param>
        private void ReadAction(BusinessActionsRepository businessActionsRepository, XmlReader xmlReader)
        {
            xmlReader.Read();

            while (xmlReader.NodeType != XmlNodeType.EndElement)
            {
                switch (xmlReader.Name)
                {
                case "action":
                {
                    string testActionId = ReadAttribute("id", xmlReader);

                    BusinessAction businessAction = new BusinessAction(testActionId);

                    // read action parameters
                    ReadActionParameters(businessAction, xmlReader);

                    // add new action to list
                    businessActionsRepository.AddAction(businessAction);

                    break;
                }

                case "function":
                {
                    xmlReader.Skip();
                    break;
                    //        string functionId = ReadAttribute("id", xmlReader);

                    //        BusinessFunctionEntry businessFunctionEntry = new BusinessFunctionEntry(functionId);

                    //        // read function steps
                    //        ReadFunctionsSteps(businessFunctionEntry, xmlReader);

                    //        // add new function to list
                    //        businessActionsRepository.Functions.Add(businessFunctionEntry);

                    //        break;
                }

                default:
                {
                    throw new System.NotSupportedException();
                }
                }
            }

            xmlReader.Read();
        }
Пример #2
0
        /// <summary>
        /// Parse xml to object <see cref="BusinessActionsRepository" />
        /// </summary>
        /// <returns>
        /// <see cref="BusinessActionsRepository" />
        /// Object that contains all business actions data
        /// </returns>
        public BusinessActionsRepository Parse()
        {
            XmlReaderSettings xmlReaderSettings =
                new XmlReaderSettings
            {
                IgnoreComments = true,
                IgnoreProcessingInstructions = true,
                IgnoreWhitespace             = true
            };

            BusinessActionsRepository businessActionsRepository = new BusinessActionsRepository();

            using (XmlReader xmlReader = XmlReader.Create(xmlStream, xmlReaderSettings))
            {
                xmlReader.Read();

                while (false == xmlReader.EOF)
                {
                    switch (xmlReader.NodeType)
                    {
                    case XmlNodeType.Element:
                    {
                        if (xmlReader.Name != "actions")
                        {
                            throw new XmlException("<actions> (root) element expected.");
                        }

                        ReadAction(businessActionsRepository, xmlReader);

                        break;
                    }

                    case XmlNodeType.XmlDeclaration:
                        xmlReader.Read();
                        continue;

                    default:
                    {
                        throw new System.NotSupportedException();
                    }
                    }
                }
            }

            return(businessActionsRepository);
        }
Пример #3
0
        public string ExpandDescriptionWithParameterValues(BusinessActionsRepository businessActionsRepository)
        {
            BusinessAction businessAction = businessActionsRepository.GetAction(ActionName);
            string         description    = businessAction.Description;

            if (HasParameters)
            {
                List <object> args = new List <object>();

                foreach (BusinessActionParameter parameter in businessAction.EnumerateParameters())
                {
                    object value = this.GetParameterValue(parameter.ParameterName);
                    args.Add(value);
                }

                return(String.Format(CultureInfo.InvariantCulture, description, args.ToArray()));
            }

            return(description);
        }
Пример #4
0
 public XmlTestSuiteParser(string testSuiteFileName, BusinessActionsRepository businessActionsRepository)
 {
     xmlSpecsStream = File.OpenRead(testSuiteFileName);
     this.businessActionsRepository = businessActionsRepository;
 }
Пример #5
0
 public XmlTestSuiteParser(Stream stream, BusinessActionsRepository businessActionsRepository)
 {
     xmlSpecsStream = stream;
     this.businessActionsRepository = businessActionsRepository;
 }