Example #1
0
        /// <summary>
        /// Factory method to get a test <see cref="Scenario"/> instance.
        /// </summary>
        /// <param name="parent">
        /// The parent, which is of type <see cref="TestCase"/>.
        /// </param>
        /// <param name="fullyQualifiedName">
        /// The fully qualified name.
        /// </param>
        /// <returns>
        /// The <see cref="Scenario"/> instance.
        /// </returns>
        public static Scenario GetTestScenario(TestCase parent, string fullyQualifiedName)
        {
            if (parent == null)
            {
                throw new ArgumentNullException("parent", "The parent test case cannot be null");
            }

            if (string.IsNullOrWhiteSpace(fullyQualifiedName))
            {
                throw new ArgumentException("Test scenario FQDN cannot be null or empty", "fullyQualifiedName");
            }

            var scenario = new Scenario { TestCase = parent, FullyQualifiedName = fullyQualifiedName };

            return scenario;
        }
Example #2
0
        /// <summary>
        /// Updates the scenario element in this instance.
        /// </summary>
        /// <param name="scenario">
        /// The scenario.
        /// </param>
        private static void UpdateScenarioElement(Scenario scenario)
        {
            if (scenario == null)
            {
                throw new ArgumentNullException("scenario", "Cannont save null test scenario to test result.");
            }

            if (scenario.Saved)
            {
                return;
            }

            XElement scenarioElement = InitTestScenario(scenario);
            UpdateEntityElement(scenario, scenarioElement);
            scenario.Messages.ForEach(message => UpdateTestEntityMessageElement(message, scenarioElement));
            scenario.Saved = true;
        }
Example #3
0
        /// <summary>
        /// Create a child <see cref="Scenario"/> from the given scenario name.
        /// </summary>
        /// <param name="name">
        /// The name for the new <see cref="Scenario"/>.
        /// </param>
        /// <returns>
        /// A new instance of <see cref="Scenario"/>.
        /// </returns>
        public Scenario CreateScenario(string name)
        {
            string scenarioName;
            switch (name)
            {
                case "":
                    {
                        scenarioName = "string.Empty";
                        break;
                    }
                case null:
                    {
                        scenarioName = "null scenario name";
                        break;
                    }
                default:
                    {
                        scenarioName = name;
                        break;
                    }
            }

            Scenario scenario = new Scenario(this, string.Format("[{0}]: ", scenarioName));
            return scenario;
        }
Example #4
0
        /// <summary>
        /// Initialize the test scenario.
        /// </summary>
        /// <param name="entity">
        /// The entity.
        /// </param>
        /// <returns>
        /// The <see cref="XElement"/>.
        /// </returns>
        /// <exception cref="NullReferenceException">
        /// </exception>
        private static XElement InitTestScenario(Scenario entity)
        {
            if (entity.TestCase == null)
            {
                throw new ArgumentNullException(
                    "entity", string.Format("Test scenario [{0}] is not linked with a test case.", entity.Name));
            }

            // Get the parent element from loaded xml result file
            XElement parent = InitTestCase(entity.TestCase);

            XElement scenarioElement = GetEntityElement(entity, parent, Constants.ScenarioElement);

            if (scenarioElement == null)
            {
                scenarioElement = ConstructEntityXElement(entity, Constants.ScenarioElement);

                parent.Add(scenarioElement);
            }

            return scenarioElement;
        }