public static SpecFlowProjectConfiguration LoadConfiguration(this IGeneratorConfigurationProvider configurationProvider, SpecFlowConfigurationHolder configurationHolder)
        {
            SpecFlowProjectConfiguration configuration = new SpecFlowProjectConfiguration();

            configurationProvider.LoadConfiguration(configurationHolder, configuration);
            return(configuration);
        }
Example #2
0
 public NoProjectScope(GherkinFileEditorClassifications classifications, IVisualStudioTracer visualStudioTracer)
 {
     GherkinTextBufferParser = new GherkinTextBufferParser(this, visualStudioTracer);
     GherkinProcessingScheduler = new GherkinProcessingScheduler(visualStudioTracer);
     SpecFlowProjectConfiguration = new SpecFlowProjectConfiguration();
     GherkinDialectServices = new GherkinDialectServices(SpecFlowProjectConfiguration.GeneratorConfiguration.FeatureLanguage); 
     Classifications = classifications;
 }
        /// <summary>
        /// The register customizations.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="generatorConfiguration">The generator configuration.</param>
        public void RegisterCustomizations(ObjectContainer container, SpecFlowProjectConfiguration generatorConfiguration)
        {
            container.RegisterTypeAs<SpecBindConfigurationProvider, ISpecBindConfigurationProvider>();

            var unitTestGenProvider = generatorConfiguration.GeneratorConfiguration.GeneratorUnitTestProvider;
            if (string.Equals(unitTestGenProvider, "mstest", StringComparison.OrdinalIgnoreCase) ||
                string.Equals(unitTestGenProvider, "mstest.2010", StringComparison.OrdinalIgnoreCase))
            {
                container.RegisterTypeAs<SpecBindTestGeneratorProvider, IUnitTestGeneratorProvider>();
            }
        }
Example #4
0
 private static SpecFlowProjectConfiguration LoadSpecFlowConfigurationFromDteProjectInternal(Project project)
 {
     SpecFlowProjectConfiguration configuration = new SpecFlowProjectConfiguration();
     ProjectItem projectItem = VsxHelper.FindProjectItemByProjectRelativePath(project, "app.config");
     if (projectItem != null)
     {
         string configFileContent = VsxHelper.GetFileContent(projectItem);
         GeneratorConfigurationReader.UpdateConfigFromFileContent(configuration.GeneratorConfiguration, configFileContent);
         RuntimeConfigurationReader.UpdateConfigFromFileContent(configuration.RuntimeConfiguration, configFileContent);
     }
     return configuration;
 }
Example #5
0
 public bool Equals(SpecFlowProjectConfiguration other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.GeneratorConfiguration, GeneratorConfiguration) && Equals(other.RuntimeConfiguration, RuntimeConfiguration));
 }
        public virtual SpecFlowProjectConfiguration LoadConfiguration(SpecFlowConfigurationHolder configurationHolder, IProjectReference projectReference)
        {
            SpecFlowProjectConfiguration configuration = new SpecFlowProjectConfiguration();

            if (configurationHolder != null && configurationHolder.HasConfiguration)
            {
                ConfigurationSectionHandler specFlowConfigSection = ConfigurationSectionHandler.CreateFromXml(configurationHolder.XmlString);
                if (specFlowConfigSection != null)
                {
                    configuration.GeneratorConfiguration.UpdateFromConfigFile(specFlowConfigSection);
                    configuration.RuntimeConfiguration.UpdateFromConfigFile(specFlowConfigSection);
                }
            }
            configuration.GeneratorConfiguration.GeneratorVersion = GetGeneratorVersion(projectReference);
            return configuration;
        }
        public virtual SpecFlowProjectConfiguration LoadConfiguration(SpecFlowConfigurationHolder configurationHolder, IProjectReference projectReference)
        {
            SpecFlowProjectConfiguration configuration = new SpecFlowProjectConfiguration();

            if (configurationHolder != null && configurationHolder.HasConfiguration)
            {
                ConfigurationSectionHandler specFlowConfigSection = ConfigurationSectionHandler.CreateFromXml(configurationHolder.XmlString);
                if (specFlowConfigSection != null)
                {
                    configuration.GeneratorConfiguration.UpdateFromConfigFile(specFlowConfigSection);
                    configuration.RuntimeConfiguration.UpdateFromConfigFile(specFlowConfigSection);
                }
            }
            configuration.GeneratorConfiguration.GeneratorVersion = GetGeneratorVersion(projectReference);
            return(configuration);
        }
 public virtual void LoadConfiguration(SpecFlowConfigurationHolder configurationHolder, SpecFlowProjectConfiguration configuration)
 {
     try
     {
         if (configurationHolder != null && configurationHolder.HasConfiguration)
         {
             ConfigurationSectionHandler specFlowConfigSection =
                 ConfigurationSectionHandler.CreateFromXml(configurationHolder.XmlString);
             if (specFlowConfigSection != null)
             {
                 UpdateGeneratorConfiguration(configuration, specFlowConfigSection);
                 UpdateRuntimeConfiguration(configuration, specFlowConfigSection);
             }
         }
     }
     catch(Exception ex)
     {
         throw new ConfigurationErrorsException("SpecFlow configuration error", ex);
     }
 }
        public static IObjectContainer CreateContainer(SpecFlowConfigurationHolder configurationHolder, ProjectSettings projectSettings)
        {
            var container = new ObjectContainer();
            container.RegisterInstanceAs(projectSettings);

            RegisterDefaults(container);

            var configurationProvider = container.Resolve<IGeneratorConfigurationProvider>();

            var plugins = LoadPlugins(container, configurationProvider, configurationHolder);
            foreach (var plugin in plugins)
                plugin.RegisterDependencies(container);

            var specFlowConfiguration = new SpecFlowProjectConfiguration();

            foreach (var plugin in plugins)
                plugin.RegisterConfigurationDefaults(specFlowConfiguration);

            configurationProvider.LoadConfiguration(configurationHolder, specFlowConfiguration);

            if (specFlowConfiguration.GeneratorConfiguration.CustomDependencies != null)
                container.RegisterFromConfiguration(specFlowConfiguration.GeneratorConfiguration.CustomDependencies);

            container.RegisterInstanceAs(specFlowConfiguration);
            container.RegisterInstanceAs(specFlowConfiguration.GeneratorConfiguration);
            container.RegisterInstanceAs(specFlowConfiguration.RuntimeConfiguration);

            var generatorInfo = container.Resolve<IGeneratorInfoProvider>().GetGeneratorInfo();
            container.RegisterInstanceAs(generatorInfo);

            container.RegisterInstanceAs(container.Resolve<CodeDomHelper>(projectSettings.ProjectPlatformSettings.Language));

            if (specFlowConfiguration.GeneratorConfiguration.GeneratorUnitTestProvider != null)
                container.RegisterInstanceAs(container.Resolve<IUnitTestGeneratorProvider>(specFlowConfiguration.GeneratorConfiguration.GeneratorUnitTestProvider));

            foreach (var plugin in plugins)
                plugin.RegisterCustomizations(container, specFlowConfiguration);

            return container;
        }
        public virtual SpecFlowProjectConfiguration LoadConfiguration(SpecFlowConfigurationHolder configurationHolder)
        {
            try
            {
                SpecFlowProjectConfiguration configuration = new SpecFlowProjectConfiguration();

                if (configurationHolder != null && configurationHolder.HasConfiguration)
                {
                    ConfigurationSectionHandler specFlowConfigSection =
                        ConfigurationSectionHandler.CreateFromXml(configurationHolder.XmlString);
                    if (specFlowConfigSection != null)
                    {
                        UpdateGeneratorConfiguration(configuration, specFlowConfigSection);
                        UpdateRuntimeConfiguration(configuration, specFlowConfigSection);
                    }
                }
                return(configuration);
            }
            catch (Exception ex)
            {
                throw new ConfigurationErrorsException("SpecFlow configuration error", ex);
            }
        }
 public void RegisterConfigurationDefaults(SpecFlowProjectConfiguration specFlowConfiguration)
 {
 }
Example #12
0
        private void Initialize()
        {
            specFlowProjectConfiguration = LoadConfiguration();
            gherkinDialectServices = new GherkinDialectServices(specFlowProjectConfiguration.GeneratorConfiguration.FeatureLanguage);

            appConfigTracker = new VsProjectFileTracker(project, "App.config", dteWithEvents, visualStudioTracer);
            appConfigTracker.FileChanged += AppConfigTrackerOnFileChanged;
            appConfigTracker.FileOutOfScope += AppConfigTrackerOnFileOutOfScope;

            var enableAnalysis = integrationOptionsProvider.GetOptions().EnableAnalysis;
            if (enableAnalysis)
            {
                featureFilesTracker = new ProjectFeatureFilesTracker(this);
                featureFilesTracker.Ready += FeatureFilesTrackerOnReady;

                bindingFilesTracker = new BindingFilesTracker(this);

                stepSuggestionProvider = new VsStepSuggestionProvider(this);
                bindingMatchService = new BindingMatchService(stepSuggestionProvider);
            }
            initialized = true;

            if (enableAnalysis)
            {
                stepSuggestionProvider.Initialize();
                bindingFilesTracker.Initialize();
                featureFilesTracker.Initialize();
                bindingFilesTracker.Run();
                featureFilesTracker.Run();
            }
        }
 internal override void UpdateGeneratorConfiguration(SpecFlowProjectConfiguration configuration, ConfigurationSectionHandler specFlowConfigSection)
 {
     configuration.GeneratorConfiguration.UpdateFromConfigFile(specFlowConfigSection, false);
 }
 internal virtual void UpdateConfiguration(SpecFlowProjectConfiguration configuration, ConfigurationSectionHandler specFlowConfigSection)
 {
     configuration.SpecFlowConfiguration = _configurationLoader.Update(configuration.SpecFlowConfiguration, specFlowConfigSection);
 }
 /// <summary>
 /// Registers the customizations.
 /// </summary>
 /// <param name="container">The container.</param>
 /// <param name="generatorConfiguration">The generator configuration.</param>
 public void RegisterCustomizations(ObjectContainer container, SpecFlowProjectConfiguration generatorConfiguration)
 {
 }
Example #16
0
 public void RegisterCustomizations(BoDi.ObjectContainer container, SpecFlowProjectConfiguration generatorConfiguration)
 {
     container.RegisterTypeAs<AttributeGenerator, ITestMethodTagDecorator>("mka.AttributeGenerator");
 }
Example #17
0
 internal virtual void UpdateGeneratorConfiguration(SpecFlowProjectConfiguration configuration, ConfigurationSectionHandler specFlowConfigSection)
 {
     configuration.GeneratorConfiguration.UpdateFromConfigFile(specFlowConfigSection);
 }
 public void RaiseCustomizeDependencies(ObjectContainer container, SpecFlowProjectConfiguration specFlowProjectConfiguration)
 {
     CustomizeDependencies?.Invoke(this, new CustomizeDependenciesEventArgs(container, specFlowProjectConfiguration));
 }
Example #19
0
        private void Initialize()
        {
            tracer.Trace("Initializing...", "VsProjectScope");
            try
            {
                specFlowProjectConfiguration = LoadConfiguration();
                gherkinDialectServices = new GherkinDialectServices(specFlowProjectConfiguration.GeneratorConfiguration.FeatureLanguage);

                appConfigTracker = new VsProjectFileTracker(project, "App.config", dteWithEvents, tracer);
                appConfigTracker.FileChanged += AppConfigTrackerOnFileChanged;
                appConfigTracker.FileOutOfScope += AppConfigTrackerOnFileOutOfScope;

                var enableAnalysis = integrationOptionsProvider.GetOptions().EnableAnalysis;
                if (enableAnalysis)
                {
                    featureFilesTracker = new ProjectFeatureFilesTracker(this);
                    featureFilesTracker.Ready += FeatureFilesTrackerOnReady;

                    bindingFilesTracker = new BindingFilesTracker(this);

                    stepSuggestionProvider = new VsStepSuggestionProvider(this);
                    stepSuggestionProvider.Ready += StepSuggestionProviderOnReady;
                    stepDefinitionMatchService = new StepDefinitionMatchServiceWithOnlySimpleTypeConverter(stepSuggestionProvider);
                }
                tracer.Trace("Initialized", "VsProjectScope");
                initialized = true;

                if (enableAnalysis)
                {
                    tracer.Trace("Starting analysis services...", "VsProjectScope");

                    stepSuggestionProvider.Initialize();
                    bindingFilesTracker.Initialize();
                    featureFilesTracker.Initialize();

                    LoadStepMap();

                    bindingFilesTracker.Run();
                    featureFilesTracker.Run();

                    dteWithEvents.OnBuildDone += BuildEventsOnOnBuildDone;

                    tracer.Trace("Analysis services started", "VsProjectScope");
                }
                else
                {
                    tracer.Trace("Analysis services disabled", "VsProjectScope");
                }
            }
            catch(Exception exception)
            {
                tracer.Trace("Exception: " + exception, "VsProjectScope");
            }
        }
 internal virtual void UpdateRuntimeConfiguration(SpecFlowProjectConfiguration configuration, ConfigurationSectionHandler specFlowConfigSection)
 {
     configuration.RuntimeConfiguration.UpdateFromConfigFile(specFlowConfigSection);
 }
 public void RegisterCustomizations(ObjectContainer container, SpecFlowProjectConfiguration generatorConfiguration)
 {
     container.RegisterTypeAs<NullUnitTestGeneratorProvider, IUnitTestGeneratorProvider>();
     container.RegisterTypeAs<MsTest2010RuntimeProvider, IUnitTestRuntimeProvider>();
 }
 public CustomizeDependenciesEventArgs(ObjectContainer objectContainer, SpecFlowProjectConfiguration specFlowProjectConfiguration)
     : base(objectContainer)
 {
     this.SpecFlowProjectConfiguration = specFlowProjectConfiguration;
 }
 public static SpecFlowProjectConfiguration LoadConfiguration(this IGeneratorConfigurationProvider configurationProvider, SpecFlowConfigurationHolder configurationHolder)
 {
     SpecFlowProjectConfiguration configuration = new SpecFlowProjectConfiguration();
     configurationProvider.LoadConfiguration(configurationHolder, configuration);
     return configuration;
 }
 public void RegisterCustomizations(ObjectContainer container, SpecFlowProjectConfiguration generatorConfiguration)
 {
     container.RegisterTypeAs<XunitRetryTestGeneratorProvider, IUnitTestGeneratorProvider>();
 }
 public ConfigurationDefaultsEventArgs(SpecFlowProjectConfiguration specFlowProjectConfiguration)
 {
     this.SpecFlowProjectConfiguration = specFlowProjectConfiguration;
 }
Example #26
0
 internal virtual void UpdateRuntimeConfiguration(SpecFlowProjectConfiguration configuration, ConfigurationSectionHandler specFlowConfigSection)
 {
     configuration.RuntimeConfiguration.LoadConfiguration(specFlowConfigSection);
 }
Example #27
0
 public SpecFlowProject()
 {
     ProjectSettings = new ProjectSettings();
     FeatureFiles = new List<FeatureFileInput>();
     Configuration = new SpecFlowProjectConfiguration();
 }
 public bool Equals(SpecFlowProjectConfiguration other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.GeneratorConfiguration, GeneratorConfiguration) && Equals(other.RuntimeConfiguration, RuntimeConfiguration);
 }
 protected bool Equals(SpecFlowProjectConfiguration other)
 {
     return(Equals(SpecFlowConfiguration, other.SpecFlowConfiguration));
 }
Example #30
0
        private void AppConfigTrackerOnFileChanged(ProjectItem appConfigItem)
        {
            var newConfig = LoadConfiguration();
            if (newConfig.Equals(SpecFlowProjectConfiguration)) 
                return;

            bool dialectServicesChanged = !newConfig.GeneratorConfiguration.FeatureLanguage.Equals(GherkinDialectServices.DefaultLanguage);

            specFlowProjectConfiguration = newConfig;
            OnSpecFlowProjectConfigurationChanged();

            if (dialectServicesChanged)
            {
                gherkinDialectServices = new GherkinDialectServices(SpecFlowProjectConfiguration.GeneratorConfiguration.FeatureLanguage);
                OnGherkinDialectServicesChanged();
            }
        }
 public void RaiseConfigurationDefaults(SpecFlowProjectConfiguration specFlowProjectConfiguration)
 {
     ConfigurationDefaults?.Invoke(this, new ConfigurationDefaultsEventArgs(specFlowProjectConfiguration));
 }
 internal virtual void UpdateGeneratorConfiguration(SpecFlowProjectConfiguration configuration, ConfigurationSectionHandler specFlowConfigSection)
 {
     configuration.GeneratorConfiguration.UpdateFromConfigFile(specFlowConfigSection, true);
 }
Example #33
0
 public SpecFlowProject()
 {
     FeatureFiles  = new List <SpecFlowFeatureFile>();
     Configuration = new SpecFlowProjectConfiguration();
 }