Example #1
0
        /// <summary>
        /// Extract all the test cases specify on the constructor and return will all the cases
        /// </summary>
        public ActionsQueue CreateActionsQueue()
        {
            int currentCase;

            LogComment("**************************************************************");
            LogComment("Start retrieving all the test cases from the XTC File");
            LogComment((_lastCase - _firstCase + 1).ToString() + " test cases found");

            //Go through each case specified
            for (currentCase = _firstCase; currentCase <= _lastCase; currentCase++)
            {
                LogStatus("Transitions for test case # " + (currentCase).ToString());

                XmlNodeList currentStepsNodeList = SetCurrentStepsForTestIndex(currentCase);



                for (int iStep = 0; iStep < currentStepsNodeList.Count; iStep++)
                {
                    ModelTestCase testCase;
                    testCase = new ModelTestCase();
                    State lastEndState = null;

                    XmlNodeList currentTransitionsList = SetCurrentTransitionFromStep(currentStepsNodeList, iStep);
                    Model       lastModel = null;
                    LogStatus((currentTransitionsList.Count).ToString() + " transtions found for current test case");

                    for (int currentTransitionIndex = 0; currentTransitionIndex < currentTransitionsList.Count; currentTransitionIndex++)
                    {
                        lastModel = EnqueueCurrentTransition(currentTransitionsList, currentTransitionIndex, out lastEndState, testCase);
                    }


                    testCase.AddTransition(new ModelEndTransition(lastModel, lastEndState));

                    _queue.Enqueue(testCase);

                    LogStatus("The transitions for test case # " + (currentCase).ToString() + " are retrieved");
                }
            }

            LogComment("All information is enqueued and ready for execution");
            LogComment("**************************************************************");

            return(_queue);
        }
Example #2
0
        /// <summary>
        /// Executes the Transition that is set by member variables
        /// </summary>
        /// <remarks>Check the Errors collection for errors</remarks>
        /// <returns>false if errors occur</returns>
        private Model EnqueueCurrentTransition(XmlNodeList currentTransitionsList, int transitionIndex, out State lastEndState, ModelTestCase testCase)
        {
            XmlNode     actionNode, stateNode;
            string      actionName;
            XmlNodeList inParams, outParams;

            State objInParams = null, objOutParams = null;
            State endState = null;

            XmlNode currTransition = null;
            Model   currModel;

            //Get the transition Node
            currTransition = currentTransitionsList.Item(transitionIndex);

            //Find the model
            currModel = GetModel(currTransition);

            //Get the In action Params
            objInParams = null;
            inParams    = currTransition.SelectNodes("curr:PARAM[@Type = 'In']", _nsmgr);
            if (inParams.Count > 0)
            {
                objInParams = this.GetActionParams(inParams);
                if (objInParams == null)
                {
                    throw new ModelLoaderException("Failure getting Action IN Params");
                }
            }

            //Get the Out action Params
            objOutParams = null;
            outParams    = currTransition.SelectNodes("curr:PARAM[@Type = 'Out']", _nsmgr);
            if (outParams.Count > 0)
            {
                objOutParams = this.GetActionParams(outParams);
                if (objOutParams == null)
                {
                    throw new ModelLoaderException("Failure getting Action OUT Params");
                }
            }

            //Get the action Node & use it to get the action name
            actionNode = currTransition.SelectSingleNode("curr:ACTION", _nsmgr);
            int fileID = -1;

            actionName = this.GetAction(actionNode, out fileID);
            if (actionName == null)
            {
                throw new ModelLoaderException("Failure finding an action for this transition");
            }

            //Get the state Node to create the object
            endState  = null;
            stateNode = currTransition.SelectSingleNode("curr:STATE", _nsmgr);
            //In stateless model case there will not be a STATE node in the xtc
            if (stateNode != null)
            {
                endState = this.GetState(stateNode);
                if (endState == null)
                {
                    throw new ModelLoaderException("Failure finding the state variables for this transition");
                }
            }


            if ((actionName == null) || (actionName.Trim() == "") && transitionIndex == 0)
            {
                testCase.AddTransition(new ModelTransition(currModel, String.Empty, null, endState, null, null));
                //_queue.Enqueue(new ModelTransition(currModel,String.Empty,null,endState,null,null));
            }
            else
            {
                //Log transition information & execute the action
                LogStatus(currModel.GetType().Name + "." + actionName + "(" + objInParams + ")");
                //_queue.Enqueue(new ModelTransition(currModel, actionName,null,endState,objInParams,objOutParams));
                testCase.AddTransition(new ModelTransition(currModel, actionName, null, endState, objInParams, objOutParams));
            }

            lastEndState = endState;

            return(currModel);
        }