コード例 #1
0
        public void Test_EatVariableDefines()
        {
            List <string> text = new List <string>()
            {
                "//123123",
                "",
                "定义 : 变量1 = 变量2  ",
                " 定义:变量2=1000@时间戳",
                "//",
                "   ",
                "测试123123",
                "123123"
            };
            var expected = new List <string>()
            {
                "//123123",
                "",
                "//",
                "   ",
                "测试123123",
                "123123"
            };
            var expectedVariable = new List <string>()
            {
                "定义 : 变量1 = 变量2  ",
                " 定义:变量2=1000@时间戳",
            };
            List <string> definedLines = new List <string>();
            var           result       = TextPreProcesser.EatVariableDefines(text, out definedLines);

            Assert.IsTrue(IsListEquals(result, expected));
            Assert.IsTrue(IsListEquals(definedLines, expectedVariable));
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: fcmai/AutomatedTesting
        //读函数
        private static Dictionary <string, UserFunctionDefinition> LoadFunctionsFromFiles()
        {
            var funFiles         = GetFunctionDefineFileNames();
            var funScripts       = funFiles.SelectMany(p => LoadFromFile(p)).ToList();
            var preprocessResult = TextPreProcesser.PreprocessV2(funScripts.ToList());
            var funs             = preprocessResult.Item3;
            var funcDefinitions  = FuncProcessor.Instance.GetFunctionDefines(funs);

            return(funcDefinitions);
        }
コード例 #3
0
        public void Test_Explain()
        {
            var defineVariable = new List <string>()
            {
                "定义 : 变量1 = 变量2  ",
                " 定义:变量2=1000@时间戳",
                " 定义:变量3=随机数@随机数109",
                " 定义 :变量4=1000=[@时间戳",
            };
            var resultDict = TextPreProcesser.Explain(defineVariable);

            Assert.IsTrue(resultDict.Count == 4);
            Assert.IsTrue(resultDict["变量1"] == "变量2");
            Assert.IsTrue(resultDict["变量2"].StartsWith("1000"));
            Assert.IsTrue(resultDict["变量3"].StartsWith("随机数"));
            Assert.IsTrue(resultDict["变量3"].EndsWith("109"));
        }
コード例 #4
0
        public void Test_ConvertFunc()
        {
            try
            {
                List <string> actualParam = new List <string>
                {
                    "测试发薪方案", "薪酬1", "月"
                };
                var scriptContent = LoadFromFile("../../脚本/函数1.txt");
                var tupleObj      = TextPreProcesser.PreprocessV2(scriptContent.ToList());

                FuncProcessor.Instance.Process(actualParam, tupleObj.Item3);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #5
0
        public TestSuite CreateTestSuiteFrom(string[] userTestLines, string suiteName)
        {
            TestSuite           suite            = new TestSuite(suiteName);
            var                 result           = TextPreProcesser.Preprocess(userTestLines.ToList());
            var                 defaultVersion   = ExtractFrontEndVersion(result.Item1);
            ConstructingContext context          = new ConstructingContext(result.Item2, defaultVersion.Item2); //保存构建上下文
            var                 splitedCaseLines = SplitTestCases(defaultVersion.Item1);

            foreach (var caseTerm in splitedCaseLines)
            {
                if (caseTerm.Count == 0)
                {
                    continue;
                }
                var title = GetCaseTitle(caseTerm[0]);
                caseTerm.RemoveAt(0);
                suite.TestCases.Add(TestCaseFactory.Instance.CreateTestCase(caseTerm.ToArray(), title, context));
            }
            return(suite);
        }