public SpecFlowProject LoadSpecFlowProjectFromMsBuild(string projectFilePath, string rootNamespace) { var configurationProvider = new GeneratorConfigurationProvider(new ConfigurationLoader()); var projectReader = new ProjectReader(configurationProvider, new ProjectLanguageReader()); return(projectReader.ReadSpecFlowProject(projectFilePath, rootNamespace)); }
private SpecFlowGeneratorConfiguration GenSpecFlowGeneratorConfig() { try { var specflowGeneratorConfig = new SpecFlowGeneratorConfiguration(); var configurationHolder = _configurationReader.ReadConfiguration(); switch (configurationHolder.ConfigSource) { case ConfigSource.AppConfig: var appConfigFormat = configurationHolder.TransformConfigurationToOldHolder(); var oldGeneratorConfig = new GeneratorConfigurationProvider().LoadConfiguration(appConfigFormat).GeneratorConfiguration; specflowGeneratorConfig.GeneratorPath = oldGeneratorConfig.GeneratorPath; specflowGeneratorConfig.UsesPlugins = oldGeneratorConfig.UsesPlugins; break; case ConfigSource.Json: var defaultSpecFlowConfiguration = ConfigurationLoader.GetDefault(); var specflowLoader = new ConfigurationLoader(); var jsonConfig = specflowLoader.Load(defaultSpecFlowConfiguration, configurationHolder); specflowGeneratorConfig.GeneratorPath = jsonConfig.GeneratorPath; specflowGeneratorConfig.UsesPlugins = jsonConfig.UsesPlugins; break; } return(specflowGeneratorConfig); } catch (Exception exception) { _tracer.Trace("Config load error: " + exception, "VsGeneratorInfoProvider"); return(new SpecFlowGeneratorConfiguration()); } }
/// <summary> /// Create and return instantiation of a parser represented by RegularExpressionScanner object. /// </summary> /// <param name="buffer">An <see cref="IVsTextLines"/> represents lines of source to parse.</param> /// <returns>Returns a RegularExpressionScanner object</returns> public override IScanner GetScanner(IVsTextLines buffer) { var configurationReader = new Vs2008SpecFlowConfigurationReader(CurrentProject, NullIdeTracer.Instance); var configurationHolder = configurationReader.ReadConfiguration(); var config = new GeneratorConfigurationProvider().LoadConfiguration(configurationHolder) ?? new SpecFlowProjectConfiguration(); scanner = new RegularExpressionScanner(config.GeneratorConfiguration.FeatureLanguage); return(scanner); }
private SpecFlowProjectConfiguration LoadConfiguration() { ISpecFlowConfigurationReader configurationReader = new VsSpecFlowConfigurationReader(project, tracer); //TODO: load through DI IGeneratorConfigurationProvider configurationLoader = new GeneratorConfigurationProvider(); //TODO: load through DI try { return(configurationLoader.LoadConfiguration(configurationReader.ReadConfiguration())); } catch (Exception exception) { tracer.Trace("Configuration loading error: " + exception, "VsProjectScope"); return(new SpecFlowProjectConfiguration()); } }
private GeneratorConfiguration GenGeneratorConfig() { try { //TODO: have a "project context" where the actual confic can be read without re-loading/parsing it. var configurationHolder = configurationReader.ReadConfiguration(); var config = new GeneratorConfigurationProvider().LoadConfiguration(configurationHolder); if (config == null) { return(new GeneratorConfiguration()); } return(config.GeneratorConfiguration); } catch (Exception exception) { tracer.Trace("Config load error: " + exception, "VsGeneratorInfoProvider"); return(new GeneratorConfiguration()); } }
private void Should_parse_csproj_file_correctly(string csprojPath, string language, string assemblyName, string rootNamespace, string projectName) { string directoryName = Path.GetDirectoryName(new Uri(GetType().Assembly.CodeBase).LocalPath); string projectFilePath = Path.Combine(directoryName, csprojPath); var specFlowJsonLocatorMock = new Mock <ISpecFlowJsonLocator>(); var configurationLoader = new ConfigurationLoader(specFlowJsonLocatorMock.Object); var generatorConfigurationProvider = new GeneratorConfigurationProvider(configurationLoader); var projectLanguageReader = new ProjectLanguageReader(); var reader = new ProjectReader(generatorConfigurationProvider, projectLanguageReader); var specFlowProjectFile = reader.ReadSpecFlowProject(projectFilePath, rootNamespace); specFlowProjectFile.ProjectSettings.DefaultNamespace.Should().Be(rootNamespace); specFlowProjectFile.ProjectSettings.ProjectName.Should().Be(projectName); specFlowProjectFile.ProjectSettings.ProjectPlatformSettings.Language.Should().Be(language); specFlowProjectFile.Configuration.SpecFlowConfiguration.AllowDebugGeneratedFiles.Should().BeFalse(); specFlowProjectFile.Configuration.SpecFlowConfiguration.AllowRowTests.Should().BeTrue(); specFlowProjectFile.Configuration.SpecFlowConfiguration.FeatureLanguage.Name.Should().Be("en-US"); }