コード例 #1
0
        public void HeaderGeneratorCreatesOneFeatureAndOneScenario()
        {
            IList <NodeFeature> features;

            features = new List <NodeFeature>();

            NodeFeature featureScenario = new NodeFeature("TestFeature1");

            featureScenario.Scenarios.Add(new NodeScenario("TestScenario1"));

            features.Add(featureScenario);

            var files = GeneratorFactory.Generate(GeneratorType.HeaderGenerator, features);

            string[] stringsExpected = new string[] {
                "#include \"CppUnitTest.h\"",
                "#include \"CppUnitTestHooks.h\"",
                "#include \"trim.hpp\"",
                "#include <vector>",
                "",
                "using namespace Microsoft::VisualStudio::CppUnitTestFramework;",
                "using namespace std;",
                "",
                "namespace CppUnitTest",
                "{",
                "\tTEST_CLASS(TestFeature1)",
                "\t{",
                "\tpublic:",
                "\t\tTEST_METHOD(TestScenario1);",
                "\t};",
                "}"
            };

            AssertExt.ContentsOfStringArray(stringsExpected, files[0]);
        }
コード例 #2
0
        private void BuildTestClass(NodeFeature feature)
        {
            List <string>   privateContents = new List <string>();
            List <string>   publicContents  = new List <string>();
            List <NodeStep> uniqueSteps     = new List <NodeStep>();

            foreach (var scenario in feature.Scenarios)
            {
                AddScenario(scenario, feature.Hooks, publicContents);
                List <NodeStep> stepsToPrint = new List <NodeStep>();
                foreach (var step in scenario.Steps)
                {
                    if (!uniqueSteps.Any(uniqueStep => uniqueStep.Equals(step)))
                    {
                        uniqueSteps.Add(step);
                        stepsToPrint.Add(step);
                    }
                }

                AddStepsForScenario(stepsToPrint, scenario, feature.Scenarios, privateContents);
            }

            OpenTestClassPublicSection(feature.Hooks);

            contents.AddRange(publicContents);

            if (privateContents.Count > 0)
            {
                contents.AddRange(privateContents);
            }
        }
コード例 #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="label">Label string (e.g., "Arg0", "Modifier-Temporal", "Arg1-H0", etc.)</param>
        /// <param name="confidence">Confidence of label</param>
        public NomBankNodeLabel(string label, float confidence)
        {
            _confidence    = confidence;
            _hyphenIndexes = new List <HyphenationIndex>();

            string[] labelParts = label.Split('-');

            // first part is always type
            _type = (NodeType)Enum.Parse(typeof(NodeType), labelParts[0]);

            // check for second part
            if (labelParts.Length > 1)
            {
                string secondPart = labelParts[1];

                // try to parse second part as a feature
                try { _feature = (NodeFeature)Enum.Parse(typeof(NodeFeature), secondPart); }
                catch (Exception)
                {
                    // if not a feature, the second part must be a hyphenation index
                    _hyphenIndexes.Add((HyphenationIndex)Enum.Parse(typeof(HyphenationIndex), secondPart));
                }
            }

            // any remaining parts must be hyphenation indexes
            for (int i = 2; i < labelParts.Length; ++i)
            {
                _hyphenIndexes.Add((HyphenationIndex)Enum.Parse(typeof(HyphenationIndex), labelParts[i]));
            }
        }
コード例 #4
0
        private void BuildTestClass(NodeFeature feature)
        {
            List <string>   privateContents   = new List <string>();
            List <string>   publicContents    = new List <string>();
            List <NodeStep> filterUniqueSteps = new List <NodeStep>();

            foreach (var scenario in feature.Scenarios)
            {
                AddScenario(scenario, feature.Hooks, publicContents);
                if ((scenario.Steps.Count > 0) && (feature.Scenarios.First() == scenario))
                {
                    OpenTestClassPrivateSection(privateContents);
                }
                AddSteps(GeneratorHelper.FindUniqueSteps(filterUniqueSteps, scenario.Steps), scenario, privateContents);
            }

            OpenTestClassPublicSection(feature.Hooks);

            Contents.AddRange(publicContents);

            if (privateContents.Count > 0)
            {
                Contents.AddRange(privateContents);
            }
        }
コード例 #5
0
        public void StepGeneratorCreatesOneScenarioTwoDuplicateSteps()
        {
            IList <NodeFeature> features;

            features = new List <NodeFeature>();

            //Add scenario 1
            NodeScenario scenario1 = new NodeScenario("Scenario1");

            scenario1.Steps.Add(new NodeStep("GivenMethod1"));
            scenario1.Steps.Add(new NodeStep("GivenMethod1"));

            //Add feature
            NodeFeature feature1 = new NodeFeature("Feature1");

            feature1.Scenarios.Add(scenario1);
            features.Add(feature1);

            var files = GeneratorFactory.Generate(GeneratorType.StepDefinitionGenerator, features);

            string[] stringsExpected = new string[] {
                "#include \"Feature1.h\"",
                "",
                "namespace CppUnitTest",
                "{",
                "\tvoid Feature1::GivenMethod1()",
                "\t{",
                "\t\tAssert::Fail(L\"Pending implementation...\");",
                "\t}",
                "}"
            };
            AssertExt.ContentsOfStringArray(stringsExpected, files[0]);
        }
コード例 #6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="type">Type of node</param>
 /// <param name="confidence">Confidence of label</param>
 public NomBankNodeLabel(NodeType type, float confidence)
 {
     _type          = type;
     _confidence    = confidence;
     _feature       = NodeFeature.None;
     _hyphenIndexes = new List <HyphenationIndex>();
     _hashCode      = type.ToString().GetHashCode();
 }
コード例 #7
0
        protected override string[] BuildContents(NodeFeature feature)
        {
            BuildIncludeStatements(feature.Name);
            OpenNameSpace(LanguageConfig.NameSpace);
            BuildScenarioMethods(feature.Name, feature.Scenarios);
            CloseNameSpace();

            return(Contents.ToArray());
        }
コード例 #8
0
        public void HeaderGeneratorCreatesOneFeatureTwoScenariosAndOneStep()
        {
            IList <NodeFeature> features;

            features = new List <NodeFeature>();

            //Creates Step 1 for Scenario 1 & Adds to list
            NodeStep step1Scenario1 = new NodeStep("GivenMethod1Scenario1");

            //Creates Step 1 for Scenario 2 & Adds to list
            NodeStep step1Scenario2 = new NodeStep("GivenMethod1Scenario2");

            //Creates Scenario 1 & Adds to list
            NodeScenario scenario1 = new NodeScenario("TestScenario1");

            scenario1.Steps.Add(step1Scenario1);

            //Creates Scenario 2 & Adds to list
            NodeScenario scenario2 = new NodeScenario("TestScenario2");

            scenario2.Steps.Add(step1Scenario2);

            //Creates Feature & Adds to list
            NodeFeature feature = new NodeFeature("TestFeature1");

            feature.Scenarios.Add(scenario1);
            feature.Scenarios.Add(scenario2);
            features.Add(feature);

            var files = GeneratorFactory.Generate(GeneratorType.HeaderGenerator, features);

            string[] stringsExpected = new string[] {
                "#include \"CppUnitTest.h\"",
                "#include \"CppUnitTestHooks.h\"",
                "#include \"trim.hpp\"",
                "#include <vector>",
                "",
                "using namespace Microsoft::VisualStudio::CppUnitTestFramework;",
                "using namespace std;",
                "",
                "namespace CppUnitTest",
                "{",
                "\tTEST_CLASS(TestFeature1)",
                "\t{",
                "\tpublic:",
                "\t\tTEST_METHOD(TestScenario1);",
                "\t\tTEST_METHOD(TestScenario2);",
                "",
                "\tprivate:",
                "\t\tvoid GivenMethod1Scenario1();",
                "\t\tvoid GivenMethod1Scenario2();",
                "\t};",
                "}"
            };

            AssertExt.ContentsOfStringArray(stringsExpected, files[0]);
        }
コード例 #9
0
ファイル: InputGenerator.cs プロジェクト: altran-nl/specflowC
 private void AddFeature(string formattedLine, string label)
 {
     if (MakePreviousScenarioHookAFeatureHookHack)
     {
         MakePreviousScenarioHookAFeatureHook(); // undo previous scenario hook in scenarioHooks
         MakePreviousScenarioHookAFeatureHookHack = false;
     } // else no need to undo previous scenario hook
     lastFeature = new NodeFeature(GherkinParser.ParseNameWithLabel(formattedLine, label), featureHooks);
     features.Add(lastFeature);
 }
コード例 #10
0
        protected override string[] BuildContents(NodeFeature feature)
        {
            BuildIncludeStatement();
            BuildHeaderStatement();
            OpenNameSpace();
            BuildStepClass(feature.Name, feature.Scenarios);
            CloseNameSpace();

            return(Contents.ToArray());
        }
コード例 #11
0
        public void StepGeneratorCreatesOneScenarioOneStepTwoParametersAndOneRow()
        {
            IList <NodeFeature> features;

            features = new List <NodeFeature>();

            //Add parameter 1
            Parameter p1 = new Parameter();

            p1.Name  = "Parameter1";
            p1.Type  = "string";
            p1.Value = "ValueOfParameter1";

            //Add parameter 2
            Parameter p2 = new Parameter();

            p2.Name  = "Parameter2";
            p2.Type  = "int";
            p2.Value = "2";

            //Add step
            NodeStep step1 = new NodeStep("GivenMethod1");

            step1.Parameters.Add(p1);
            step1.Parameters.Add(p2);
            step1.Rows = new List <string[]> {
                new string[] { "a", "b", "c" }
            };

            //Add scenario
            NodeScenario scenario1 = new NodeScenario("Scenario1");

            scenario1.Steps.Add(step1);

            //Add feature
            NodeFeature feature1 = new NodeFeature("Feature1");

            feature1.Scenarios.Add(scenario1);
            features.Add(feature1);

            var files = GeneratorFactory.Generate(GeneratorType.StepDefinitionGenerator, features);

            string[] stringsExpected = new string[] {
                "#include \"Feature1.h\"",
                "",
                "namespace CppUnitTest",
                "{",
                "\tvoid Feature1::GivenMethod1(std::vector<std::vector<std::string>> table, int rows, int cols, string Parameter1, int Parameter2)",
                "\t{",
                "\t\tAssert::Fail(L\"Pending implementation...\");",
                "\t}",
                "}"
            };
            AssertExt.ContentsOfStringArray(stringsExpected, files[0]);
        }
コード例 #12
0
 private static void VerifyFeature(NodeFeature feature, string changingText)
 {
     Assert.AreEqual(string.Format("Feature{0}", changingText), feature.Name);
     Assert.AreEqual(1, feature.Hooks.Count, string.Format("feature{0} hook count mismatch", changingText));
     Assert.AreEqual(string.Format("f{0}", changingText), feature.Hooks[0].Name);
     Assert.AreEqual(1, feature.Scenarios.Count, string.Format("scenario{0} count mismatch", changingText));
     Assert.AreEqual(string.Format("Scenario{0}", changingText), feature.Scenarios[0].Name);
     Assert.AreEqual(2, feature.Scenarios[0].Hooks.Count, string.Format("scenario{0} hook count mismatch", changingText));
     Assert.AreEqual(string.Format("f{0}", changingText), feature.Scenarios[0].Hooks[0].Name);
     Assert.AreEqual(string.Format("s{0}", changingText), feature.Scenarios[0].Hooks[1].Name);
 }
コード例 #13
0
        public static IList <NodeFeature> FeatureWithScenarioAndNoStep()
        {
            IList <NodeFeature> features            = new List <NodeFeature>();
            NodeFeature         featureWithScenario = new NodeFeature("Feature1");
            NodeScenario        scenario            = new NodeScenario("Scenario1");

            featureWithScenario.Scenarios.Add(scenario);    // scenario to feature
            features.Add(featureWithScenario);              // feature to feature list

            return(features);
        }
コード例 #14
0
        public void HeaderGeneratorCreatesOneFeatureOneFeatureHookOneScenarioHookAndOneStep()
        {
            IList <NodeFeature> features;

            features = new List <NodeFeature>();

            //Creates Step 1
            NodeStep step1 = new NodeStep("GivenMethod1");

            //Creates Scenario 1
            NodeScenario scenario1 = new NodeScenario("TestScenario1", new List <NodeHook>()
            {
                new NodeHook("featurehook1"), new NodeHook("scenariohook1")
            });

            scenario1.Steps.Add(step1);

            //Creates Feature 1
            NodeFeature testFeature = new NodeFeature("TestFeature1", new List <NodeHook>()
            {
                new NodeHook("featurehook1")
            });

            testFeature.Scenarios.Add(scenario1);

            features.Add(testFeature);

            var files = GeneratorFactory.Generate(GeneratorType.HeaderGenerator, features);

            string[] stringsExpected = new string[] {
                "#include \"CppUnitTest.h\"",
                "#include \"CppUnitTestHooks.h\"",
                "#include \"trim.hpp\"",
                "#include <vector>",
                "",
                "using namespace Microsoft::VisualStudio::CppUnitTestFramework;",
                "using namespace std;",
                "",
                "namespace CppUnitTest",
                "{",
                "\tTEST_CLASS(TestFeature1)",
                "\t{",
                "\tpublic:",
                "\t\tTEST_CLASS_HOOK_FEATUREHOOK1()",
                "\t\tTEST_METHOD_HOOK_FEATUREHOOK1_SCENARIOHOOK1(TestScenario1);",
                "",
                "\tprivate:",
                "\t\tvoid GivenMethod1();",
                "\t};",
                "}"
            };

            AssertExt.ContentsOfStringArray(stringsExpected, files[0]);
        }
コード例 #15
0
        protected override string[] BuildContents(NodeFeature feature)
        {
            BuildIncludeStatements();
            BuildUsingStatements();
            OpenNameSpace(LanguageConfig.NameSpace);
            OpenTestClass(feature.Name);
            BuildTestClass(feature);
            CloseTestClass();
            CloseNameSpace();

            return(Contents.ToArray());
        }
コード例 #16
0
        public void HeaderGeneratorCreatesOneFeatureTwoFeatureHooksAndTwoScenarioHooks()
        {
            IList <NodeFeature> features;

            features = new List <NodeFeature>();

            List <NodeHook> featureHooks = new List <NodeHook>()
            {
                new NodeHook("featurehook1"),
                new NodeHook("featurehook2")
            };

            List <NodeHook> scenarioHooks = new List <NodeHook>()
            {
                new NodeHook("featurehook1"),
                new NodeHook("featurehook2"),
                new NodeHook("scenariohook1"),
                new NodeHook("scenariohook2")
            };

            NodeFeature testFeature = new NodeFeature("TestFeature1", featureHooks);

            testFeature.Scenarios.Add(new NodeScenario("TestScenario1", scenarioHooks));

            features.Add(testFeature);

            var files = GeneratorFactory.Generate(GeneratorType.HeaderGenerator, features);

            string[] stringsExpected = new string[] {
                "#include \"CppUnitTest.h\"",
                "#include \"CppUnitTestHooks.h\"",
                "#include \"trim.hpp\"",
                "#include <vector>",
                "",
                "using namespace Microsoft::VisualStudio::CppUnitTestFramework;",
                "using namespace std;",
                "",
                "namespace CppUnitTest",
                "{",
                "\tTEST_CLASS(TestFeature1)",
                "\t{",
                "\tpublic:",
                "\t\tTEST_CLASS_HOOK_FEATUREHOOK1()",
                "\t\tTEST_CLASS_HOOK_FEATUREHOOK2()",
                "\t\tTEST_METHOD_HOOK_FEATUREHOOK1_FEATUREHOOK2_SCENARIOHOOK1_SCENARIOHOOK2(TestScenario1);",
                "\t};",
                "}"
            };

            AssertExt.ContentsOfStringArray(stringsExpected, files[0]);
        }
コード例 #17
0
        private string[] BuildTestClassHeaderFile(NodeFeature feature, string nameSpaceName)
        {
            BuildIncludeStatements();
            BuildUsingStatements();
            OpenNameSpace(nameSpaceName);
            OpenTestClass(feature.Name);

            BuildTestClass(feature);

            CloseTestClass();
            CloseNameSpace();

            return(contents.ToArray());
        }
コード例 #18
0
        public void HeaderGeneratorCreatesOneFeatureWithDuplicateSteps()
        {
            IList <NodeFeature> features = new List <NodeFeature>();

            //Create scenario & add
            NodeScenario scenario1 = new NodeScenario("MyScenario1");

            scenario1.Steps.Add(new NodeStep("GivenAMethod1"));
            scenario1.Steps.Add(new NodeStep("WhenUsingAMethod1"));
            scenario1.Steps.Add(new NodeStep("ThenUsingAMethod1"));
            scenario1.Steps.Add(new NodeStep("GivenAMethod1"));
            scenario1.Steps.Add(new NodeStep("WhenUsingAMethod1"));
            scenario1.Steps.Add(new NodeStep("ThenUsingAMethod1"));

            //Create feature & add
            NodeFeature feature1 = new NodeFeature("MyFeature1");

            feature1.Scenarios.Add(scenario1);
            features.Add(feature1);

            //Call output generator
            var files = GeneratorFactory.Generate(GeneratorType.HeaderGenerator, features);

            string[] stringsExpected = new string[] {
                "#include \"CppUnitTest.h\"",
                "#include \"CppUnitTestHooks.h\"",
                "#include \"trim.hpp\"",
                "#include <vector>",
                "",
                "using namespace Microsoft::VisualStudio::CppUnitTestFramework;",
                "using namespace std;",
                "",
                "namespace CppUnitTest",
                "{",
                "\tTEST_CLASS(MyFeature1)",
                "\t{",
                "\tpublic:",
                "\t\tTEST_METHOD(MyScenario1);",
                "",
                "\tprivate:",
                "\t\tvoid GivenAMethod1();",
                "\t\tvoid WhenUsingAMethod1();",
                "\t\tvoid ThenUsingAMethod1();",
                "\t};",
                "}"
            };
            AssertExt.ContentsOfStringArray(stringsExpected, files[0]);
        }
コード例 #19
0
        public void StepGeneratorCreatesOneScenarioOneStepOneDecimalParameter()
        {
            IList <NodeFeature> features;

            features = new List <NodeFeature>();

            //Add parameter
            Parameter p1 = new Parameter();

            p1.Name  = "Parameter1";
            p1.Type  = "decimal";
            p1.Value = "2.1";

            //Add step
            NodeStep step1 = new NodeStep("GivenMethod1");

            step1.Parameters.Add(p1);

            //Add scenario
            NodeScenario scenario1 = new NodeScenario("Scenario1");

            scenario1.Steps.Add(step1);

            //Add feature
            NodeFeature feature1 = new NodeFeature("Feature1");

            feature1.Scenarios.Add(scenario1);
            features.Add(feature1);

            var files = GeneratorFactory.Generate(GeneratorType.StepDefinitionGenerator, features);

            string[] stringsExpected = new string[] {
                "#include \"Feature1.h\"",
                "",
                "namespace CppUnitTest",
                "{",
                "\tvoid Feature1::GivenMethod1(decimal Parameter1)",
                "\t{",
                "\t\tAssert::Fail(L\"Pending implementation...\");",
                "\t}",
                "}"
            };
            AssertExt.ContentsOfStringArray(stringsExpected, files[0]);
        }
コード例 #20
0
        public static IList <NodeFeature> FeatureWithScenarioOutlineAndStep()
        {
            IList <NodeFeature> features            = new List <NodeFeature>();
            NodeFeature         featureWithScenario = new NodeFeature("Feature1", new List <NodeHook>());
            NodeScenarioOutline scenario            = new NodeScenarioOutline("Scenario1", new List <NodeHook>());

            scenario.Examples.Rows = new List <string[]>()
            {
                new[] { "a", "b", "c" },
                new[] { "1", "2", "3" },
                new[] { "4", "5", "6" }
            };

            scenario.Steps.Add(new NodeStep("GivenIHaveAStep"));
            featureWithScenario.Scenarios.Add(scenario);
            features.Add(featureWithScenario);

            return(features);
        }
コード例 #21
0
        public void StepGeneratorCreatesOneScenarioOneStepOneRow()
        {
            IList <NodeFeature> features;

            features = new List <NodeFeature>();

            //Add step
            NodeStep step1 = new NodeStep("GivenMethod1");

            step1.Rows = new List <string[]>()
            {
                new [] { "a", "b", "c" }
            };

            //Add scenario
            NodeScenario scenario1 = new NodeScenario("Scenario1");

            scenario1.Steps.Add(step1);

            //Add feature
            NodeFeature feature1 = new NodeFeature("Feature1");

            feature1.Scenarios.Add(scenario1);
            features.Add(feature1);

            var files = GeneratorFactory.Generate(GeneratorType.StepDefinitionGenerator, features);

            string[] stringsExpected = new string[] {
                "#include \"Feature1.h\"",
                "",
                "namespace CppUnitTest",
                "{",
                "\tvoid Feature1::GivenMethod1(std::vector<std::vector<std::string>> table, int rows, int cols)",
                "\t{",
                "\t\tAssert::Fail(L\"Pending implementation...\");",
                "\t}",
                "}"
            };
            AssertExt.ContentsOfStringArray(stringsExpected, files[0]);
        }
コード例 #22
0
        public void StepGeneratorCreatesTwoFeaturesWithScenario()
        {
            IList <NodeFeature> features;

            features = new List <NodeFeature>();

            NodeFeature  feature  = new NodeFeature("Feature1");
            NodeScenario scenario = new NodeScenario("Scenario1");

            scenario.Steps.Add(new NodeStep("GivenMethod"));
            feature.Scenarios.Add(scenario);
            features.Add(feature);
            feature  = new NodeFeature("Feature2");
            scenario = new NodeScenario("Scenario2");
            scenario.Steps.Add(new NodeStep("GivenMethod"));
            feature.Scenarios.Add(scenario);
            features.Add(feature);

            var files = GeneratorFactory.Generate(GeneratorType.StepDefinitionGenerator, features);

            Assert.AreEqual(2, files.Count, "File count mismatch.");
            for (int i = 0; i < files.Count; i++)
            {
                string[] stringsExpected = new string[] {
                    string.Format("#include \"Feature{0}.h\"", i + 1),
                    "",
                    "namespace CppUnitTest",
                    "{",
                    string.Format("\tvoid Feature{0}::GivenMethod()", i + 1),
                    "\t{",
                    "\t\tAssert::Fail(L\"Pending implementation...\");",
                    "\t}",
                    "}"
                };
                AssertExt.ContentsOfStringArray(stringsExpected, files[i]);
            }
        }
コード例 #23
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="label">Label string (e.g., "Arg0", "Modifier-Temporal", etc.)</param>
        /// <param name="confidence">Confidence of label</param>
        public PropBankNodeLabel(string label, float confidence)
        {
            _confidence = confidence;

            string[] labelParts = label.Split('-');

            if (labelParts.Length > 2)
            {
                throw new Exception("Unexpected label parts");
            }

            // first part is always type
            _type = (NodeType)Enum.Parse(typeof(NodeType), labelParts[0]);

            // check for second part (the feature)
            if (labelParts.Length == 2)
            {
                _feature = (NodeFeature)Enum.Parse(typeof(NodeFeature), labelParts[1]);
            }
            else
            {
                _feature = NodeFeature.None;
            }
        }
コード例 #24
0
 /// <summary>
 /// Tries to get the feature for a string
 /// </summary>
 /// <param name="feature">Feature name</param>
 /// <param name="nodeFeature">NodeFeature</param>
 /// <returns>True if feature was found, false otherwise</returns>
 public static bool TryGetNodeFeature(string feature, out NodeFeature nodeFeature)
 {
     return(_stringFeatureMap.TryGetValue(feature, out nodeFeature));
 }
コード例 #25
0
        public void HeaderGeneratorCreatesOneFeatureWithOneTable()
        {
            IList <NodeFeature> features;

            features = new List <NodeFeature>();
            List <NodeHook> featureHooks = new List <NodeHook>();

            List <string[]> rows = new List <string[]>();

            //Create row array & add
            string[] row1 = new string[] { "a", "b", "c" };
            string[] row2 = new string[] { "1", "2", "3" };
            rows.Add(row1);
            rows.Add(row2);

            //Create step & add
            NodeStep step1 = new NodeStep("GivenStep1WithTable");

            step1.Rows = rows;

            //Create scenario & add
            NodeScenario scenario1 = new NodeScenario("MyScenario1", new List <NodeHook>()
            {
                new NodeHook("MyFeatureHook1"), new NodeHook("MyScenarioHook1")
            });

            scenario1.Steps.Add(step1);

            //Create feature & add
            NodeFeature feature1 = new NodeFeature("MyFeature1", new List <NodeHook>()
            {
                new NodeHook("MyFeatureHook1")
            });

            feature1.Scenarios.Add(scenario1);
            features.Add(feature1);

            //Call output generator
            var files = GeneratorFactory.Generate(GeneratorType.HeaderGenerator, features);

            string[] stringsExpected = new string[] {
                "#include \"CppUnitTest.h\"",
                "#include \"CppUnitTestHooks.h\"",
                "#include \"trim.hpp\"",
                "#include <vector>",
                "",
                "using namespace Microsoft::VisualStudio::CppUnitTestFramework;",
                "using namespace std;",
                "",
                "namespace CppUnitTest",
                "{",
                "\tTEST_CLASS(MyFeature1)",
                "\t{",
                "\tpublic:",
                "\t\tTEST_CLASS_HOOK_MYFEATUREHOOK1()",
                "\t\tTEST_METHOD_HOOK_MYFEATUREHOOK1_MYSCENARIOHOOK1(MyScenario1);",
                "",
                "\tprivate:",
                "\t\tvoid GivenStep1WithTable(std::vector<std::vector<std::string>> table, int rows, int cols);",
                "\t};",
                "}"
            };
            AssertExt.ContentsOfStringArray(stringsExpected, files[0]);
        }
コード例 #26
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="type">Type of node</param>
 /// <param name="feature">Feature for node</param>
 /// <param name="confidence">Confidence of label</param>
 public NomBankNodeLabel(NodeType type, NodeFeature feature, float confidence)
     : this(type, confidence)
 {
     _feature  = feature;
     _hashCode = (_type.ToString() + "-" + _feature.ToString()).GetHashCode();
 }
コード例 #27
0
        private static void RemoveAutoGeneratedStepsThatDuplicateUserSteps(string file, NodeFeature feature)
        {
            string[]             contents = File.ReadAllLines(file);
            StepDefinitionParser parser   = new StepDefinitionParser();
            List <FeatureGroup>  groups   = parser.Parse(contents);
            var filterGroup = groups.FirstOrDefault(featureGroup => featureGroup.FeatureName == feature.Name);

            if (filterGroup != null)
            {
                foreach (var scenario in feature.Scenarios)
                {
                    foreach (var filterStep in filterGroup.Steps)
                    {
                        scenario.Steps.RemoveAll(step => step.Equals(filterStep));
                    }
                }
            }
        }
コード例 #28
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="type">Type of node</param>
 /// <param name="feature">Feature for node</param>
 /// <param name="confidence">Confidence of label</param>
 public PropBankNodeLabel(NodeType type, NodeFeature feature, float confidence)
     : this(type, confidence)
 {
     _feature = feature;
 }
コード例 #29
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="type">Type of node</param>
 /// <param name="confidence">Confidence of label</param>
 public PropBankNodeLabel(NodeType type, float confidence)
 {
     _type       = type;
     _confidence = confidence;
     _feature    = NodeFeature.None;
 }
コード例 #30
0
        private string[] BuildTestClassHeaderFile(NodeFeature feature, string nameSpaceName)
        {
            BuildIncludeStatements();
            BuildUsingStatements();
            OpenNameSpace(nameSpaceName);
            OpenTestClass(feature.Name);

            BuildTestClass(feature);

            CloseTestClass();
            CloseNameSpace();

            return contents.ToArray();
        }
コード例 #31
0
 /// <summary>
 /// Gets string for a feature
 /// </summary>
 /// <param name="feature">NodeFeature</param>
 /// <returns>String</returns>
 public static string GetNodeFeatureString(NodeFeature feature)
 {
     return(_featureStringMap[feature]);
 }
コード例 #32
0
        private void BuildTestClass(NodeFeature feature)
        {
            List<string> privateContents = new List<string>();
            List<string> publicContents = new List<string>();
            List<NodeStep> uniqueSteps = new List<NodeStep>();

            foreach (var scenario in feature.Scenarios)
            {
                AddScenario(scenario, feature.Hooks, publicContents);
                List<NodeStep> stepsToPrint = new List<NodeStep>();
                foreach (var step in scenario.Steps)
                {
                    if (!uniqueSteps.Any(uniqueStep => uniqueStep.Equals(step)))
                    {
                        uniqueSteps.Add(step);
                        stepsToPrint.Add(step);
                    }
                }

                AddStepsForScenario(stepsToPrint, scenario, feature.Scenarios, privateContents);
            }

            OpenTestClassPublicSection(feature.Hooks);

            contents.AddRange(publicContents);

            if (privateContents.Count > 0)
            {
                contents.AddRange(privateContents);
            }
        }