private void AddReference(InputProjectDriver inputProjectDriver, Project project, string reference) { string referenceFullPath = Path.GetFullPath(Path.Combine(AssemblyFolderHelper.GetTestAssemblyFolder(), reference)); string assemblyName = Path.GetFileNameWithoutExtension(referenceFullPath); Debug.Assert(assemblyName != null); project.AddItem("Reference", assemblyName, new[] { new KeyValuePair<string, string>("HintPath", referenceFullPath), }); }
public ProjectSteps(InputProjectDriver inputProjectDriver, ProjectGenerator projectGenerator, ProjectCompiler projectCompiler, HooksDriver hooksDriver) { this.inputProjectDriver = inputProjectDriver; this.projectCompiler = projectCompiler; _hooksDriver = hooksDriver; this.projectGenerator = projectGenerator; }
private void AddBindingClass(InputProjectDriver inputProjectDriver, Project project, BindingClassInput bindingClassInput) { if (bindingClassInput.RawClass != null && bindingClassInput.RawClass.Contains("[assembly:")) { string outputPath = Path.Combine(inputProjectDriver.CompilationFolder, bindingClassInput.ProjectRelativePath); File.WriteAllText(outputPath, bindingClassInput.RawClass, Encoding.UTF8); } else if (bindingClassInput.RawClass != null) { SaveFileFromTemplate(inputProjectDriver.CompilationFolder, "BindingClass." + inputProjectDriver.CodeFileExtension, bindingClassInput.FileName, new Dictionary <string, string> { { "AdditionalUsings", "" }, { "BindingClass", bindingClassInput.RawClass }, }); } else { SaveFileFromTemplate(inputProjectDriver.CompilationFolder, "Bindings." + inputProjectDriver.CodeFileExtension, bindingClassInput.FileName, new Dictionary <string, string> { { "ClassName", bindingClassInput.Name }, { "Bindings", GetBindingsCode(bindingClassInput) }, }); } project.AddItem("Compile", bindingClassInput.ProjectRelativePath); }
public ReportingSteps(InputProjectDriver inputProjectDriver, ProjectSteps projectSteps, AppConfigConfigurationDriver _appConfigConfigurationDriver, ExecutionSteps executionSteps, ReportInfo reportInfo) { this.inputProjectDriver = inputProjectDriver; this.reportInfo = reportInfo; this.executionSteps = executionSteps; this.projectSteps = projectSteps; this._appConfigConfigurationDriver = _appConfigConfigurationDriver; }
public ReportingSteps(InputProjectDriver inputProjectDriver, ProjectSteps projectSteps, SpecFlowConfigurationDriver specFlowConfigurationDriver, ExecutionSteps executionSteps, ReportInfo reportInfo) { this.inputProjectDriver = inputProjectDriver; this.reportInfo = reportInfo; this.executionSteps = executionSteps; this.projectSteps = projectSteps; this.specFlowConfigurationDriver = specFlowConfigurationDriver; }
public static void BeforeTestRun() { var directoryForTestProjects = InputProjectDriver.DetermineDirectoryForTestProjects(); if (Directory.Exists(directoryForTestProjects)) { Directory.Delete(directoryForTestProjects, true); } }
public void AddBindingClass(InputProjectDriver inputProjectDriver, Project project, BindingClassInput bindingClassInput) { ProjectCompilerHelper.SaveFileFromResourceTemplate(inputProjectDriver.ProjectFolder, BindingClassFileName, bindingClassInput.FileName, new Dictionary <string, string> { { "ClassName", bindingClassInput.Name }, { "Bindings", GetBindingsCode(bindingClassInput) }, }); project.AddItem("Compile", bindingClassInput.ProjectRelativePath); }
private void AddReference(InputProjectDriver inputProjectDriver, Project project, string reference) { string referenceFullPath = Path.GetFullPath(Path.Combine(AssemblyFolderHelper.GetTestAssemblyFolder(), reference)); string assemblyName = Path.GetFileNameWithoutExtension(referenceFullPath); Debug.Assert(assemblyName != null); project.AddItem("Reference", assemblyName, new[] { new KeyValuePair <string, string>("HintPath", referenceFullPath), }); }
public Project GenerateProject(InputProjectDriver inputProjectDriver) { string projectFileName = string.Format("{0}_{1}.{2}", inputProjectDriver.ProjectName, Guid.NewGuid().ToString("N"), GetProjectFileExtension(inputProjectDriver.Language)); Console.WriteLine("Compiling project '{0}' in '{1}'", projectFileName, inputProjectDriver.CompilationFolder); EnsureCompilationFolder(inputProjectDriver.CompilationFolder); Project project = CreateProject(inputProjectDriver, projectFileName); AddAppConfig(inputProjectDriver, project); foreach (var bindingClassInput in inputProjectDriver.BindingClasses) { AddBindingClass(inputProjectDriver, project, bindingClassInput); } foreach (var featureFileInput in inputProjectDriver.FeatureFiles) { string outputPath = Path.Combine(inputProjectDriver.CompilationFolder, featureFileInput.ProjectRelativePath); File.WriteAllText(outputPath, featureFileInput.Content, Encoding.UTF8); var generatedFile = featureFileInput.ProjectRelativePath + "." + inputProjectDriver.CodeFileExtension; project.AddItem("None", featureFileInput.ProjectRelativePath, new[] { new KeyValuePair <string, string>("Generator", "SpecFlowSingleFileGenerator"), new KeyValuePair <string, string>("LastGenOutput", generatedFile), }); project.AddItem("Compile", generatedFile); } foreach (var contentFileInput in inputProjectDriver.ContentFiles) { string outputPath = Path.Combine(inputProjectDriver.CompilationFolder, contentFileInput.ProjectRelativePath); Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); File.WriteAllText(outputPath, contentFileInput.Content, Encoding.UTF8); project.AddItem("Content", contentFileInput.ProjectRelativePath, new[] { new KeyValuePair <string, string>("CopyToOutputDirectory", "PreserveNewest"), }); } AddReference(inputProjectDriver, project, "Newtonsoft.Json.dll"); foreach (var reference in inputProjectDriver.References.Concat(inputProjectDriver.AppConfigConfigurationDriver.GetAdditionalReferences())) { AddReference(inputProjectDriver, project, reference); } project.Save(); return(project); }
public override void AdditionalAdjustments(Project project, InputProjectDriver inputProjectDriver) { var myProjectFolder = Path.Combine(inputProjectDriver.ProjectFolder, "My Project"); Directory.CreateDirectory(myProjectFolder); ProjectCompilerHelper.SaveFileFromResourceTemplate(inputProjectDriver.ProjectFolder, @"My_Project.Application.Designer.vb", @"My Project\Application.Designer.vb"); ProjectCompilerHelper.SaveFileFromResourceTemplate(inputProjectDriver.ProjectFolder, @"My_Project.Application.myapp", @"My Project\Application.myapp"); ProjectCompilerHelper.SaveFileFromResourceTemplate(inputProjectDriver.ProjectFolder, @"My_Project.AssemblyInfo.vb", @"My Project\AssemblyInfo.vb"); ProjectCompilerHelper.SaveFileFromResourceTemplate(inputProjectDriver.ProjectFolder, @"My_Project.Resources.Designer.vb", @"My Project\Resources.Designer.vb"); ProjectCompilerHelper.SaveFileFromResourceTemplate(inputProjectDriver.ProjectFolder, @"My_Project.Resources.resx.content", @"My Project\Resources.resx"); ProjectCompilerHelper.SaveFileFromResourceTemplate(inputProjectDriver.ProjectFolder, @"My_Project.Settings.Designer.vb", @"My Project\Settings.Designer.vb"); ProjectCompilerHelper.SaveFileFromResourceTemplate(inputProjectDriver.ProjectFolder, @"My_Project.Settings.settings", @"My Project\Settings.settings"); }
private void AddAppConfig(InputProjectDriver inputProjectDriver, Project project) { inputProjectDriver.AppConfigConfigurationDriver.SaveConfigurationTo(Path.Combine(inputProjectDriver.CompilationFolder, "App.config")); project.AddItem("None", "App.config"); if (inputProjectDriver.SpecFlowJsonConfigurationDriver.IsUsed) { inputProjectDriver.SpecFlowJsonConfigurationDriver.Save(Path.Combine(inputProjectDriver.CompilationFolder, "specflow.json")); IEnumerable <KeyValuePair <string, string> > metadata = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("Link", "specflow.json"), new KeyValuePair <string, string>("CopyToOutputDirectory", "Always") }; var projectItems = project.AddItem("None", "specflow.json", metadata); } }
private Project CreateProject(InputProjectDriver inputProjectDriver, string outputFileName) { // the MsBuild global collection caches the project file, so we need to generate a unique project file name. Guid projectId = Guid.NewGuid(); string projectFileName = SaveFileFromTemplate(inputProjectDriver.CompilationFolder, "TestProjectFile." + GetProjectFileExtension(inputProjectDriver.Language), outputFileName, new Dictionary <string, string> { { "ProjectGuid", projectId.ToString("B") }, { "ProjectName", inputProjectDriver.ProjectName }, }); inputProjectDriver.ProjectFilePath = projectFileName; ProjectCollection.GlobalProjectCollection.UnloadAllProjects(); return(new Project(projectFileName)); }
public Project GenerateProject(InputProjectDriver inputProjectDriver) { string projectFileName = string.Format("{0}_{1}.{2}", inputProjectDriver.ProjectName, Guid.NewGuid().ToString("N"), GetProjectFileExtension(inputProjectDriver.Language)); Console.WriteLine("Compiling project '{0}' in '{1}'", projectFileName, inputProjectDriver.CompilationFolder); EnsureCompilationFolder(inputProjectDriver.CompilationFolder); Project project = CreateProject(inputProjectDriver, projectFileName); AddAppConfig(inputProjectDriver, project); foreach (var bindingClassInput in inputProjectDriver.BindingClasses) AddBindingClass(inputProjectDriver, project, bindingClassInput); foreach (var featureFileInput in inputProjectDriver.FeatureFiles) { string outputPath = Path.Combine(inputProjectDriver.CompilationFolder, featureFileInput.ProjectRelativePath); File.WriteAllText(outputPath, featureFileInput.Content, Encoding.UTF8); var generatedFile = featureFileInput.ProjectRelativePath + "." + inputProjectDriver.CodeFileExtension; project.AddItem("None", featureFileInput.ProjectRelativePath, new[] { new KeyValuePair<string, string>("Generator", "SpecFlowSingleFileGenerator"), new KeyValuePair<string, string>("LastGenOutput", generatedFile), }); project.AddItem("Compile", generatedFile); } foreach (var contentFileInput in inputProjectDriver.ContentFiles) { string outputPath = Path.Combine(inputProjectDriver.CompilationFolder, contentFileInput.ProjectRelativePath); File.WriteAllText(outputPath, contentFileInput.Content, Encoding.UTF8); project.AddItem("Content", contentFileInput.ProjectRelativePath, new[] { new KeyValuePair<string, string>("CopyToOutputDirectory", "PreserveNewest"), }); } foreach (var reference in inputProjectDriver.References.Concat(inputProjectDriver.ConfigurationDriver.GetAdditionalReferences())) AddReference(inputProjectDriver, project, reference); project.Save(); return project; }
private string GetBindingsCode(BindingClassInput bindingClassInput, InputProjectDriver inputProjectDriver) { StringBuilder result = new StringBuilder(); int counter = 0; foreach (var stepBindingInput in bindingClassInput.StepBindings) { switch (inputProjectDriver.Language.ToLower()) { case "c#": result.AppendFormat(@"[{2}(@""{3}"")]public void sb{0}({4} {5}) {{ {1} }}", ++counter, stepBindingInput.Code, stepBindingInput.ScenarioBlock, stepBindingInput.Regex, stepBindingInput.ParameterType, stepBindingInput.ParameterName); break; case "vb.net": if (String.IsNullOrEmpty(stepBindingInput.ParameterType)) { result.AppendFormat(@"<[{2}](""{3}"")> Public Sub sb{0}() {1} End Sub", ++counter, stepBindingInput.Code, stepBindingInput.ScenarioBlock, stepBindingInput.Regex); } else { result.AppendFormat(@"<[{2}](""{3}"")> Public Sub sb{0}({4} as {5}) {1} End Sub", ++counter, stepBindingInput.Code, stepBindingInput.ScenarioBlock, stepBindingInput.Regex, stepBindingInput.ParameterName, stepBindingInput.ParameterType); } break; } result.AppendLine(); } foreach (var otherBinding in bindingClassInput.OtherBindings) { result.AppendLine(otherBinding); } return(result.ToString()); }
private void AddBindingClass(InputProjectDriver inputProjectDriver, Project project, BindingClassInput bindingClassInput) { if (bindingClassInput.RawClass != null) { SaveFileFromTemplate(inputProjectDriver.CompilationFolder, "BindingClass.cs", bindingClassInput.FileName, new Dictionary<string, string> { { "AdditionalUsings", "" }, { "BindingClass", bindingClassInput.RawClass }, }); } else { SaveFileFromTemplate(inputProjectDriver.CompilationFolder, "Bindings.cs", bindingClassInput.FileName, new Dictionary<string, string> { { "ClassName", bindingClassInput.Name }, { "Bindings", GetBindingsCode(bindingClassInput) }, }); } project.AddItem("Compile", bindingClassInput.ProjectRelativePath); }
private void AddBindingClass(InputProjectDriver inputProjectDriver, Project project, BindingClassInput bindingClassInput) { if (bindingClassInput.RawClass != null) { SaveFileFromTemplate(inputProjectDriver.CompilationFolder, "BindingClass.cs", bindingClassInput.FileName, new Dictionary <string, string> { { "AdditionalUsings", "" }, { "BindingClass", bindingClassInput.RawClass }, }); } else { SaveFileFromTemplate(inputProjectDriver.CompilationFolder, "Bindings.cs", bindingClassInput.FileName, new Dictionary <string, string> { { "ClassName", bindingClassInput.Name }, { "Bindings", GetBindingsCode(bindingClassInput) }, }); } project.AddItem("Compile", bindingClassInput.ProjectRelativePath); }
public ExternalLibrarySteps(InputProjectDriver inputProjectDriver, ProjectGenerator projectGenerator, ProjectCompiler projectCompiler) { this.inputProjectDriver = inputProjectDriver; this.projectGenerator = projectGenerator; this.projectCompiler = projectCompiler; }
public GeneratorSteps(InputProjectDriver inputProjectDriver, ProjectGenerator projectGenerator, ProjectCompiler projectCompiler) { this.inputProjectDriver = inputProjectDriver; this.projectCompiler = projectCompiler; this.projectGenerator = projectGenerator; }
public abstract void AdditionalAdjustments(Project project, InputProjectDriver inputProjectDriver);
public BindingSteps(InputProjectDriver inputProjectDriver, HooksDriver hooksDriver) { this.inputProjectDriver = inputProjectDriver; this.hooksDriver = hooksDriver; }
private void AddBindingClass(InputProjectDriver inputProjectDriver, Project project, BindingClassInput bindingClassInput) { if (bindingClassInput.RawClass != null && bindingClassInput.RawClass.Contains("[assembly:")) { string outputPath = Path.Combine(inputProjectDriver.CompilationFolder, bindingClassInput.ProjectRelativePath); File.WriteAllText(outputPath, bindingClassInput.RawClass, Encoding.UTF8); } else if (bindingClassInput.RawClass != null) { SaveFileFromTemplate(inputProjectDriver.CompilationFolder, "BindingClass." + inputProjectDriver.CodeFileExtension, bindingClassInput.FileName, new Dictionary<string, string> { { "AdditionalUsings", "" }, { "BindingClass", bindingClassInput.RawClass }, }); } else { SaveFileFromTemplate(inputProjectDriver.CompilationFolder, "Bindings." + inputProjectDriver.CodeFileExtension, bindingClassInput.FileName, new Dictionary<string, string> { { "ClassName", bindingClassInput.Name }, { "Bindings", GetBindingsCode(bindingClassInput, inputProjectDriver) }, }); } project.AddItem("Compile", bindingClassInput.ProjectRelativePath); }
private void AddAppConfig(InputProjectDriver inputProjectDriver, Project project) { inputProjectDriver.ConfigurationDriver.SaveConfigurationTo(Path.Combine(inputProjectDriver.CompilationFolder, "App.config")); project.AddItem("None", "App.config"); }
public TestFileSteps(TestFileManager testFileManager, ParserDriver parserDriver, InputProjectDriver inputProjectDriver) { this.testFileManager = testFileManager; this.inputProjectDriver = inputProjectDriver; this.parserDriver = parserDriver; }
public FeatureFileSteps(InputProjectDriver inputProjectDriver) { this.inputProjectDriver = inputProjectDriver; }
public override void AdditionalAdjustments(Project project, InputProjectDriver inputProjectDriver) { }
private Project CreateProject(InputProjectDriver inputProjectDriver, string outputFileName) { // the MsBuild global collection caches the project file, so we need to generate a unique project file name. Guid projectId = Guid.NewGuid(); string projectFileName = SaveFileFromTemplate(inputProjectDriver.CompilationFolder, "TestProjectFile." + GetProjectFileExtension(inputProjectDriver.Language), outputFileName, new Dictionary<string, string> { { "ProjectGuid", projectId.ToString("B") }, { "ProjectName", inputProjectDriver.ProjectName }, }); inputProjectDriver.ProjectFilePath = projectFileName; ProjectCollection.GlobalProjectCollection.UnloadAllProjects(); return new Project(projectFileName); }
public ContentFileSteps(InputProjectDriver inputProjectDriver) { this.inputProjectDriver = inputProjectDriver; }
public BindingSteps(InputProjectDriver inputProjectDriver) { this.inputProjectDriver = inputProjectDriver; }
private string GetBindingsCode(BindingClassInput bindingClassInput, InputProjectDriver inputProjectDriver) { StringBuilder result = new StringBuilder(); int counter = 0; foreach (var stepBindingInput in bindingClassInput.StepBindings) { switch (inputProjectDriver.Language.ToLower()) { case "c#": result.AppendFormat(@"[{2}(@""{3}"")]public void sb{0}({4} {5}) {{ {1} }}", ++counter, stepBindingInput.Code, stepBindingInput.ScenarioBlock, stepBindingInput.Regex, stepBindingInput.ParameterType, stepBindingInput.ParameterName); break; case "vb.net": if (String.IsNullOrEmpty(stepBindingInput.ParameterType)) { result.AppendFormat(@"<[{2}](""{3}"")> Public Sub sb{0}() {1} End Sub", ++counter, stepBindingInput.Code, stepBindingInput.ScenarioBlock, stepBindingInput.Regex); } else { result.AppendFormat(@"<[{2}](""{3}"")> Public Sub sb{0}({4} as {5}) {1} End Sub", ++counter, stepBindingInput.Code, stepBindingInput.ScenarioBlock, stepBindingInput.Regex, stepBindingInput.ParameterName, stepBindingInput.ParameterType); } break; } result.AppendLine(); } foreach (var otherBinding in bindingClassInput.OtherBindings) { result.AppendLine(otherBinding); } return result.ToString(); }