static private void WriteFileStepDefinition(List <NodeFeature> features, string outputDirectory) { for (int i = 0; i < features.Count; i++) { string file = outputDirectory + features[i].Name + "_stepDefinitions.cpp"; Console.WriteLine(string.Format("STEP DEFINITIONS CPP: {0}", file)); UnitTestLanguageConfig langConfig = GetLanguageConfig(); if (File.Exists(file)) { Console.WriteLine("File exists and may contain user-generated code"); RemoveAutoGeneratedStepsThatDuplicateUserSteps(file, features[i]); if (features[i].Scenarios.Sum(s => s.Steps.Count) > 0) { Console.WriteLine("Appending new steps"); langConfig.UseInclude = false; var listOfContents = new StepDefinitionGenerator().Generate(langConfig, new List <NodeFeature>() { features[i] }); if (listOfContents.Count > 0) { File.AppendAllLines(file, listOfContents[0]); if (!_singleFile) { AddFilesToCppProject(file, FEATURE_DIR, CPP_PROJ); } } } else { Console.WriteLine("No new steps to append"); } } else { var listOfContents = new StepDefinitionGenerator().Generate(langConfig, new List <NodeFeature>() { features[i] }); if (listOfContents.Count > 0) { File.WriteAllLines(file, listOfContents[0]); if (!_singleFile) { AddFilesToCppProject(file, FEATURE_DIR, CPP_PROJ); } } } } }
private static void WriteFileStepDefinition(List<NodeFeature> features, string outputDirectory) { for (int i = 0; i < features.Count; i++) { string file = outputDirectory + features[i].Name + "_stepDefinitions.cpp"; Console.WriteLine(string.Format("STEP DEFINITIONS CPP: {0}", file)); UnitTestLanguageConfig langConfig = GetLanguageConfig(); if (File.Exists(file)) { Console.WriteLine("File exists and may contain user-generated code"); RemoveAutoGeneratedStepsThatDuplicateUserSteps(file, features[i]); if (features[i].Scenarios.Sum(s => s.Steps.Count) > 0) { Console.WriteLine("Appending new steps"); langConfig.UseInclude = false; var listOfContents = new StepDefinitionGenerator().Generate(langConfig, new List<NodeFeature>() { features[i] }); if (listOfContents.Count > 0) { File.AppendAllLines(file, listOfContents[0]); if (!_singleFile) { AddFilesToCppProject(file, FEATURE_DIR, CPP_PROJ); } } } else { Console.WriteLine("No new steps to append"); } } else { var listOfContents = new StepDefinitionGenerator().Generate(langConfig, new List<NodeFeature>() { features[i] }); if (listOfContents.Count > 0) { File.WriteAllLines(file, listOfContents[0]); if (!_singleFile) { AddFilesToCppProject(file, FEATURE_DIR, CPP_PROJ); } } } } }