protected override string GenerateCode(string inputFileContent) { var generatorServices = new VsGeneratorServices(CurrentProject); using (var testGenerator = generatorServices.CreateTestGenerator()) { string projectFolder = VsxHelper.GetProjectFolder(CurrentProject); var fullPath = Path.GetFullPath(Path.Combine(projectFolder, CodeFilePath)); FeatureFileInput featureFileInput = new FeatureFileInput(FileSystemHelper.GetRelativePath(fullPath, projectFolder)) { FeatureFileContent = inputFileContent }; generationResult = testGenerator.GenerateTestFile(featureFileInput, new GenerationSettings()); if (!generationResult.Success) return null; return generationResult.GeneratedTestCode; } }
protected override string GenerateCode(string inputFileContent) { IVisualStudioTracer tracer = VsxHelper.ResolveMefDependency<IVisualStudioTracer>(ServiceProvider.GlobalProvider); var generatorServices = new VsGeneratorServices(CurrentProject, new VsSpecFlowConfigurationReader(CurrentProject, tracer), tracer); using (var testGenerator = generatorServices.CreateTestGenerator()) { string projectFolder = VsxHelper.GetProjectFolder(CurrentProject); var fullPath = Path.GetFullPath(Path.Combine(projectFolder, CodeFilePath)); FeatureFileInput featureFileInput = new FeatureFileInput(FileSystemHelper.GetRelativePath(fullPath, projectFolder)) { FeatureFileContent = inputFileContent }; generationResult = testGenerator.GenerateTestFile(featureFileInput, new GenerationSettings()); if (!generationResult.Success) return null; return generationResult.GeneratedTestCode; } }
private string GenerateError(TestGeneratorResult generationResult, CodeDomHelper codeDomHelper) { var errorsArray = generationResult.Errors.ToArray(); foreach (var testGenerationError in errorsArray) { OnGenerationError(testGenerationError); } return string.Join(Environment.NewLine, errorsArray.Select(e => codeDomHelper.GetErrorStatementString(e.Message)).ToArray()); }