Exemple #1
0
        public void GenerateCode(FileProjectItem item, CustomToolContext context)
        {
            context.RunAsync(
                () => {
                string fileName = item.FileName;
                var projectNode = item.Project;
                SpecFlowProject specFlowProject = CreateSpecFlowProjectFrom(projectNode);
                var specFlowGenerator           = new SpecFlowGenerator(specFlowProject);

                string outputFile = context.GetOutputFileName(item, ".feature");

                var specFlowFeatureFile = specFlowProject.GetOrCreateFeatureFile(fileName);

                var fileContents = File.ReadAllText(fileName);
                string outputFileContents;
                using (var reader = new StringReader(fileContents)) {
                    using (var writer = new StringWriter(new StringBuilder())) {
                        specFlowGenerator.GenerateTestFile(specFlowFeatureFile, projectNode.LanguageProperties.CodeDomProvider, reader, writer);
                        outputFileContents = writer.ToString();
                    }
                }
                File.WriteAllText(outputFile, outputFileContents);

                WorkbenchSingleton.SafeThreadCall(
                    () => context.EnsureOutputFileIsInProject(item, outputFile));
            });
        }
Exemple #2
0
        public void GenerateCode(FileProjectItem item, CustomToolContext context)
        {
            context.RunAsync(() =>
            {
                var ideSingleFileGenerator = new IdeSingleFileGenerator();

                string outputFilePath = context.GetOutputFileName(item, ".feature");
                ideSingleFileGenerator.GenerateFile(item.FileName, outputFilePath, () => new SharpDevelop4GeneratorServices(item.Project));

                WorkbenchSingleton.SafeThreadCall(
                    () => context.EnsureOutputFileIsInProject(item, outputFilePath));
            });
        }