Exemplo n.º 1
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;
 }
Exemplo n.º 2
0
        public string GetFeatureText(Feature feature, CultureInfo defaultLanguage = null)
        {
            defaultLanguage = defaultLanguage ?? new CultureInfo("en-US");
            var dialectServices = new GherkinDialectServices(defaultLanguage);
            var dialect = dialectServices.GetGherkinDialect(feature);

            var result = new StringBuilder();

            AppendHeader(defaultLanguage, dialect, result);

            AppendTags(result, feature.Tags);
            AppendFeatureLine(feature, result);
            AppendLine(result);

            if (feature.Background != null)
            {
                AppendBackgroundLine(feature.Background, result);
                AppendSteps(feature.Background.Steps, result);
                AppendLine(result);
            }

            foreach (var scenario in feature.Scenarios)
            {
                var outline = scenario as ScenarioOutline;
                bool isOutline = outline != null;

                AppendTags(result, scenario.Tags);
                AppendScenarioLine(result, scenario, dialect, isOutline);

                AppendSteps(scenario.Steps, result);

                AppendLine(result);

                if (isOutline)
                {
                    foreach (var exampleSet in outline.Examples.ExampleSets)
                    {
                        AppendTags(result, exampleSet.Tags);
                        AppendExampleSetLine(result, dialect, exampleSet);
                        AppendTable(result, exampleSet.Table, indent);
                        AppendLine(result);
                    }
                }

                AppendLine(result);
            }

            return result.ToString();
        }
Exemplo n.º 3
0
        private void AppConfigTrackerOnFileChanged(ProjectItem appConfigItem)
        {
            var newConfig = DteProjectReader.LoadSpecFlowConfigurationFromDteProject(project) ?? new SpecFlowProjectConfiguration();
            if (newConfig.Equals(SpecFlowProjectConfiguration)) 
                return;

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

            SpecFlowProjectConfiguration = newConfig;
            this.visualStudioTracer.Trace("SpecFlow configuration changed", "VsProjectScope");
            if (SpecFlowProjectConfigurationChanged != null)
                SpecFlowProjectConfigurationChanged(this, EventArgs.Empty);

            if (dialectServicesChanged)
            {
                GherkinDialectServices = new GherkinDialectServices(SpecFlowProjectConfiguration.GeneratorConfiguration.FeatureLanguage);
                this.visualStudioTracer.Trace("default language changed", "VsProjectScope");
                if (GherkinDialectServicesChanged != null)
                    GherkinDialectServicesChanged(this, EventArgs.Empty);
            }
        }
 public SpecFlowLangParser(CultureInfo defaultLanguage)
 {
     this.dialectServices = new GherkinDialectServices(defaultLanguage);
 }
Exemplo n.º 5
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();
            }
        }
Exemplo n.º 6
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");
            }
        }
Exemplo n.º 7
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();
            }
        }
Exemplo n.º 8
0
 public SpecFlowLangParser(CultureInfo defaultLanguage)
 {
     this.dialectServices = new GherkinDialectServices(defaultLanguage);
 }
Exemplo n.º 9
0
 public RegularExpressionScanner(CultureInfo defaultLanguage)
 {
     var dialectServices = new GherkinDialectServices(defaultLanguage);
     GherkinDialect gherkinDialect = dialectServices.GetDefaultDialect();
     patternTable = gherkinDialect.GetKeywords().ToList().ConvertAll(x => new Regex(Regex.Escape(x))).ToArray();
 }