public void VsSessionHost_IServiceProvider_GetService() { // Setup var testSubject = new VsSessionHost(this.serviceProvider, new Integration.Service.SonarQubeServiceWrapper(this.serviceProvider), new ConfigurableActiveSolutionTracker()); ConfigurableVsShell shell = new ConfigurableVsShell(); shell.RegisterPropertyGetter((int)__VSSPROPID2.VSSPROPID_InstallRootDir, () => this.TestContext.TestRunDirectory); this.serviceProvider.RegisterService(typeof(SVsShell), shell); // Local services // Act + Verify foreach (Type serviceType in VsSessionHost.SupportedLocalServices) { Assert.IsNotNull(testSubject.GetService(serviceType)); } Assert.AreSame(testSubject.GetService<IFileSystem>(), testSubject.GetService<ISourceControlledFileSystem>()); // VS-services // Sanity Assert.IsNull(testSubject.GetService(typeof(VsSessionHostTests)), "Not expecting any service at this point"); // Setup this.serviceProvider.RegisterService(typeof(VsSessionHostTests), this); // Act + Verify Assert.AreSame(this, testSubject.GetService(typeof(VsSessionHostTests)), "Unexpected service was returned, expected to use the service provider"); }