コード例 #1
0
        string InstantiatedTestClass(string instantiationName, string exampleTableName)
        {
            StringBuilder instantiatedTestClass = new StringBuilder();

            if (!BDDUtil.SupportUnicode)
            {
                instantiatedTestClass.AppendLine("// " + instantiationName);
            }

            instantiatedTestClass
            .AppendLine("INSTANTIATE_TEST_CASE_P(")
            .Append(BDDUtil.INDENT_DOUBLE)
            .Append(BDDUtil.to_ident(instantiationName))
            .AppendLine(",");

            instantiatedTestClass
            .Append(BDDUtil.INDENT_DOUBLE)
            .Append(BDDUtil.to_ident(ScenarioOutlineClassName))
            .AppendLine(",")
            .Append(BDDUtil.INDENT_DOUBLE)
            .Append("testing::ValuesIn(")
            .AppendLine(exampleTableName + ".Rows()));");

            return(instantiatedTestClass.ToString());
        }
コード例 #2
0
        string GetStepKeyword(string keyword)
        {
            string keyword_orig = BDDUtil.RemoveAllWhiteSpaces(keyword);

            if (GherkinKeyword.IsStepKeyword(keyword_orig, BDDStepImplBuilderContext.GherkinDialect.GivenStepKeywords))
            {
                return("Given");
            }
            else if (GherkinKeyword.IsStepKeyword(keyword_orig, BDDStepImplBuilderContext.GherkinDialect.WhenStepKeywords))
            {
                return("When");
            }
            else if (GherkinKeyword.IsStepKeyword(keyword_orig, BDDStepImplBuilderContext.GherkinDialect.ThenStepKeywords))
            {
                return("Then");
            }
            else if (GherkinKeyword.IsStepKeyword(keyword_orig, BDDStepImplBuilderContext.GherkinDialect.AndStepKeywords))
            {
                return("And");
            }
            else if (GherkinKeyword.IsStepKeyword(keyword_orig, BDDStepImplBuilderContext.GherkinDialect.ButStepKeywords))
            {
                return("But");
            }

            return(keyword_orig);
        }
コード例 #3
0
        private void MakeStepFunctionName()
        {
            string paramIndicator = "QQQQQQ";
            Regex  regex          = new Regex(paramIndicator);
            string stepRegexText  = stepRegex.Replace(StepText, paramIndicator);

            foreach (BDDStepArg stepArg in origArgList)
            {
                stepRegexText = regex.Replace(stepRegexText, stepArg.StepFunctionPlaceHolder, 1);
            }

            StepFunctionName = BDDUtil.MakeIdentifier(stepRegexText);
        }
コード例 #4
0
        string BuildFeatureTestClass()
        {
            StringBuilder testClass = new StringBuilder();

            testClass
            .AppendLine("// " + FeatureClassName)
            .AppendLine("class " + BDDUtil.to_ident(FeatureClassName) + " : public bdd::AbstractBDDTest")
            .AppendLine("{")
            .AppendLine(BuildSetupAndTearDown())
            .Append(backgoundBuilder.BuildScenario())
            .AppendLine("};");

            return(testClass.ToString());
        }
コード例 #5
0
        string BuildParameterizedTestClass()
        {
            StringBuilder scenarioOutlineClass = new StringBuilder();

            scenarioOutlineClass
            .AppendLine("class " + BDDUtil.to_ident(ScenarioOutlineClassName) + " :")
            .AppendLine(BDDUtil.INDENT + "public " + BDDUtil.to_ident(FeatureClassName) + ",")
            .AppendLine(BDDUtil.INDENT + "public WithParamInterface<GherkinRow>")
            .AppendLine("{")
            .AppendLine("public:")
            .Append(BuildSetupFunction())
            .AppendLine("};");

            return(scenarioOutlineClass.ToString());
        }
コード例 #6
0
        string BuildSetupFunction()
        {
            StringBuilder setupFunction = new StringBuilder();

            if (!BDDUtil.SupportUnicode)
            {
                setupFunction
                .AppendLine("// " + BDDUtil.INDENT_DOUBLE + FeatureClassName + "::SetUp();");
            }
            setupFunction
            .AppendLine(BDDUtil.INDENT + "void SetUp() override")
            .AppendLine(BDDUtil.INDENT + "{")
            .AppendLine(BDDUtil.INDENT_DOUBLE + BDDUtil.to_ident(FeatureClassName) + "::SetUp();")
            .AppendLine(BDDUtil.INDENT_DOUBLE + BuildGUIDTag())
            .AppendLine(BDDUtil.INDENT + "}");

            return(setupFunction.ToString());
        }
コード例 #7
0
        public override string BuildScenarioImpl()
        {
            StringBuilder scenarioImpl = new StringBuilder();

            if (!BDDUtil.SupportUnicode)
            {
                scenarioImpl.AppendLine("// TEST_F(" + FeatureClassName + ", " + ScenarioName + ")");
            }

            scenarioImpl
            .AppendLine("TEST_F(" + BDDUtil.to_ident(FeatureClassName) + ", " + BDDUtil.to_ident(ScenarioName) + ")")
            .AppendLine("{")
            .AppendLine(BDDUtil.INDENT + BuildGUIDTag())
            .AppendLine()
            .Append(BuildSteps(BDDUtil.INDENT))
            .AppendLine("}");

            return(scenarioImpl.ToString());
        }
コード例 #8
0
        string BuildTestBody()
        {
            StringBuilder scenarioOutlineTestBody = new StringBuilder();

            string scenarioOutline = BDDUtil.MakeIdentifier(ScenarioOutline.Name);

            if (!BDDUtil.SupportUnicode)
            {
                scenarioOutlineTestBody
                .AppendLine("// TEST_P(" + ScenarioOutlineClassName + ", " + ScenarioOutline + ")");
            }
            scenarioOutlineTestBody
            .AppendLine("TEST_P(" + BDDUtil.to_ident(ScenarioOutlineClassName) + ", " + BDDUtil.to_ident(scenarioOutline) + ")")
            .AppendLine("{")
            .AppendLine(BDDUtil.INDENT + "GherkinRow param = GetParam();")
            .AppendLine()
            .Append(BuildSteps(BDDUtil.INDENT))
            .AppendLine("}");

            return(scenarioOutlineTestBody.ToString());
        }