Пример #1
0
 public TestTracer(ITraceListener traceListener, IStepFormatter stepFormatter, IStepDefinitionSkeletonProvider stepDefinitionSkeletonProvider, RuntimeConfiguration runtimeConfiguration)
 {
     this.traceListener = traceListener;
     this.stepFormatter = stepFormatter;
     this.stepDefinitionSkeletonProvider = stepDefinitionSkeletonProvider;
     this.runtimeConfiguration = runtimeConfiguration;
 }
Пример #2
0
        public TestExecutionEngine(IStepFormatter stepFormatter, ITestTracer testTracer, IErrorProvider errorProvider, IStepArgumentTypeConverter stepArgumentTypeConverter, 
            RuntimeConfiguration runtimeConfiguration, IBindingRegistry bindingRegistry, IUnitTestRuntimeProvider unitTestRuntimeProvider, 
            IDictionary<ProgrammingLanguage, IStepDefinitionSkeletonProvider> stepDefinitionSkeletonProviders, IContextManager contextManager)
        {
            this.errorProvider = errorProvider;
            this.contextManager = contextManager;
            this.stepDefinitionSkeletonProviders = stepDefinitionSkeletonProviders;
            this.unitTestRuntimeProvider = unitTestRuntimeProvider;
            this.bindingRegistry = bindingRegistry;
            this.runtimeConfiguration = runtimeConfiguration;
            this.testTracer = testTracer;
            this.stepFormatter = stepFormatter;
            this.stepArgumentTypeConverter = stepArgumentTypeConverter;

            this.currentStepDefinitionSkeletonProvider = stepDefinitionSkeletonProviders[ProgrammingLanguage.CSharp]; // fallback if feature initialization was not proper
        }
Пример #3
0
 public TestExecutionEngine(IStepFormatter stepFormatter, ITestTracer testTracer, IErrorProvider errorProvider, IStepArgumentTypeConverter stepArgumentTypeConverter, 
     RuntimeConfiguration runtimeConfiguration, IBindingRegistry bindingRegistry, IUnitTestRuntimeProvider unitTestRuntimeProvider, 
     IStepDefinitionSkeletonProvider stepDefinitionSkeletonProvider, IContextManager contextManager, IStepDefinitionMatchService stepDefinitionMatchService,
     IDictionary<string, IStepErrorHandler> stepErrorHandlers, IBindingInvoker bindingInvoker)
 {
     this.errorProvider = errorProvider;
     this.bindingInvoker = bindingInvoker;
     this.contextManager = contextManager;
     this.unitTestRuntimeProvider = unitTestRuntimeProvider;
     this.stepDefinitionSkeletonProvider = stepDefinitionSkeletonProvider;
     this.bindingRegistry = bindingRegistry;
     this.runtimeConfiguration = runtimeConfiguration;
     this.testTracer = testTracer;
     this.stepFormatter = stepFormatter;
     this.stepArgumentTypeConverter = stepArgumentTypeConverter;
     this.stepErrorHandlers = stepErrorHandlers == null ? null : stepErrorHandlers.Values.ToArray();
     this.stepDefinitionMatchService = stepDefinitionMatchService;
 }
Пример #4
0
        public void OnFeatureStart(FeatureInfo featureInfo)
        {
            // if the unit test provider would execute the fixture teardown code 
            // only delayed (at the end of the execution), we automatically close 
            // the current feature if necessary
            if (unitTestRuntimeProvider.DelayedFixtureTearDown &&
                ObjectContainer.FeatureContext != null)
            {
                OnFeatureEnd();
            }

            stepDefinitionSkeletonProvider = ObjectContainer.StepDefinitionSkeletonProvider(featureInfo.GenerationTargetLanguage);

            // The Generator defines the value of FeatureInfo.Language: either feature-language or language from App.config or the default
            // The runtime can define the binding-culture: Value is configured on App.config, else it is null
            CultureInfo bindingCulture = ObjectContainer.Configuration.BindingCulture ?? featureInfo.Language;
            ObjectContainer.FeatureContext = new FeatureContext(featureInfo, bindingCulture);
            FireEvents(BindingEvent.FeatureStart, ObjectContainer.FeatureContext.FeatureInfo.Tags);
        }
Пример #5
0
        public TestExecutionEngine(IStepFormatter stepFormatter, ITestTracer testTracer, IErrorProvider errorProvider, IStepArgumentTypeConverter stepArgumentTypeConverter, 
            RuntimeConfiguration runtimeConfiguration, IBindingRegistry bindingRegistry, IUnitTestRuntimeProvider unitTestRuntimeProvider, 
            IDictionary<ProgrammingLanguage, IStepDefinitionSkeletonProvider> stepDefinitionSkeletonProviders, IContextManager contextManager, IStepDefinitionMatchService stepDefinitionMatchService,
            IDictionary<string, IStepErrorHandler> stepErrorHandlers, IBindingInvoker bindingInvoker, IRuntimeBindingRegistryBuilder bindingRegistryBuilder)
        {
            this.errorProvider = errorProvider;
            //this.stepDefinitionMatcher = stepDefinitionMatcher;
            this.bindingInvoker = bindingInvoker;
            this.bindingRegistryBuilder = bindingRegistryBuilder;
            this.contextManager = contextManager;
            this.stepDefinitionSkeletonProviders = stepDefinitionSkeletonProviders;
            this.unitTestRuntimeProvider = unitTestRuntimeProvider;
            this.bindingRegistry = bindingRegistry;
            this.runtimeConfiguration = runtimeConfiguration;
            this.testTracer = testTracer;
            this.stepFormatter = stepFormatter;
            this.stepArgumentTypeConverter = stepArgumentTypeConverter;
            this.stepErrorHandlers = stepErrorHandlers == null ? null : stepErrorHandlers.Values.ToArray();

            this.currentStepDefinitionSkeletonProvider = stepDefinitionSkeletonProviders[ProgrammingLanguage.CSharp]; // fallback if feature initialization was not proper

            this.stepDefinitionMatchService = stepDefinitionMatchService;
        }
Пример #6
0
        public void OnFeatureStart(FeatureInfo featureInfo)
        {
            // if the unit test provider would execute the fixture teardown code 
            // only delayed (at the end of the execution), we automatically close 
            // the current feature if necessary
            if (unitTestRuntimeProvider.DelayedFixtureTearDown &&
                contextManager.FeatureContext != null)
            {
                OnFeatureEnd();
            }

            if (!stepDefinitionSkeletonProviders.ContainsKey(featureInfo.GenerationTargetLanguage))
                currentStepDefinitionSkeletonProvider = stepDefinitionSkeletonProviders[ProgrammingLanguage.CSharp]; // fallback case for unsupported skeleton provider
            currentStepDefinitionSkeletonProvider = stepDefinitionSkeletonProviders[featureInfo.GenerationTargetLanguage];

            // The Generator defines the value of FeatureInfo.Language: either feature-language or language from App.config or the default
            // The runtime can define the binding-culture: Value is configured on App.config, else it is null
            CultureInfo bindingCulture = runtimeConfiguration.BindingCulture ?? featureInfo.Language;
            contextManager.InitializeFeatureContext(featureInfo, bindingCulture);
            FireEvents(BindingEvent.FeatureStart);
        }
Пример #7
0
 public GoToStepDefinitionCommand(IServiceProvider serviceProvider, DTE dte, IGherkinLanguageServiceFactory gherkinLanguageServiceFactory, IStepDefinitionSkeletonProvider stepDefinitionSkeletonProvider) 
 {
     this.gherkinLanguageServiceFactory = gherkinLanguageServiceFactory;
     this.stepDefinitionSkeletonProvider = stepDefinitionSkeletonProvider;
 }
 public void Init()
 {
     skeletonProviderCS = new StepDefinitionSkeletonProviderCS();
     skeletonProviderVB = new StepDefinitionSkeletonProviderVB();
 }
 public GenerateStepDefinitionSkeletonCommand(IServiceProvider serviceProvider, DTE dte, IGherkinLanguageServiceFactory gherkinLanguageServiceFactory, IStepDefinitionSkeletonProvider stepDefinitionSkeletonProvider, IProjectScopeFactory projectScopeFactory) : base(serviceProvider, dte)
 {
     this.gherkinLanguageServiceFactory = gherkinLanguageServiceFactory;
     this.stepDefinitionSkeletonProvider = stepDefinitionSkeletonProvider;
     this.projectScopeFactory = projectScopeFactory;
 }
Пример #10
0
 /// <summary>
 /// Adds the missing steps to a file already existing through use of the skeletonProvider.
 /// Shows a message if succesful.
 /// </summary>
 private void AddStepsToFile(IStepDefinitionSkeletonProvider skeletonProvider,
     List<StepInstance> missingSteps, string classExtension)
 {
     string dir = Path.GetDirectoryName(_featurePath);
     OpenFileDialog ofd = new OpenFileDialog
     {
         DefaultExt = ".cs",
         Title = "Choose the file your step definitions should be added to.",
         InitialDirectory = dir,
         FileName = _suggestedStepDefName
     };
     DialogResult dialogResult = ofd.ShowDialog();
     if (dialogResult == DialogResult.OK)
     {
         try
         {
             string contents = _handler.GetFileText(ofd.FileName, classExtension);
             string newText = skeletonProvider.AddStepsToExistingFile(contents, missingSteps);
             if (!String.IsNullOrEmpty(newText))
             {
                 _handler.WriteToFile(newText, true, ofd.FileName);
                 MessageBox.Show("Success! Your steps have been added successfully",
                                 MessageBoxHeader);
             }
             else
             {
                 MessageBox.Show("The file you selected does not contain a binding class",
                                 MessageBoxHeader, MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         catch (FileHandlerException fileHandlerException)
         {
             MessageBox.Show(fileHandlerException.Message, MessageBoxHeader,
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Пример #11
0
 /// <summary>
 /// Creates a new file containing the missing steps and adds them to the visual studio
 /// solution. Then displays a message conveying whether it succeeded.
 /// </summary>
 private void WriteStepsToFile(IStepDefinitionSkeletonProvider skeletonProvider, List<StepInstance> missingSteps)
 {
     //Store info on file
     StepDefSkeletonInfo info = new StepDefSkeletonInfo(_suggestedStepDefName,
                                                        _defaultNamespace);
     //Generate the skeleton for the new file
     string skeleton = skeletonProvider.GetFileSkeleton(missingSteps, info);
     string file;
     try
     {
         //Try to write the skeleton to a file
         file = _handler.WriteToFile(skeleton, false, _suggestedStepDefName, _featurePath);
     }
     catch (FileHandlerException fileHandlerException)
     {
         //If the file already existed, ask to overwrite
         var overwrite = MessageBox.Show(fileHandlerException.Message, MessageBoxHeader,
                                         MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
         //If they have selected to overwrite then add again, this time allowing overwrites
         if (overwrite == DialogResult.Yes)
             file = _handler.WriteToFile(skeleton, true, _suggestedStepDefName, _featurePath);
         else
             throw new FileGeneratorException("Cancelled creating step definition file.");
     }
     //Add the file generated to the visual studio solution
     if (!_handler.AddToSolution(_sln, _featurePath, file))
         MessageBox.Show(
             "A step defintion file has been created but it could not be added to an existing visual studio project",
             MessageBoxHeader, MessageBoxButtons.OK, MessageBoxIcon.Warning);
     else
         MessageBox.Show("Success! A step definition file has been generated",
                         MessageBoxHeader);
 }
Пример #12
0
        /// <summary>
        /// Generates the missing steps for the given feature file and determines whether they
        /// should be added to an existing file or put in a new file
        /// </summary>
        private void ProcessMissingSteps(IStepDefinitionSkeletonProvider skeletonProvider, string classExtension)
        {
            var missingSteps = _analyser.GetMissingSteps(); //Get the steps which did not match any bindings
            if (missingSteps.Count <= 0)
            {
                throw new FileGeneratorException("There are no unimplemented steps for this feature.");
            }

            var result = MessageBox.Show("Do you wish to add your step definitions to an existing file?",
                                         MessageBoxHeader, MessageBoxButtons.YesNoCancel,
                                         MessageBoxIcon.Question);
            switch (result)
            {
                case DialogResult.No:
                    {
                        WriteStepsToFile(skeletonProvider, missingSteps);
                        break;
                    }
                case DialogResult.Yes:
                    {
                        AddStepsToFile(skeletonProvider, missingSteps, classExtension);
                        break;
                    }
            }
        }