コード例 #1
0
        public void CodeBehindGeneratorCreatesScenarioWithOneStepAndTable()
        {
            var features = TestCodeBehindData.FeatureWithScenarioAndStep();

            features[0].Scenarios[0].Steps[0].Rows = new List <string[]>()
            {
                new[] { "a", "b", "c" },
                new[] { "1", "2", "3" }
            };

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

            string[] stringsExpected = new string[] {
                string.Format("#include \"{0}.h\"", features[0].Name),
                string.Empty,
                "namespace CppUnitTest",
                "{",
                string.Format("\tvoid {0}::{1}()", features[0].Name, features[0].Scenarios[0].Name),
                "\t{",
                "\t\tstd::vector<std::vector<std::string>> table0 = {{",
                "\t\t\t{ \"a\", \"b\", \"c\" },",
                "\t\t\t{ \"1\", \"2\", \"3\" }",
                "\t\t}};",
                string.Format("\t\t{0}(table0,{1},{2});",
                              features[0].Scenarios[0].Steps[0].Name,
                              features[0].Scenarios[0].Steps[0].Rows.Count,
                              features[0].Scenarios[0].Steps[0].Rows[0].Length),
                "\t}",
                "}"
            };

            AssertExt.ContentsOfStringArray(stringsExpected, files[0]);
        }
コード例 #2
0
        public void CodeBehindGeneratorCreatesScenarioWithOneStep()
        {
            var features = TestCodeBehindData.FeatureWithScenarioAndStep();
            var files    = GeneratorFactory.Generate(GeneratorType.CodeBehindGenerator, features);

            string parameterName = string.Empty;

            string[] stringsExpected = new string[] {
                string.Format("#include \"{0}.h\"", features[0].Name),
                string.Empty,
                "namespace CppUnitTest",
                "{",
                string.Format("\tvoid {0}::{1}()", features[0].Name, features[0].Scenarios[0].Name),
                "\t{",
                string.Format("\t\t{0}({1});", features[0].Scenarios[0].Steps[0].Name, parameterName),
                "\t}",
                "}"
            };

            AssertExt.ContentsOfStringArray(stringsExpected, files[0]);
        }