Exemplo n.º 1
0
        ///<summary>
        /// Loads the Xml and Execute the test cases
        ///
        ///</summary>
        public void Play()
        {
            ActionsQueue queue = new ActionsQueue();

            XmlElement element = (XmlElement)_xmlDoc.SelectSingleNode("KeyboardTestCase");


            // Retriving the test Xmal Content for set up the environment, right now all the variations share the
            // same enviroment.

            XmlElement    xamlElement = (XmlElement)element.SelectSingleNode("Xaml");
            XmlTextWriter writer      = new XmlTextWriter("KeyboardTestEnvironment.xml", System.Text.Encoding.Unicode);

            xamlElement.WriteContentTo(writer);
            writer.Close();


            // Getting all the Variations
            XmlNodeList xmlList = element.SelectNodes("RecordActions");

            for (int j = 0; j < xmlList.Count; j++)
            {
                XmlElement    actionTest    = (XmlElement)xmlList[j];
                ModelTestCase modelTestCase = convertXmlElementToModelTestCase(_model, actionTest);

                queue.Enqueue(modelTestCase);
            }


            // This is actually executing the test cases
            GeneralTestCaseLoader tcLoader = new GeneralTestCaseLoader(queue);

            tcLoader.AddModel(_model);
            tcLoader.Run();
        }
Exemplo n.º 2
0
        ///<summary>
        /// This is been used to convert XmlElement to a modeltestcase. This method also populate the
        /// ModelTransitions
        ///</summary>
        ModelTestCase convertXmlElementToModelTestCase(Model model, XmlElement xmlElement)
        {
            ModelTestCase modelTestCase = new ModelTestCase();

            //This will call BeginCase, this is a pattern for State-based Modeling
            ModelTransition modelTransition = new ModelTransition(model);

            modelTransition.ActionName = "";
            modelTestCase.AddTransition(modelTransition);

            modelTransition            = new ModelTransition(model);
            modelTransition.ActionName = "LoadEnvironment";
            modelTransition.InParams.Add("Filename", "KeyboardTestEnvironment.xml");
            modelTestCase.AddTransition(modelTransition);

            for (int i = 0; i < xmlElement.ChildNodes.Count; i++)
            {
                modelTransition = new ModelTransition(model);
                modelTestCase.AddTransition(modelTransition);
                convertToModelTransition(modelTransition, (XmlElement)xmlElement.ChildNodes[i]);
            }

            modelTestCase.AddTransition(new ModelEndTransition(model, new State()));

            return(modelTestCase);
        }