/**
         * Excute function with input = values, then return output result.
         * Use this method to excute not void function.
         * */
        public static bool ExcuteFunction(string keyword, string values,ref string error_mes, ref object output)
        {
            try
            {
                List<StringReplace> listReplace = util.getReplaceString(ref values);

                ReflectMethod meth = Methods.Single(w => w._Keyword.Equals(keyword));
                List<string> listValue = util.getListValueFromString(values);
                int n = listValue.Count;
                if (n == 1 && listValue[0].Equals("")) {
                    n = 0;
                }

                List<string> ArgTypes = meth.getArgumentsType();
                if (n != ArgTypes.Count) {
                    error_mes = ErrorMessage.INVALID_METHOD_ARGUMENT;
                    return false;
                }
                for (int i = 0; i < n; i++)
                {
                    foreach (StringReplace strReplace in listReplace)
                    {
                        if (listValue[i].Equals(strReplace.Replace))
                        {
                            listValue[i] = strReplace.Value;
                            break;
                        }
                    }
                }
                object[] mParam = new object[n];
                for (int i = 0; i < n; i++)
                {
                    object tam = null;
                    if (!getOdject(ArgTypes[i], listValue[i], ref tam))
                    {
                        error_mes = ErrorMessage.CONVERSION_TYPE;
                        return false;
                    }
                    mParam[i] = tam;
                }
                string excuteMes = "";
                Dictionary<string, string> listTConfig = new Dictionary<string, string>();
                string excelPath = ConfigurationSettings.AppSettings["ExcelFile"];
                ExcelDataAccess exceldataAccess = new ExcelDataAccess(excelPath);
                listTConfig = exceldataAccess.getTestConfig();
                bool flag = meth.Excute(mParam, ref output, ref excuteMes, listTConfig);
                if (flag == false)
                {
                    error_mes = ErrorMessage.USERCODE + "\n" + excuteMes;
                    return false;
                }
                return true;
            }
            catch (Exception e)
            {
                error_mes = ErrorMessage.USERCODE;
                return false;
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            XmlDataAccess XmlHelper1 = new XmlDataAccess("performanceConfig.xml");
            XmlDataAccess XmlHelper2 = new XmlDataAccess("performanceInput.xml");
            XmlDataAccess XmlHelper3 = new XmlDataAccess("performanceReport.xml");
            List<TestCommand> listTCommand = XmlHelper1.getTestCommands();
            ComponentFunction.Initialize(listTCommand);
            List<TestSuite> listTSuite = XmlHelper1.getTestSuites();
            List<TestData> listTData = new List<TestData>();
            Dictionary<string, string> listTConfig = new Dictionary<string, string>();

            string excelPath = ConfigurationSettings.AppSettings["ExcelFile"];

            ExcelDataAccess exceldataAccess = new ExcelDataAccess(excelPath);
            listTConfig = exceldataAccess.getTestConfig();

            listTConfig = XmlHelper1.getTestConfig();

            foreach (TestSuite tsuite in listTSuite) {
                string Log = "";
                if (tsuite.Construct(ref Log)) {
                    List<string> listvalues = XmlHelper2.getValues(tsuite.getName());
                    foreach (string values in listvalues) {
                        Log = "";
                        TestData temp = new TestData();

                        string description = string.Empty;
                        if (tsuite.Debug(values, ref Log, ref description, listTConfig))
                        {
                            temp.TestCase = tsuite.getName();
                            temp.Values = values;
                            temp.Result = Glossary.PASS;
                            temp.Comment = Log;
                        }else{
                            temp.TestCase = tsuite.getName();
                            temp.Values = values;
                            temp.Result = Glossary.FAILURE;
                            temp.Comment = Log;
                        }
                        listTData.Add(temp);
                    }
                }
            }
            XmlHelper3.BuildReport(listTData);
            Console.ReadLine();
        }
Esempio n. 3
0
        public List<TestData> Run()
        {
            foreach (TestData tdata in _listTDatas)
            {
                if (tdata.Result.Equals("") || tdata.Result.Equals(Glossary.NOTRUN))
                {

                    string temp = "";
                    string description = string.Empty;
                    Dictionary<string, string> listTConfig = new Dictionary<string, string>();
                    string excelPath = ConfigurationSettings.AppSettings["ExcelFile"];
                    ExcelDataAccess exceldataAccess = new ExcelDataAccess(excelPath);
                    listTConfig = exceldataAccess.getTestConfig();
                    if (Debug(tdata.Values, ref temp, ref description, listTConfig))
                    {
                        tdata.Result = Glossary.PASS;
                    }
                    else
                    {
                        tdata.Result = Glossary.FAILURE;
                        tdata.Comment = temp;
                    }
                }
            }
            return _listTDatas;
        }