Example #1
0
        private void ReadAction(TestCase testCase, XmlReader xmlReader)
        {
            xmlReader.Read();

            while (xmlReader.NodeType != XmlNodeType.EndElement)
            {
                string       businessActionName = xmlReader.Name;
                TestCaseStep testCaseStep       = new TestCaseStep(businessActionName);

                BusinessAction businessAction = businessActionsRepository.GetAction(businessActionName);

                if (xmlReader.HasAttributes)
                {
                    while (xmlReader.MoveToNextAttribute())
                    {
                        string parameterName = xmlReader.LocalName;
                        string valueString   = xmlReader.Value;

                        BusinessActionParameter parameter = businessAction.GetParameter(parameterName);

                        // convert value
                        try
                        {
                            object value = Convert.ChangeType(
                                valueString,
                                parameter.ParameterType,
                                CultureInfo.InvariantCulture);

                            testCaseStep.AddParameter(new TestStepParameter(parameterName, value));
                        }
                        catch (InvalidCastException ex)
                        {
                            throw new InvalidCastException(
                                      string.Format(
                                          CultureInfo.InvariantCulture,
                                          "Could not cast parameter value '{0}' to '{1}'. Test case = '{2}', business action = '{3}', parameter = '{4}'",
                                          valueString,
                                          parameter.ParameterType.Name,
                                          testCase.TestCaseName,
                                          businessAction.ActionName,
                                          parameter.ParameterName),
                                      ex);
                        }
                    }

                    // move back to element
                    xmlReader.MoveToElement();
                }

                // add test action parameters
                testCase.AddStep(testCaseStep);

                // end of Action element
                xmlReader.Read();
            }

            // end of TestCase element
            xmlReader.Read();
        }
Example #2
0
 /// <summary>
 /// Adds a test step to the test case.
 /// </summary>
 /// <param name="testCaseStep">Test step to add.</param>
 public void AddStep(TestCaseStep testCaseStep)
 {
     testSteps.Add(testCaseStep);
 }