public void NuGetHelper_HandleFailures() { // Arrange var sp = CreateServiceProvider(); var testLogger = new TestLogger(); // Case 1: No MEF service // Act + Assert using (new AssertIgnoreScope()) // Missing MEF service { NuGetHelper.TryInstallPackage(sp, testLogger, new ProjectMock("prj"), "pcg").Should().BeFalse("No MEF service should be resulted with a false returned value"); } testLogger.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, testLogger, new ProjectMock("prj"), "pcg").Should().BeFalse("Non critical exception should result with a false returned value"); testLogger.AssertOutputStrings(1); }
public void TestInitialize() { ThreadHelper.SetCurrentThreadAsUIThread(); this.serviceProvider = new ConfigurableServiceProvider(assertOnUnexpectedServiceRequest: false); this.sonarQubeService = new ConfigurableSonarQubeServiceWrapper(); this.stepRunner = new ConfigurableProgressStepRunner(); this.solutionBinding = new ConfigurableSolutionBindingSerializer(); var projectSystem = new ConfigurableVsProjectSystemHelper(this.serviceProvider); this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), projectSystem); var host = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher); var propertyManager = new ProjectPropertyManager(host); var mefExports = MefTestHelpers.CreateExport <IProjectPropertyManager>(propertyManager); var mefModel = ConfigurableComponentModel.CreateWithExports(mefExports); this.serviceProvider.RegisterService(typeof(SComponentModel), mefModel); }
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; var sonarLintSettingsMefExport = MefTestHelpers.CreateExport <ISonarLintSettings>(settings); var mefModel = ConfigurableComponentModel.CreateWithExports(sonarLintSettingsMefExport); this.serviceProvider.RegisterService(typeof(SComponentModel), mefModel); this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), projectSystemHelper); }
public void TestInitialize() { ThreadHelper.SetCurrentThreadAsUIThread(); this.serviceProvider = new ConfigurableServiceProvider(assertOnUnexpectedServiceRequest: false); this.sonarQubeServiceMock = new Mock <ISonarQubeService>(); this.stepRunner = new ConfigurableProgressStepRunner(); this.configProvider = new ConfigurableConfigurationProvider(); var projectSystem = new ConfigurableVsProjectSystemHelper(this.serviceProvider); this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), projectSystem); var host = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher); var propertyManager = new ProjectPropertyManager(host); var mefExport1 = MefTestHelpers.CreateExport <IProjectPropertyManager>(propertyManager); var mefExport2 = MefTestHelpers.CreateExport <ILogger>(new SonarLintOutputLogger(serviceProvider)); var mefModel = ConfigurableComponentModel.CreateWithExports(mefExport1, mefExport2); this.serviceProvider.RegisterService(typeof(SComponentModel), mefModel); }
public void TestInitialize() { ThreadHelper.SetCurrentThreadAsUIThread(); this.serviceProvider = new ConfigurableServiceProvider(assertOnUnexpectedServiceRequest: false); IComponentModel componentModel = ConfigurableComponentModel.CreateWithExports( new Export[] { MefTestHelpers.CreateExport <ITelemetryLogger>(new ConfigurableTelemetryLogger()) }); this.serviceProvider.RegisterService(typeof(SComponentModel), componentModel); this.sonarQubeServiceMock = new Mock <ISonarQubeService>(); this.host = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher) { SonarQubeService = this.sonarQubeServiceMock.Object }; this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), new ConfigurableVsProjectSystemHelper(this.serviceProvider)); }
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(IConfigurationProvider), 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 }; IComponentModel componentModel = ConfigurableComponentModel.CreateWithExports( new [] { MefTestHelpers.CreateExport <ITelemetryLogger>(new ConfigurableTelemetryLogger()) }); this.serviceProvider.RegisterService(typeof(SComponentModel), componentModel); }
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 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); this.testProjectRegexSetter = new Mock <ITestProjectRegexSetter>(); this.serviceProvider.RegisterService(typeof(ITestProjectRegexSetter), testProjectRegexSetter.Object); }