Ejemplo n.º 1
0
        public void VsSessionHost_IServiceProvider_GetService()
        {
            // Arrange
            var testSubject = new VsSessionHost(this.serviceProvider, this.sonarQubeServiceMock.Object,
                                                new ConfigurableActiveSolutionTracker());
            ConfigurableVsShell shell = new ConfigurableVsShell();

            shell.RegisterPropertyGetter((int)__VSSPROPID2.VSSPROPID_InstallRootDir, () => this.TestContext.TestRunDirectory);
            this.serviceProvider.RegisterService(typeof(SVsShell), shell);

            // Local services
            // Act + Assert
            foreach (Type serviceType in VsSessionHost.SupportedLocalServices)
            {
                testSubject.GetService(serviceType).Should().NotBeNull();
            }

            testSubject.GetService <ISourceControlledFileSystem>().Should().Be(testSubject.GetService <IFileSystem>());

            // VS-services
            // Sanity
            testSubject.GetService(typeof(VsSessionHostTests)).Should().BeNull("Not expecting any service at this point");

            // Arrange
            this.serviceProvider.RegisterService(typeof(VsSessionHostTests), this);

            // Act + Assert
            testSubject.GetService(typeof(VsSessionHostTests)).Should().Be(this, "Unexpected service was returned, expected to use the service provider");
        }
        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");
        }
        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");
        }