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.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); }
private static IServiceProvider CreateServiceProviderWithEmptyComponentModel() { var serviceProvider = new ConfigurableServiceProvider(); var mefModel = new ConfigurableComponentModel(serviceProvider); serviceProvider.RegisterService(typeof(SComponentModel), mefModel, replaceExisting: true); return(serviceProvider); }
public void BindingController_BindingFinished_Navigation() { // Arrange ServerViewModel serverVM = CreateServerViewModel(); serverVM.SetProjects(new[] { new ProjectInformation { Key = "key1" } }); ProjectViewModel projectVM = serverVM.Projects.First(); BindingController testSubject = this.PrepareCommandForExecution(); this.host.VisualStateManager.ManagedState.ConnectedServers.Add(serverVM); var progressEvents = new ConfigurableProgressEvents(); var teController = new ConfigurableTeamExplorerController(); var mefExports = MefTestHelpers.CreateExport <ITeamExplorerController>(teController); var mefModel = ConfigurableComponentModel.CreateWithExports(mefExports); serviceProvider.RegisterService(typeof(SComponentModel), mefModel, replaceExisting: true); // Case 1: On non-successful binding no navigation will occur foreach (ProgressControllerResult nonSuccuess in new[] { ProgressControllerResult.Cancelled, ProgressControllerResult.Failed }) { // Act testSubject.SetBindingInProgress(progressEvents, projectVM.ProjectInformation); progressEvents.SimulateFinished(nonSuccuess); // Assert teController.ShowConnectionsPageCallsCount.Should().Be(0); this.dteMock.ToolWindows.SolutionExplorer.Window.Active.Should().BeFalse(); } // Case 2: Has conflicts (should navigate to team explorer page) this.conflictsController.HasConflicts = true; // Act testSubject.SetBindingInProgress(progressEvents, projectVM.ProjectInformation); progressEvents.SimulateFinished(ProgressControllerResult.Succeeded); // Assert teController.ShowConnectionsPageCallsCount.Should().Be(1); this.dteMock.ToolWindows.SolutionExplorer.Window.Active.Should().BeFalse(); // Case 3: Has no conflicts (should navigate to solution explorer) this.conflictsController.HasConflicts = false; // Act testSubject.SetBindingInProgress(progressEvents, projectVM.ProjectInformation); progressEvents.SimulateFinished(ProgressControllerResult.Succeeded); // Assert teController.ShowConnectionsPageCallsCount.Should().Be(1); this.dteMock.ToolWindows.SolutionExplorer.Window.Active.Should().BeTrue(); }
private static IServiceProvider CreateServiceProviderWithMefExports <T>(T instance) { var serviceProvider = new ConfigurableServiceProvider(); var mefExports = MefTestHelpers.CreateExport <T>(instance); var mefModel = ConfigurableComponentModel.CreateWithExports(mefExports); serviceProvider.RegisterService(typeof(SComponentModel), mefModel, replaceExisting: true); return(serviceProvider); }
public void TestsInitialize() { activeSolutionBoundTrackerMock = new Mock <IActiveSolutionBoundTracker>(); sonarLintOutputMock = new Mock <ISonarLintOutput>(); var mefExport1 = MefTestHelpers.CreateExport <IActiveSolutionBoundTracker>(activeSolutionBoundTrackerMock.Object); var mefExport2 = MefTestHelpers.CreateExport <ISonarLintOutput>(sonarLintOutputMock.Object); var mefModel = ConfigurableComponentModel.CreateWithExports(mefExport1, mefExport2); configurableServiceProvider = new ConfigurableServiceProvider(false); configurableServiceProvider.RegisterService(typeof(SComponentModel), mefModel); }
public void NuGetHelper_SuccessfulCalls() { // Arrange var package = new PackageName(Guid.NewGuid().ToString("N"), new SemanticVersion("1.0")); var availablePackages = new[] { package }; ConfigurableServiceProvider sp = CreateServiceProvider(); sp.RegisterService(typeof(SComponentModel), ConfigurableComponentModel.CreateWithExports(MefTestHelpers.CreateExport <IVsPackageInstaller>(new ConfigurablePackageInstaller(availablePackages, simulateInstallerException: false))), replaceExisting: true); // Act + Assert NuGetHelper.TryInstallPackage(sp, new ProjectMock("prj"), package.Id, package.Version.ToNormalizedString()).Should().BeTrue("The package is expected to be installed successfully"); }
public void TestInitialize() { this.serviceProvider = new ConfigurableServiceProvider(); this.projectSystem = new ConfigurableVsProjectSystemHelper(this.serviceProvider); this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), this.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 BindingController_BindingFinished_Navigation() { // Arrange var bindingArgs = new BindCommandArgs("key2", "", new ConnectionInformation(new Uri("http://myUri"))); BindingController testSubject = this.PrepareCommandForExecution(); var progressEvents = new ConfigurableProgressEvents(); var teController = new ConfigurableTeamExplorerController(); var mefExports = MefTestHelpers.CreateExport <ITeamExplorerController>(teController); var mefModel = ConfigurableComponentModel.CreateWithExports(mefExports); serviceProvider.RegisterService(typeof(SComponentModel), mefModel, replaceExisting: true); // Case 1: On non-successful binding no navigation will occur foreach (ProgressControllerResult nonSuccuess in new[] { ProgressControllerResult.Cancelled, ProgressControllerResult.Failed }) { // Act testSubject.SetBindingInProgress(progressEvents, bindingArgs); progressEvents.SimulateFinished(nonSuccuess); // Assert teController.ShowConnectionsPageCallsCount.Should().Be(0); this.dteMock.ToolWindows.SolutionExplorer.Window.Active.Should().BeFalse(); } // Case 2: Has conflicts (should navigate to team explorer page) this.conflictsController.HasConflicts = true; // Act testSubject.SetBindingInProgress(progressEvents, bindingArgs); progressEvents.SimulateFinished(ProgressControllerResult.Succeeded); // Assert teController.ShowConnectionsPageCallsCount.Should().Be(1); this.dteMock.ToolWindows.SolutionExplorer.Window.Active.Should().BeFalse(); // Case 3: Has no conflicts (should navigate to solution explorer) this.conflictsController.HasConflicts = false; // Act testSubject.SetBindingInProgress(progressEvents, bindingArgs); progressEvents.SimulateFinished(ProgressControllerResult.Succeeded); // Assert teController.ShowConnectionsPageCallsCount.Should().Be(1); this.dteMock.ToolWindows.SolutionExplorer.Window.Active.Should().BeTrue(); }
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() { 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); this.host.SonarQubeService = this.sonarQubeServiceMock.Object; this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), new ConfigurableVsProjectSystemHelper(this.serviceProvider)); }
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 TestInitialize() { projectSystemHelper = new Mock <IProjectSystemHelper>(); projectPropertyManager = new Mock <IProjectPropertyManager>(); var mefExports = MefTestHelpers.CreateExport <IProjectPropertyManager>(projectPropertyManager.Object); var mefModel = ConfigurableComponentModel.CreateWithExports(mefExports); var serviceProvider = new Mock <IServiceProvider>(); serviceProvider.Setup(x => x.GetService(typeof(IProjectSystemHelper))).Returns(projectSystemHelper.Object); serviceProvider.Setup(x => x.GetService(typeof(SComponentModel))).Returns(mefModel); projectSystemHelper .Setup(x => x.GetIVsHierarchy(It.IsAny <EnvDTE.Project>())) .Returns(new ProjectMock("")); testSubject = new BuildPropertyTestProjectIndicator(serviceProvider.Object); }
public void TestInitialize() { ThreadHelper.SetCurrentThreadAsUIThread(); this.serviceProvider = new ConfigurableServiceProvider(assertOnUnexpectedServiceRequest: false); this.sonarQubeServiceMock = new Mock <ISonarQubeService>(); 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 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() { 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); }