Beispiel #1
0
        public void TestInit()
        {
            KnownUIContextsAccessor.Reset();
            this.serviceProvider = new ConfigurableServiceProvider();

            this.teamExplorerController = new ConfigurableTeamExplorerController();
            this.infoBarManager         = new ConfigurableInfoBarManager();

            IComponentModel componentModel = ConfigurableComponentModel.CreateWithExports(
                new Export[]
            {
                MefTestHelpers.CreateExport <ITeamExplorerController>(this.teamExplorerController),
                MefTestHelpers.CreateExport <IInfoBarManager>(this.infoBarManager),
            });

            this.serviceProvider.RegisterService(typeof(SComponentModel), componentModel);

            this.solutionBindingInformationProvider = new ConfigurableSolutionBindingInformationProvider();

            var outputWindow = new ConfigurableVsOutputWindow();

            this.outputWindowPane = outputWindow.GetOrCreateSonarLintPane();
            this.serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow);

            this.configProvider = new ConfigurableConfigurationProvider();
            this.serviceProvider.RegisterService(typeof(IConfigurationProvider), this.configProvider);

            this.host         = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher);
            this.stateManager = (ConfigurableStateManager)this.host.VisualStateManager;
        }
        public void TestInitialize()
        {
            this.serviceProvider = new ConfigurableServiceProvider(false);
            this.host            = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher);
            var mefExport1 = MefTestHelpers.CreateExport <IHost>(this.host);

            this.activeSolutionTracker = new ConfigurableActiveSolutionTracker();
            var mefExport2 = MefTestHelpers.CreateExport <IActiveSolutionTracker>(this.activeSolutionTracker);

            var mefModel = ConfigurableComponentModel.CreateWithExports(mefExport1, mefExport2);

            this.serviceProvider.RegisterService(typeof(SComponentModel), mefModel, replaceExisting: true);

            this.solutionMock = new SolutionMock();
            this.serviceProvider.RegisterService(typeof(SVsSolution), this.solutionMock);

            this.errorListController = new ConfigurableErrorListInfoBarController();
            this.serviceProvider.RegisterService(typeof(IErrorListInfoBarController), this.errorListController);

            this.solutionBindingInformationProvider = new ConfigurableSolutionBindingInformationProvider();
            this.serviceProvider.RegisterService(typeof(ISolutionBindingInformationProvider), this.solutionBindingInformationProvider);

            this.solutionBindingSerializer = new ConfigurableSolutionBindingSerializer();
            this.serviceProvider.RegisterService(typeof(ISolutionBindingSerializer), solutionBindingSerializer);

            this.sonarLintOutputMock = new Mock <ISonarLintOutput>();
        }
        /// <summary>
        /// Creates and returns a new IComponentModel instance that supports calls
        /// to DefaultCompositionService.SatisyImportsOnce.
        /// </summary>
        /// <param name="catalog">An existing catalog to use</param>
        public static IComponentModel Create(ComposablePartCatalog catalog)
        {
            ConfigurableComponentModel model = new ConfigurableComponentModel(catalog);

            model.DefaultCompositionService = new ConfigurableCompositionService(model.container)
            {
            };
            return(model);
        }
        /// <summary>
        /// Creates and returns a new IComponentModel instance that supports calls
        /// to DefaultCompositionService.SatisyImportsOnce.
        /// The supplied composable parts will be used in the composition.
        /// </summary>
        /// <param name="doNothingOnSatisfyImportsOnce">When set to true, SatisfyImportsOnce will do nothing.</param>
        public static IComponentModel Create(bool doNothingOnSatisfyImportsOnce)
        {
            ConfigurableComponentModel model = new ConfigurableComponentModel();

            model.DefaultCompositionService = new ConfigurableCompositionService(model.container)
            {
                DoNothingOnSatisfyImportsOnce = doNothingOnSatisfyImportsOnce
            };
            return(model);
        }
        /// <summary>
        /// Creates and returns a new IComponentModel instance that supports composition.
        /// The model will have the exports pre configured
        public static IComponentModel CreateWithExports(params Export[] exports)
        {
            ConfigurableComponentModel     model = new ConfigurableComponentModel();
            ConfigurableCompositionService svc   = new ConfigurableCompositionService(model.container);

            svc.ExportsToCompose.AddRange(exports);
            svc.SatisfyImportsOnce((ComposablePart)null);
            model.DefaultCompositionService = svc;
            return(model);
        }
Beispiel #6
0
        public void TestInitialize()
        {
            this.monitorSelection = KnownUIContextsAccessor.MonitorSelectionService;

            this.serviceProvider = new ConfigurableServiceProvider();
            this.serviceProvider.RegisterService(typeof(DTE), this.dte = new DTEMock());
            this.serviceProvider.RegisterService(typeof(SComponentModel),
                                                 ConfigurableComponentModel.CreateWithExports(MefTestHelpers.CreateExport <ITelemetryLogger>(this.logger = new ConfigurableTelemetryLogger())));

            this.solutionRootFolder = Path.Combine(this.TestContext.TestRunDirectory, this.TestContext.TestName);
            this.dte.Solution       = new SolutionMock(dte, Path.Combine(this.solutionRootFolder, "solution.sln"));
        }
        /// <summary>
        /// Creates and returns a new IComponentModel instance that supports calls
        /// to DefaultCompositionService.SatisyImportsOnce.
        /// The supplied composable parts will be used in the composition.
        /// </summary>
        public static IComponentModel Create(params object[] composableParts)
        {
            ConfigurableComponentModel     model = new ConfigurableComponentModel();
            ConfigurableCompositionService svc   = new ConfigurableCompositionService(model.container);

            if (composableParts != null)
            {
                svc.PartsToCompose.AddRange(composableParts);
            }
            model.DefaultCompositionService = svc;
            return(model);
        }
        public void TelemetryLoggerAccessor_GetLogger()
        {
            // Arrange
            var loggerInstance = new ConfigurableTelemetryLogger();
            var componentModel = ConfigurableComponentModel.CreateWithExports(
                MefTestHelpers.CreateExport <ITelemetryLogger>(loggerInstance));

            // Act
            ITelemetryLogger logger = TelemetryLoggerAccessor.GetLogger(componentModel);

            // Assert
            logger.Should().Be(loggerInstance, "Failed to find the MEF service: {0}", nameof(ITelemetryLogger));
        }
        public void TestInitialize()
        {
            this.serviceProvider = new ConfigurableServiceProvider();

            var outputWindow = new ConfigurableVsOutputWindow();

            this.outputWindowPane = outputWindow.GetOrCreateSonarLintPane();
            this.serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow);

            this.serviceProvider.RegisterService(typeof(SComponentModel),
                                                 ConfigurableComponentModel.CreateWithExports(
                                                     MefTestHelpers.CreateExport <ITelemetryLogger>(new ConfigurableTelemetryLogger())));
        }
        private ConfigurablePackageInstaller PrepareInstallPackagesTest(NuGetBindingOperation testSubject, Dictionary <Language, IEnumerable <PackageName> > nugetPackagesByLanguage)
        {
            foreach (var nugetPackagesForLanguage in nugetPackagesByLanguage)
            {
                testSubject.NuGetPackages.Add(nugetPackagesForLanguage.Key,
                                              nugetPackagesForLanguage.Value.Select(x => new NuGetPackageInfo(x.Id, x.Version.ToNormalizedString())).ToList());
            }


            ConfigurablePackageInstaller packageInstaller = new ConfigurablePackageInstaller(nugetPackagesByLanguage.Values.SelectMany(x => x));

            this.serviceProvider.RegisterService(typeof(SComponentModel),
                                                 ConfigurableComponentModel.CreateWithExports(MefTestHelpers.CreateExport <IVsPackageInstaller>(packageInstaller)));

            return(packageInstaller);
        }
        public void TelemetryLoggerAccessor_GetLogger()
        {
            // Setup
            ConfigurableServiceProvider sp = new ConfigurableServiceProvider();
            var loggerInstance             = new ConfigurableTelemetryLogger();
            var componentModel             = ConfigurableComponentModel.CreateWithExports(
                MefTestHelpers.CreateExport <ITelemetryLogger>(loggerInstance));

            sp.RegisterService(typeof(SComponentModel), componentModel);

            // Act
            ITelemetryLogger logger = TelemetryLoggerAccessor.GetLogger(sp);

            // Verify
            Assert.AreSame(loggerInstance, logger, "Failed to find the MEF service: {0}", nameof(ITelemetryLogger));
        }
        public void TestInitialize()
        {
            // Create a non-MEF service
            this.serviceInstance = new TestService();

            // Create a MEF service
            this.mefServiceInstance = new TestMefService();
            var mefExports = MefTestHelpers.CreateExport <IMefService>(this.mefServiceInstance);
            var mefModel   = ConfigurableComponentModel.CreateWithExports(mefExports);

            // Register services
            var sp = new ConfigurableServiceProvider(false);

            sp.RegisterService(typeof(IService), this.serviceInstance);
            sp.RegisterService(typeof(SComponentModel), mefModel, replaceExisting: true);

            this.serviceProvider = sp;
        }
        private ConfigurablePackageInstaller PrepareInstallPackagesTest(BindingWorkflow testSubject, Dictionary <Language, IEnumerable <PackageName> > nugetPackagesByLanguage, params Project[] projects)
        {
            testSubject.BindingProjects.Clear();
            testSubject.BindingProjects.AddRange(projects);

            foreach (var nugetPackagesForLanguage in nugetPackagesByLanguage)
            {
                testSubject.NuGetPackages.Add(nugetPackagesForLanguage.Key,
                                              nugetPackagesForLanguage.Value.Select(x => new NuGetPackageInfoResponse {
                    Id = x.Id, Version = x.Version.ToNormalizedString()
                }).ToList());
            }

            ConfigurablePackageInstaller packageInstaller = new ConfigurablePackageInstaller(nugetPackagesByLanguage.Values.SelectMany(x => x));

            this.serviceProvider.RegisterService(typeof(SComponentModel),
                                                 ConfigurableComponentModel.CreateWithExports(MefTestHelpers.CreateExport <IVsPackageInstaller>(packageInstaller)));

            return(packageInstaller);
        }
Beispiel #14
0
        public void TestInitialize()
        {
            this.serviceProvider = new ConfigurableServiceProvider();

            this.menuService = new ConfigurableMenuCommandService();
            this.serviceProvider.RegisterService(typeof(IMenuCommandService), this.menuService);

            var projectSystem = new ConfigurableVsProjectSystemHelper(this.serviceProvider);

            this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), projectSystem);

            var host = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher);

            var propManager       = new ProjectPropertyManager(host);
            var propManagerExport = MefTestHelpers.CreateExport <IProjectPropertyManager>(propManager);

            var teController = new ConfigurableTeamExplorerController();
            var teExport     = MefTestHelpers.CreateExport <ITeamExplorerController>(teController);

            var mefModel = ConfigurableComponentModel.CreateWithExports(teExport, propManagerExport);

            this.serviceProvider.RegisterService(typeof(SComponentModel), mefModel);
        }
        public void TestInitialize()
        {
            this.serviceProvider = new ConfigurableServiceProvider();

            this.dte          = new DTEMock();
            this.dte.Solution = new SolutionMock(dte, Path.Combine(this.TestContext.TestRunDirectory, this.TestContext.TestName, "solution.sln"));
            this.serviceProvider.RegisterService(typeof(DTE), this.dte);

            var outputWindow = new ConfigurableVsOutputWindow();

            this.outputPane = outputWindow.GetOrCreateSonarLintPane();
            this.serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow);

            this.store = new ConfigurableCredentialStore();
            this.serviceProvider.RegisterService(typeof(ICredentialStoreService), this.store);

            this.projectSystemHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider)
            {
                SolutionItemsProject = this.dte.Solution.AddOrGetProject("Solution Items")
            };
            this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), this.projectSystemHelper);

            this.sourceControlledFileSystem = new ConfigurableSourceControlledFileSystem();
            this.serviceProvider.RegisterService(typeof(ISourceControlledFileSystem), this.sourceControlledFileSystem);

            this.solutionRuleSetsInfoProvider = new ConfigurableSolutionRuleSetsInformationProvider
            {
                SolutionRootFolder = Path.GetDirectoryName(this.dte.Solution.FilePath)
            };
            this.serviceProvider.RegisterService(typeof(ISolutionRuleSetsInformationProvider), this.solutionRuleSetsInfoProvider);

            var mefExport = MefTestHelpers.CreateExport <ILogger>(new SonarLintOutputLogger(serviceProvider));
            var mefModel  = ConfigurableComponentModel.CreateWithExports(mefExport);

            this.serviceProvider.RegisterService(typeof(SComponentModel), mefModel);
        }
        public void TestInit()
        {
            this.serviceProvider = new ConfigurableServiceProvider();

            var outputWindow = new ConfigurableVsOutputWindow();

            this.outputWindowPane = outputWindow.GetOrCreateSonarLintPane();
            this.serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow);

            this.host = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher);

            this.ruleSetInspector = null;
            this.sccFS            = null;
            this.rsSerializer     = null;
            this.conflictsManager = new ConfigurableConflictsManager();

            IComponentModel componentModel = ConfigurableComponentModel.CreateWithExports(
                new Export[]
            {
                MefTestHelpers.CreateExport <ITelemetryLogger>(new ConfigurableTelemetryLogger())
            });

            this.serviceProvider.RegisterService(typeof(SComponentModel), componentModel);
        }