Beispiel #1
0
        public override int ExecuteVariation(CXmlDriverParam param)
        {
            CError.WriteLine("Test Parameters : ");
            CError.WriteLine(this.CurVariation.Desc);
            CFactory f = null;
            string factoryToInvoke = param.SelectExistingValue("DriverFunction");
            switch (factoryToInvoke) //seperates whether to call Reader or Writer
            {
                case "XmlReader":
                    f = new CReaderFactory();
                    break;
                case "XmlWriter":
                    f = new CWriterFactory();
                    break;
                default:
                    throw new
                            CTestFailedException("Invalid XmlDriverScenario passed in : " + factoryToInvoke);
            }
            CFactory.TestState testResult = f.TestVariation(param);
            if (testResult == CFactory.TestState.Pass)
                return TEST_PASS;
            else if (testResult == CFactory.TestState.Skip)
                return TEST_SKIPPED;

            return TEST_FAIL;
        }
Beispiel #2
0
        //Constructor
        internal CXmlDriverVariation(CXmlDriverScenario testCase,
            string name, string description, int id, int pri,
            CXmlDriverParam xmlDriverParams) : base(testCase)
        {
            _xmlDriverParams = xmlDriverParams;

            // use name as a description if provided
            if (name != null)
                this.Desc = name;
            else
                this.Desc = description;
            this.Name = name;


            this.Pri = pri;
            this.id = id;
        }
Beispiel #3
0
        // Creates test case class
        private CXmlDriverScenario CreateTestCase(string name, string desc, CXmlDriverParam param)
        {
            CXmlDriverScenario tmp = null;

            try
            {
                //Create this class (call the constructor with no arguments)
                tmp                = new CRWFactoryDriverScenario();
                tmp.Name           = name;
                tmp.Desc           = desc;
                tmp.TestModule     = TestModule;
                tmp.XmlDriverParam = param;
                if (_isRequiredCultureInfoNeedToBeSet)
                {
                    tmp.RequiredCultureInfo = _requiredCultureInfo;
                }
            }
            catch (Exception e)
            {
                throw new CXmlDriverException("XmlDriver: CreateIntance failed for TestCase '" + "CRWFactoryDriverScenario" /*type.Name*/ + "' (" + e.ToString() + ")");
            }
            return(tmp);
        }
 public abstract int ExecuteVariation(CXmlDriverParam param);
Beispiel #5
0
        /// <summary>
        /// This method will be called by ExecuteVariation and it will 
        /// orchestrate the state.
        /// </summary>
        /// <param name="param"></param>
        /// <returns>TEST_SUCCESS, TEST_FAIL or TEST_SKIPPED
        /// </returns>
        public TestState TestVariation(CXmlDriverParam param)
        {
            // The following commands actually test the variation.
            Init(param);

            PreTest();
            CError.Compare(pstate, TestState.PreTest, "Invalid State: " + pstate);
            try
            {
                Test();
                if (pstate == TestState.Skip)
                {
                    return TestState.Skip;
                }
                CError.Compare(pstate, TestState.Pass, "Invalid State: " + pstate);
            }
            catch (Exception readerException)
            {
                Log(readerException.ToString());
                if (!IsVariationValid)
                {
                    if (!CheckException(readerException))
                    {
                        pstate = TestState.Error;
                        DumpVariationInfo();
                        throw readerException;
                    }
                    else
                    {
                        pstate = TestState.Pass;
                    }
                }
                else //Variation was valid
                {
                    pstate = TestState.Error;
                    DumpVariationInfo();
                    throw readerException;
                }
            }
            finally //do we need this style? what if somehow state is not pass, investigate
            {
                PostTest();
            }

            Log("State at the End: " + pstate);

            if (pstate == TestState.Complete)
                return TestState.Pass;

            return TestState.Error;
        }
Beispiel #6
0
        /// <summary>
        /// Init does the following :
        /// Store Parameter Info.
        /// Parse out the commonly required and universal tags
        /// </summary>
        public virtual void Init(CXmlDriverParam param)
        {
            varInfo = param;
            string resultType = varInfo.SelectExistingValue("Result/@Type", "Data");
            if (resultType == "Valid")
                isValid = true;
            else
                isValid = false;

            exceptionType = varInfo.SelectValue("Result/ExceptionType", "Data");
            exceptionMsg = varInfo.SelectValue("Result/ExceptionMessage", "Data");
            xmlFile = varInfo.SelectValue("Result/TestXmlFile", "Data");
            filePath = varInfo.SelectValue("filepath", "Data");
            filePath = FilePathUtil.ExpandVariables(filePath);
            if (filePath == null)
            {
                Log("Setting filePath = " + filePath);
            }
            httpPath = varInfo.SelectValue("httppath", "Data");
        }
Beispiel #7
0
 // Creates test case class
 private CXmlDriverScenario CreateTestCase(string name, string desc, CXmlDriverParam param)
 {
     CXmlDriverScenario tmp = null;
     try
     {
         //Create this class (call the constructor with no arguments)
         tmp = new CRWFactoryDriverScenario();
         tmp.Name = name;
         tmp.Desc = desc;
         tmp.TestModule = TestModule;
         tmp.XmlDriverParam = param;
         if (_isRequiredCultureInfoNeedToBeSet)
             tmp.RequiredCultureInfo = _requiredCultureInfo;
     }
     catch (Exception e)
     {
         throw new CXmlDriverException("XmlDriver: CreateIntance failed for TestCase '" + "CRWFactoryDriverScenario"/*type.Name*/ + "' (" + e.ToString() + ")");
     }
     return tmp;
 }
Beispiel #8
0
 private static CXmlDriverParam[] ToXmlDriverParamArray(IList list)
 {
     CXmlDriverParam[] arr = new CXmlDriverParam[list.Count];
     for (int i = 0; i < arr.Length; i++)
         arr[i] = (CXmlDriverParam)list[i];
     return arr;
 }
Beispiel #9
0
 public abstract int ExecuteVariation(CXmlDriverParam param);