コード例 #1
1
        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),
                                                           });
        }
コード例 #2
0
ファイル: ProjectSteps.cs プロジェクト: nnanoob/SpecFlow-1
 public ProjectSteps(InputProjectDriver inputProjectDriver, ProjectGenerator projectGenerator, ProjectCompiler projectCompiler, HooksDriver hooksDriver)
 {
     this.inputProjectDriver = inputProjectDriver;
     this.projectCompiler    = projectCompiler;
     _hooksDriver            = hooksDriver;
     this.projectGenerator   = projectGenerator;
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 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;
 }
コード例 #5
0
ファイル: ReportingSteps.cs プロジェクト: yazide/SpecFlow
 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;
 }
コード例 #6
0
        public static void BeforeTestRun()
        {
            var directoryForTestProjects = InputProjectDriver.DetermineDirectoryForTestProjects();

            if (Directory.Exists(directoryForTestProjects))
            {
                Directory.Delete(directoryForTestProjects, true);
            }
        }
コード例 #7
0
 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);
 }
コード例 #8
0
        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),
            });
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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");
        }
コード例 #11
0
        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);
            }
        }
コード例 #12
0
        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));
        }
コード例 #13
0
ファイル: ProjectGenerator.cs プロジェクト: tmulkern/SpecFlow
        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;
        }
コード例 #14
0
        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());
        }
コード例 #15
0
 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);
 }
コード例 #16
0
 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);
 }
コード例 #17
0
 public ExternalLibrarySteps(InputProjectDriver inputProjectDriver, ProjectGenerator projectGenerator, ProjectCompiler projectCompiler)
 {
     this.inputProjectDriver = inputProjectDriver;
     this.projectGenerator   = projectGenerator;
     this.projectCompiler    = projectCompiler;
 }
コード例 #18
0
ファイル: GeneratorSteps.cs プロジェクト: nnanoob/SpecFlow-1
 public GeneratorSteps(InputProjectDriver inputProjectDriver, ProjectGenerator projectGenerator, ProjectCompiler projectCompiler)
 {
     this.inputProjectDriver = inputProjectDriver;
     this.projectCompiler    = projectCompiler;
     this.projectGenerator   = projectGenerator;
 }
コード例 #19
0
 public abstract void AdditionalAdjustments(Project project, InputProjectDriver inputProjectDriver);
コード例 #20
0
 public BindingSteps(InputProjectDriver inputProjectDriver, HooksDriver hooksDriver)
 {
     this.inputProjectDriver = inputProjectDriver;
     this.hooksDriver        = hooksDriver;
 }
コード例 #21
0
ファイル: ProjectGenerator.cs プロジェクト: tmulkern/SpecFlow
 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);
 }
コード例 #22
0
ファイル: ProjectGenerator.cs プロジェクト: tmulkern/SpecFlow
 private void AddAppConfig(InputProjectDriver inputProjectDriver, Project project)
 {
     inputProjectDriver.ConfigurationDriver.SaveConfigurationTo(Path.Combine(inputProjectDriver.CompilationFolder, "App.config"));
     project.AddItem("None", "App.config");
 }
コード例 #23
0
 public TestFileSteps(TestFileManager testFileManager, ParserDriver parserDriver, InputProjectDriver inputProjectDriver)
 {
     this.testFileManager    = testFileManager;
     this.inputProjectDriver = inputProjectDriver;
     this.parserDriver       = parserDriver;
 }
コード例 #24
0
 public FeatureFileSteps(InputProjectDriver inputProjectDriver)
 {
     this.inputProjectDriver = inputProjectDriver;
 }
コード例 #25
0
 private void AddAppConfig(InputProjectDriver inputProjectDriver, Project project)
 {
     inputProjectDriver.ConfigurationDriver.SaveConfigurationTo(Path.Combine(inputProjectDriver.CompilationFolder, "App.config"));
     project.AddItem("None", "App.config");
 }
コード例 #26
0
 public override void AdditionalAdjustments(Project project, InputProjectDriver inputProjectDriver)
 {
 }
コード例 #27
0
ファイル: ProjectGenerator.cs プロジェクト: tmulkern/SpecFlow
        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);
        }
コード例 #28
0
 public ContentFileSteps(InputProjectDriver inputProjectDriver)
 {
     this.inputProjectDriver = inputProjectDriver;
 }
コード例 #29
0
 public BindingSteps(InputProjectDriver inputProjectDriver)
 {
     this.inputProjectDriver = inputProjectDriver;
 }
コード例 #30
0
ファイル: ProjectGenerator.cs プロジェクト: tmulkern/SpecFlow
        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();
        }