public void TestInitialize()
        {
            solution = new Mock <IVsSolution>();

            var serviceProvider = new Mock <IServiceProvider>();

            serviceProvider.Setup(x => x.GetService(typeof(SVsSolution))).Returns(solution.Object);

            testSubject = new LegacySolutionBindingPathProvider(serviceProvider.Object);
        }
Exemplo n.º 2
0
        public void TestInitialize()
        {
            solutionRuleSetsInformationProvider = new Mock <ISolutionRuleSetsInformationProvider>();
            serviceProvider = new Mock <IServiceProvider>();
            serviceProvider
            .Setup(x => x.GetService(typeof(ISolutionRuleSetsInformationProvider)))
            .Returns(solutionRuleSetsInformationProvider.Object);

            testSubject = new LegacySolutionBindingPathProvider(serviceProvider.Object);
        }
Exemplo n.º 3
0
        private void RegisterLocalServices()
        {
            this.localServices.Add(typeof(ISolutionRuleSetsInformationProvider), new Lazy <ILocalService>(() => new SolutionRuleSetsInformationProvider(this, Logger)));
            this.localServices.Add(typeof(IRuleSetSerializer), new Lazy <ILocalService>(() => new RuleSetSerializer()));
            this.localServices.Add(typeof(ICredentialStoreService), new Lazy <ILocalService>(() => new CredentialStore(new SecretStore("SonarLint.VisualStudio.Integration"))));
            this.localServices.Add(typeof(IConfigurationProvider), new Lazy <ILocalService>(() =>
            {
                var solution = this.GetService <SVsSolution, IVsSolution>();
                var connectedModeConfigPathProvider = new ConnectedModeSolutionBindingPathProvider(solution);
                var legacyConfigPathProvider        = new LegacySolutionBindingPathProvider(this);
                var legacyPostSaveOperation         = new LegacySolutionBindingPostSaveOperation(this);

                var store             = this.GetService <ICredentialStoreService>();
                var credentialsLoader = new SolutionBindingCredentialsLoader(store);
                var bindingFileLoader = new SolutionBindingFileLoader(Logger);

                var sccFileSystem = this.GetService <ISourceControlledFileSystem>();

                var bindingSerializer = new SolutionBindingSerializer(sccFileSystem, bindingFileLoader, credentialsLoader);

                return(new ConfigurationProvider(legacyConfigPathProvider, connectedModeConfigPathProvider, bindingSerializer, legacyPostSaveOperation));
            }));

            var projectNameTestProjectIndicator = new Lazy <ILocalService>(() => new ProjectNameTestProjectIndicator(Logger));

            this.localServices.Add(typeof(ITestProjectRegexSetter), projectNameTestProjectIndicator);

            this.localServices.Add(typeof(IProjectSystemHelper), new Lazy <ILocalService>(() => new ProjectSystemHelper(this)));
            this.localServices.Add(typeof(IRuleSetInspector), new Lazy <ILocalService>(() => new RuleSetInspector(this, Logger)));
            this.localServices.Add(typeof(IRuleSetConflictsController), new Lazy <ILocalService>(() => new RuleSetConflictsController(this, new ConflictsManager(this, Logger))));
            this.localServices.Add(typeof(IProjectSystemFilter), new Lazy <ILocalService>(() =>
            {
                var testProjectIndicators = new List <ITestProjectIndicator>
                {
                    new BuildPropertyTestProjectIndicator(this),
                    new ProjectKindTestProjectIndicator(this),
                    new ProjectCapabilityTestProjectIndicator(this),
                    new ServiceGuidTestProjectIndicator(Logger),
                    projectNameTestProjectIndicator.Value as ITestProjectIndicator,
                };

                var testProjectIndicator = new TestProjectIndicator(testProjectIndicators);

                return(new ProjectSystemFilter(this, testProjectIndicator));
            }));
            this.localServices.Add(typeof(IErrorListInfoBarController), new Lazy <ILocalService>(() => new ErrorListInfoBarController(this, new UnboundProjectFinder(this))));

            // Use Lazy<object> to avoid creating instances needlessly, since the interfaces are serviced by the same instance
            var sccFs = new Lazy <ILocalService>(() => new SourceControlledFileSystem(this, Logger));

            this.localServices.Add(typeof(ISourceControlledFileSystem), sccFs);

            Debug.Assert(SupportedLocalServices.Length == this.localServices.Count, "Unexpected number of local services");
            Debug.Assert(SupportedLocalServices.All(t => this.localServices.ContainsKey(t)), "Not all the LocalServices are registered");
        }
        private ILocalService GetConfigurationPersister()
        {
            var connectedModeConfigPathProvider = new ConnectedModeSolutionBindingPathProvider(this);
            var legacyConfigPathProvider        = new LegacySolutionBindingPathProvider(this);
            var legacyConfigFolderItemAdder     = new LegacyConfigFolderItemAdder(this);

            var credentialsLoader = new SolutionBindingCredentialsLoader(credentialStoreService);
            var bindingFileLoader = new SolutionBindingFileLoader(Logger);

            var sccFileSystem = this.GetService <ISourceControlledFileSystem>();

            var solutionBindingDataWriter = new SolutionBindingDataWriter(sccFileSystem, bindingFileLoader, credentialsLoader);

            return(new ConfigurationPersister(legacyConfigPathProvider, connectedModeConfigPathProvider, solutionBindingDataWriter, legacyConfigFolderItemAdder));
        }