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 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); 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 MefCtor_CheckExports() { CompositionBatch batch = new CompositionBatch(); // Set up the exports required by the test subject var fileRenamesEventSourceExport = MefTestHelpers.CreateExport <IFileRenamesEventSource>(Mock.Of <IFileRenamesEventSource>()); batch.AddExport(fileRenamesEventSourceExport); var tableManagerExport = MefTestHelpers.CreateExport <ITableManagerProvider>(mockTableManagerProvider.Object); batch.AddExport(tableManagerExport); var selectionServiceExport = MefTestHelpers.CreateExport <IIssueSelectionService>(Mock.Of <IIssueSelectionService>()); batch.AddExport(selectionServiceExport); // Set up importers for each of the interfaces exported by the test subject var errorDataSourceImporter = new SingleObjectImporter <ISonarErrorListDataSource>(); var issueLocationStoreImporter = new SingleObjectImporter <IIssueLocationStore>(); batch.AddPart(errorDataSourceImporter); batch.AddPart(issueLocationStoreImporter); // Specify the source types that can be used to satify any import requests TypeCatalog catalog = new TypeCatalog(typeof(SonarErrorListDataSource)); using (CompositionContainer container = new CompositionContainer(catalog)) { container.Compose(batch); // Both imports should be satisfied... errorDataSourceImporter.Import.Should().NotBeNull(); issueLocationStoreImporter.Import.Should().NotBeNull(); // ... and the the export should be a singleton, so the both importers should // get the same instance errorDataSourceImporter.Import.Should().BeSameAs(issueLocationStoreImporter.Import); } }
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 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); }
public void MefCtor_CheckIsExported() { MefTestHelpers.CheckTypeCanBeImported <IDEWindowService, IIDEWindowService>(null, new[] { MefTestHelpers.CreateExport <ILogger>(Mock.Of <ILogger>()) }); }
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 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); }
public void FormatDefinition_MefCtor_CheckIsExported() { MefTestHelpers.CheckTypeCanBeImported <LightIssueHighlightFormatDefinition, EditorFormatDefinition>(null, null); MefTestHelpers.CheckTypeCanBeImported <DarkIssueHighlightFormatDefinition, EditorFormatDefinition>(null, null); }
public void MefCtor_CheckIsExported() { // Act & Assert MefTestHelpers.CheckTypeCanBeImported <LineHashCalculator, ILineHashCalculator>(null, null); }