public void TestInitialize() { KnownUIContextsAccessor.Reset(); this.sonarQubeService = new Mock <ISonarQubeService>(); this.workflow = new TestBindingWorkflow(); this.serviceProvider = new ConfigurableServiceProvider(); this.dteMock = new DTEMock(); this.serviceProvider.RegisterService(typeof(DTE), this.dteMock); this.solutionMock = new SolutionMock(); this.monitorSelection = KnownUIContextsAccessor.MonitorSelectionService; this.projectSystemHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider); this.conflictsController = new ConfigurableRuleSetConflictsController(); this.configProvider = new ConfigurableConfigurationProvider(); this.ruleSetsInformationProvider = new ConfigurableSolutionRuleSetsInformationProvider(); this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), this.projectSystemHelper); this.serviceProvider.RegisterService(typeof(IRuleSetConflictsController), this.conflictsController); this.serviceProvider.RegisterService(typeof(IConfigurationProviderService), this.configProvider); this.serviceProvider.RegisterService(typeof(ISolutionRuleSetsInformationProvider), this.ruleSetsInformationProvider); this.serviceProvider.RegisterService(typeof(ISourceControlledFileSystem), new ConfigurableSourceControlledFileSystem(new MockFileSystem())); var outputWindow = new ConfigurableVsOutputWindow(); this.outputWindowPane = outputWindow.GetOrCreateSonarLintPane(); this.serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow); this.host = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher) { SonarQubeService = sonarQubeService.Object }; configProvider.FolderPathToReturn = "c:\\test"; }
public void TestInitialize() { KnownUIContextsAccessor.Reset(); this.sonarQubeService = new Mock <ISonarQubeService>(); this.workflow = new TestBindingWorkflow(); this.serviceProvider = new ConfigurableServiceProvider(); this.dteMock = new DTEMock(); this.serviceProvider.RegisterService(typeof(DTE), this.dteMock); this.solutionMock = new SolutionMock(); this.monitorSelection = KnownUIContextsAccessor.MonitorSelectionService; this.projectSystemHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider); this.conflictsController = new ConfigurableRuleSetConflictsController(); this.configProvider = new ConfigurableConfigurationProvider(); this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), this.projectSystemHelper); this.serviceProvider.RegisterService(typeof(IRuleSetConflictsController), this.conflictsController); this.serviceProvider.RegisterService(typeof(IConfigurationProvider), this.configProvider); var outputWindow = new ConfigurableVsOutputWindow(); this.outputWindowPane = outputWindow.GetOrCreateSonarLintPane(); this.serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow); this.host = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher); this.host.SonarQubeService = sonarQubeService.Object; IComponentModel componentModel = ConfigurableComponentModel.CreateWithExports( new [] { MefTestHelpers.CreateExport <ITelemetryLogger>(new ConfigurableTelemetryLogger()) }); this.serviceProvider.RegisterService(typeof(SComponentModel), componentModel); }
public void TestInitialize() { KnownUIContextsAccessor.Reset(); this.sonarQubeService = new Mock <ISonarQubeService>(); this.workflow = new TestBindingWorkflow(); this.serviceProvider = new ConfigurableServiceProvider(); this.dteMock = new DTEMock(); this.serviceProvider.RegisterService(typeof(DTE), this.dteMock); this.solutionMock = new SolutionMock(); this.monitorSelection = KnownUIContextsAccessor.MonitorSelectionService; this.projectSystemHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider); this.conflictsController = new ConfigurableRuleSetConflictsController(); this.configProvider = new ConfigurableConfigurationProvider(); this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), this.projectSystemHelper); this.serviceProvider.RegisterService(typeof(IRuleSetConflictsController), this.conflictsController); this.serviceProvider.RegisterService(typeof(IConfigurationProvider), this.configProvider); var outputWindow = new ConfigurableVsOutputWindow(); this.outputWindowPane = outputWindow.GetOrCreateSonarLintPane(); this.serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow); this.host = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher); this.host.SonarQubeService = sonarQubeService.Object; // Instead of ignored unexpected service, register one (for telemetry) this.serviceProvider.RegisterService(typeof(SComponentModel), new ConfigurableComponentModel()); }
public void TestInit() { this.serviceProvider = new ConfigurableServiceProvider(); this.sonarQubeServiceMock = new Mock <ISonarQubeService>(); this.host = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher); this.host.SetActiveSection(ConfigurableSectionController.CreateDefault()); this.host.SonarQubeService = this.sonarQubeServiceMock.Object; this.projectSystemHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider); this.sonarQubeServiceMock.Setup(x => x.GetAllPluginsAsync(It.IsAny <CancellationToken>())) .ReturnsAsync(new List <SonarQubePlugin> { new SonarQubePlugin(MinimumSupportedSonarQubePlugin.CSharp.Key, MinimumSupportedSonarQubePlugin.CSharp.MinimumVersion), new SonarQubePlugin(MinimumSupportedSonarQubePlugin.VbNet.Key, MinimumSupportedSonarQubePlugin.VbNet.MinimumVersion) }); this.settings = new ConfigurableSonarLintSettings(); var mefExports = MefTestHelpers.CreateExport <ISonarLintSettings>(settings); var mefModel = ConfigurableComponentModel.CreateWithExports(mefExports); this.serviceProvider.RegisterService(typeof(SComponentModel), mefModel); this.filter = new ConfigurableProjectSystemFilter(); this.serviceProvider.RegisterService(typeof(IProjectSystemFilter), this.filter); var outputWindow = new ConfigurableVsOutputWindow(); this.outputWindowPane = outputWindow.GetOrCreateSonarLintPane(); this.serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow); this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), this.projectSystemHelper); this.credentialStoreMock = new Mock <ICredentialStoreService>(); this.serviceProvider.RegisterService(typeof(ICredentialStoreService), this.credentialStoreMock.Object); }
public void TestInit() { this.serviceProvider = new ConfigurableServiceProvider(); this.sonarQubeService = new ConfigurableSonarQubeServiceWrapper(); this.host = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher); this.host.SetActiveSection(ConfigurableSectionController.CreateDefault()); this.host.SonarQubeService = this.sonarQubeService; this.projectSystemHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider); this.sonarQubeService.RegisterServerPlugin(new ServerPlugin { Key = MinimumSupportedServerPlugin.CSharp.Key, Version = MinimumSupportedServerPlugin.CSharp.MinimumVersion }); this.sonarQubeService.RegisterServerPlugin(new ServerPlugin { Key = MinimumSupportedServerPlugin.VbNet.Key, Version = MinimumSupportedServerPlugin.VbNet.MinimumVersion }); this.settings = new ConfigurableIntegrationSettings { AllowNuGetPackageInstall = true }; var mefExports = MefTestHelpers.CreateExport <IIntegrationSettings>(settings); var mefModel = ConfigurableComponentModel.CreateWithExports(mefExports); this.serviceProvider.RegisterService(typeof(SComponentModel), mefModel); this.filter = new ConfigurableProjectSystemFilter(); this.serviceProvider.RegisterService(typeof(IProjectSystemFilter), this.filter); var outputWindow = new ConfigurableVsOutputWindow(); this.outputWindowPane = outputWindow.GetOrCreateSonarLintPane(); this.serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow); this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), this.projectSystemHelper); }
public void TestInit() { this.sonarQubeServiceMock = new Mock <ISonarQubeService>(); this.connectionWorkflowMock = new Mock <IConnectionWorkflowExecutor>(); this.connectionProvider = new ConfigurableConnectionInformationProvider(); this.serviceProvider = new ConfigurableServiceProvider(); var outputWindow = new ConfigurableVsOutputWindow(); this.outputWindowPane = outputWindow.GetOrCreateSonarLintPane(); this.serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow); this.settings = new ConfigurableSonarLintSettings(); this.projectSystemHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider); this.host = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher); this.host.SonarQubeService = this.sonarQubeServiceMock.Object; IComponentModel componentModel = ConfigurableComponentModel.CreateWithExports( new [] { MefTestHelpers.CreateExport <ITelemetryLogger>(new ConfigurableTelemetryLogger()), MefTestHelpers.CreateExport <ISonarLintSettings>(settings) }); this.serviceProvider.RegisterService(typeof(SComponentModel), componentModel); this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), projectSystemHelper); }
public void TestInit() { this.serviceProvider = new ConfigurableServiceProvider(); this.sonarQubeService = new ConfigurableSonarQubeServiceWrapper(); this.host = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher); this.host.SetActiveSection(ConfigurableSectionController.CreateDefault()); this.host.SonarQubeService = this.sonarQubeService; this.projectSystemHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider); this.sonarQubeService.RegisterServerPlugin(new ServerPlugin { Key = MinimumSupportedServerPlugin.CSharp.Key, Version = MinimumSupportedServerPlugin.CSharp.MinimumVersion }); this.sonarQubeService.RegisterServerPlugin(new ServerPlugin { Key = MinimumSupportedServerPlugin.VbNet.Key, Version = MinimumSupportedServerPlugin.VbNet.MinimumVersion }); this.settings = new ConfigurableIntegrationSettings(); var mefExports = MefTestHelpers.CreateExport<IIntegrationSettings>(settings); var mefModel = ConfigurableComponentModel.CreateWithExports(mefExports); this.serviceProvider.RegisterService(typeof(SComponentModel), mefModel); this.filter = new ConfigurableProjectSystemFilter(); this.serviceProvider.RegisterService(typeof(IProjectSystemFilter), this.filter); var outputWindow = new ConfigurableVsOutputWindow(); this.outputWindowPane = outputWindow.GetOrCreateSonarLintPane(); this.serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow); this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), this.projectSystemHelper); }
public void TestInit() { this.serviceProvider = new ConfigurableServiceProvider(); this.dte = new DTEMock(); this.serviceProvider.RegisterService(typeof(EnvDTE.DTE), this.dte); var outputWindow = new ConfigurableVsOutputWindow(); this.outputPane = outputWindow.GetOrCreateSonarLintPane(); this.serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow); this.testSubject = new TelemetryLogger(this.serviceProvider); }
public void TestInitialize() { this.serviceProvider = new ConfigurableServiceProvider(false); this.host = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher); this.activeSolutionBoundTracker = new ConfigurableActiveSolutionBoundTracker(); var outputWindow = new ConfigurableVsOutputWindow(); var mefExport1 = MefTestHelpers.CreateExport<IHost>(this.host); var mefExport2 = MefTestHelpers.CreateExport<IActiveSolutionBoundTracker>(this.activeSolutionBoundTracker); var mefModel = ConfigurableComponentModel.CreateWithExports(mefExport1, mefExport2); this.serviceProvider.RegisterService(typeof(SComponentModel), mefModel); this.serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow); this.testSubject = new SonarAnalyzerManager(this.serviceProvider, new AdhocWorkspace()); }
public void TestInitialize() { this.serviceProvider = new ConfigurableServiceProvider(false); this.host = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher); this.activeSolutionBoundTracker = new ConfigurableActiveSolutionBoundTracker(); var outputWindow = new ConfigurableVsOutputWindow(); var mefExport1 = MefTestHelpers.CreateExport <IHost>(this.host); var mefExport2 = MefTestHelpers.CreateExport <IActiveSolutionBoundTracker>(this.activeSolutionBoundTracker); var mefModel = ConfigurableComponentModel.CreateWithExports(mefExport1, mefExport2); this.serviceProvider.RegisterService(typeof(SComponentModel), mefModel); this.serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow); this.testSubject = new SonarAnalyzerManager(this.serviceProvider, new AdhocWorkspace()); }
public void TestInit() { this.sonarQubeService = new ConfigurableSonarQubeServiceWrapper(); this.connectionWorkflow = new ConfigurableConnectionWorkflow(this.sonarQubeService); this.connectionProvider = new ConfigurableConnectionInformationProvider(); this.serviceProvider = new ConfigurableServiceProvider(); var outputWindow = new ConfigurableVsOutputWindow(); this.outputWindowPane = outputWindow.GetOrCreateSonarLintPane(); this.serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow); this.settings = new ConfigurableIntegrationSettings(); this.host = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher); this.host.SonarQubeService = this.sonarQubeService; var mefExports = MefTestHelpers.CreateExport<IIntegrationSettings>(settings); var mefModel = ConfigurableComponentModel.CreateWithExports(mefExports); this.serviceProvider.RegisterService(typeof(SComponentModel), mefModel); }
public void TestInit() { this.sonarQubeService = new ConfigurableSonarQubeServiceWrapper(); this.connectionWorkflow = new ConfigurableConnectionWorkflow(this.sonarQubeService); this.connectionProvider = new ConfigurableConnectionInformationProvider(); this.serviceProvider = new ConfigurableServiceProvider(); var outputWindow = new ConfigurableVsOutputWindow(); this.outputWindowPane = outputWindow.GetOrCreateSonarLintPane(); this.serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow); this.settings = new ConfigurableIntegrationSettings(); this.host = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher); this.host.SonarQubeService = this.sonarQubeService; var mefExports = MefTestHelpers.CreateExport <IIntegrationSettings>(settings); var mefModel = ConfigurableComponentModel.CreateWithExports(mefExports); this.serviceProvider.RegisterService(typeof(SComponentModel), mefModel); }
public void Write_OutputsToWindow() { // Arrange var windowMock = new ConfigurableVsOutputWindow(); var serviceProviderMock = new ConfigurableServiceProvider(assertOnUnexpectedServiceRequest: true); serviceProviderMock.RegisterService(typeof(SVsOutputWindow), windowMock); SonarLintOutputLogger logger = new SonarLintOutputLogger(serviceProviderMock); // Act logger.WriteLine("123"); logger.WriteLine("abc"); // Assert var outputPane = windowMock.AssertPaneExists(VsShellUtils.SonarLintOutputPaneGuid); outputPane.AssertOutputStrings("123", "abc"); }
public void NuGetHelper_HandleFailures() { // Setup ConfigurableServiceProvider sp = CreateServiceProvider(); var outputWindow = new ConfigurableVsOutputWindow(); var outputPane = outputWindow.GetOrCreateSonarLintPane(); sp.RegisterService(typeof(SVsOutputWindow), outputWindow); // Case 1: No MEF service // Act + Verify using (new AssertIgnoreScope()) // Missing MEF service { Assert.IsFalse(NuGetHelper.TryInstallPackage(sp, new ProjectMock("prj"), "pcg"), "No MEF service should be resulted with a false returned value"); } outputPane.AssertOutputStrings(0); // Case 2: Exception from the service sp.RegisterService(typeof(SComponentModel), ConfigurableComponentModel.CreateWithExports(MefTestHelpers.CreateExport<IVsPackageInstaller>(new ConfigurablePackageInstaller(simulateInstallerException: true))), replaceExisting: true); // Act + Verify Assert.IsFalse(NuGetHelper.TryInstallPackage(sp, new ProjectMock("prj"), "pcg"), "Non critical exception should result with a false returned value"); outputPane.AssertOutputStrings(1); }
public void NuGetHelper_HandleFailures() { // Arrange ConfigurableServiceProvider sp = CreateServiceProvider(); var outputWindow = new ConfigurableVsOutputWindow(); var outputPane = outputWindow.GetOrCreateSonarLintPane(); sp.RegisterService(typeof(SVsOutputWindow), outputWindow); // Case 1: No MEF service // Act + Assert using (new AssertIgnoreScope()) // Missing MEF service { NuGetHelper.TryInstallPackage(sp, new ProjectMock("prj"), "pcg").Should().BeFalse("No MEF service should be resulted with a false returned value"); } outputPane.AssertOutputStrings(0); // Case 2: Exception from the service sp.RegisterService(typeof(SComponentModel), ConfigurableComponentModel.CreateWithExports(MefTestHelpers.CreateExport <IVsPackageInstaller>(new ConfigurablePackageInstaller(simulateInstallerException: true))), replaceExisting: true); // Act + Assert NuGetHelper.TryInstallPackage(sp, new ProjectMock("prj"), "pcg").Should().BeFalse("Non critical exception should result with a false returned value"); outputPane.AssertOutputStrings(1); }