Ejemplo n.º 1
0
        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(IConfigurationProviderService), 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
            };

            configProvider.FolderPathToReturn = "c:\\test";
        }
Ejemplo n.º 2
0
        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.serviceProvider.RegisterService(typeof(IProjectSystemHelper), this.projectSystemHelper);
            this.serviceProvider.RegisterService(typeof(IRuleSetConflictsController), this.conflictsController);
            this.serviceProvider.RegisterService(typeof(IConfigurationProvider), this.configProvider);

            var outputWindow = new ConfigurableVsOutputWindow();

            this.outputWindowPane = outputWindow.GetOrCreateSonarLintPane();
            this.serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow);

            this.host = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher);
            this.host.SonarQubeService = sonarQubeService.Object;

            // Instead of ignored unexpected service, register one (for telemetry)
            this.serviceProvider.RegisterService(typeof(SComponentModel), new ConfigurableComponentModel());
        }
Ejemplo n.º 3
0
        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.serviceProvider.RegisterService(typeof(IProjectSystemHelper), this.projectSystemHelper);
            this.serviceProvider.RegisterService(typeof(IRuleSetConflictsController), this.conflictsController);
            this.serviceProvider.RegisterService(typeof(IConfigurationProvider), this.configProvider);

            var outputWindow = new ConfigurableVsOutputWindow();

            this.outputWindowPane = outputWindow.GetOrCreateSonarLintPane();
            this.serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow);

            this.host = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher);
            this.host.SonarQubeService = sonarQubeService.Object;

            IComponentModel componentModel = ConfigurableComponentModel.CreateWithExports(
                new []
            {
                MefTestHelpers.CreateExport <ITelemetryLogger>(new ConfigurableTelemetryLogger())
            });

            this.serviceProvider.RegisterService(typeof(SComponentModel), componentModel);
        }
Ejemplo n.º 4
0
        public void TestStopCondition()
        {
            // set the seed manually.
            RandomGeneratorExtensions.GetGetNewRandom = () => new RandomGenerator(4541247);

            // create solver.
            var solver = new VNSSolver <float, ProblemMock, ObjectiveMock, SolutionMock, float>(
                new GeneratorMock(), new PerturberMock(), new LocalSearchMock(), (i, l, p, o, s) =>
            {
                return(s.Value < 100);
            });

            // run solver but stop when after a few reported improvements.
            var best = new SolutionMock()
            {
                Value = 1000
            };

            solver.IntermidiateResult += (s) =>
            {
                best = s;
            };
            var solution = solver.Solve(new ProblemMock()
            {
                Max = 1000
            }, new ObjectiveMock());

            Assert.AreEqual(best.Value, solution.Value);
            Assert.IsTrue(solution.Value < 100);
        }
        public void TestInitialize()
        {
            fileSystem = new MockFileSystem();

            this.dte             = new DTEMock();
            this.serviceProvider = new ConfigurableServiceProvider();
            this.solutionMock    = new SolutionMock(dte, Path.Combine(SolutionRoot, "xxx.sln"));
            this.projectMock     = this.solutionMock.AddOrGetProject(Path.Combine(SolutionRoot, @"Project\project.proj"));
            this.outputPane      = new ConfigurableVsOutputWindowPane();
            this.serviceProvider.RegisterService(typeof(SVsGeneralOutputWindowPane), this.outputPane);
            this.projectSystemHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider);
            this.sccFileSystem       = new ConfigurableSourceControlledFileSystem(fileSystem);
            this.ruleSetFS           = new ConfigurableRuleSetSerializer(fileSystem);
            this.serviceProvider.RegisterService(typeof(ISourceControlledFileSystem), this.sccFileSystem);
            this.serviceProvider.RegisterService(typeof(IRuleSetSerializer), this.ruleSetFS);
            this.serviceProvider.RegisterService(typeof(ISolutionRuleSetsInformationProvider),
                                                 new SolutionRuleSetsInformationProvider(this.serviceProvider, new Mock <ILogger>().Object, new MockFileSystem()));
            this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), this.projectSystemHelper);

            var coreRuleSet    = new FilePathAndContent <CoreRuleSet>(@"c:\Solution\sln.ruleset", new CoreRuleSet());
            var vsRuleSet      = new VsRuleSet("VS ruleset");
            var additionalFile = new FilePathAndContent <SonarLintConfiguration>(@"c:\Solution\additionalFile.txt", new SonarLintConfiguration());

            cSharpVBBindingConfig = new CSharpVBBindingConfig(coreRuleSet, additionalFile);

            ruleSetFS.RegisterRuleSet(vsRuleSet, coreRuleSet.Path);

            additionalFileConflictChecker = new Mock <IAdditionalFileConflictChecker>();
            ruleSetReferenceChecker       = new Mock <IRuleSetReferenceChecker>();
        }
Ejemplo n.º 6
0
        public void TestInitialize()
        {
            this.dte             = new DTEMock();
            this.serviceProvider = new ConfigurableServiceProvider();
            this.solutionMock    = new SolutionMock(dte, Path.Combine(SolutionRoot, "xxx.sln"));
            this.outputPane      = new ConfigurableVsOutputWindowPane();
            this.serviceProvider.RegisterService(typeof(SVsGeneralOutputWindowPane), this.outputPane);
            this.projectSystemHelper  = new ConfigurableVsProjectSystemHelper(this.serviceProvider);
            this.solutionItemsProject = this.solutionMock.AddOrGetProject("Solution items");
            this.projectSystemHelper.SolutionItemsProject  = this.solutionItemsProject;
            this.projectSystemHelper.CurrentActiveSolution = this.solutionMock;
            this.fileSystem    = new MockFileSystem();
            this.sccFileSystem = new ConfigurableSourceControlledFileSystem(fileSystem);
            this.ruleFS        = new ConfigurableRuleSetSerializer(fileSystem);
            this.ruleSetInfo   = new ConfigurableSolutionRuleSetsInformationProvider
            {
                SolutionRootFolder = SolutionRoot
            };

            this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), this.projectSystemHelper);
            this.serviceProvider.RegisterService(typeof(ISourceControlledFileSystem), this.sccFileSystem);
            this.serviceProvider.RegisterService(typeof(IRuleSetSerializer), this.ruleFS);
            this.serviceProvider.RegisterService(typeof(ISolutionRuleSetsInformationProvider), this.ruleSetInfo);

            projectBinderFactoryMock = new Mock <IProjectBinderFactory>();
        }
        public void TestInitialize()
        {
            this.dte = new DTEMock();
            this.serviceProvider = new ConfigurableServiceProvider();
            this.solutionMock = new SolutionMock(dte, Path.Combine(SolutionRoot, "xxx.sln"));
            this.projectMock = this.solutionMock.AddOrGetProject(Path.Combine(SolutionRoot, @"Project\project.proj"));
            this.outputPane = new ConfigurableVsOutputWindowPane();
            this.serviceProvider.RegisterService(typeof(SVsGeneralOutputWindowPane), this.outputPane);
            this.projectSystemHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider);
            this.ruleStore = new ConfigurableSolutionRuleStore();
            this.sccFileSystem = new ConfigurableSourceControlledFileSystem();
            this.ruleSetFS = new ConfigurableRuleSetSerializer(this.sccFileSystem);

            this.serviceProvider.RegisterService(typeof(ISourceControlledFileSystem), this.sccFileSystem);
            this.serviceProvider.RegisterService(typeof(IRuleSetSerializer), this.ruleSetFS);
            this.serviceProvider.RegisterService(typeof(ISolutionRuleSetsInformationProvider), new SolutionRuleSetsInformationProvider(this.serviceProvider));
        }
Ejemplo n.º 8
0
        public void TestInitialize()
        {
            this.dte             = new DTEMock();
            this.serviceProvider = new ConfigurableServiceProvider();
            this.solutionMock    = new SolutionMock(dte, Path.Combine(SolutionRoot, "xxx.sln"));
            this.projectMock     = this.solutionMock.AddOrGetProject(Path.Combine(SolutionRoot, @"Project\project.proj"));
            this.outputPane      = new ConfigurableVsOutputWindowPane();
            this.serviceProvider.RegisterService(typeof(SVsGeneralOutputWindowPane), this.outputPane);
            this.projectSystemHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider);
            this.ruleStore           = new ConfigurableSolutionRuleStore();
            this.sccFileSystem       = new ConfigurableSourceControlledFileSystem();
            this.ruleSetFS           = new ConfigurableRuleSetSerializer(this.sccFileSystem);

            this.serviceProvider.RegisterService(typeof(ISourceControlledFileSystem), this.sccFileSystem);
            this.serviceProvider.RegisterService(typeof(IRuleSetSerializer), this.ruleSetFS);
            this.serviceProvider.RegisterService(typeof(ISolutionRuleSetsInformationProvider), new SolutionRuleSetsInformationProvider(this.serviceProvider));
        }
Ejemplo n.º 9
0
        public void ConfigurationSaveAndRestorationTest()
        {
            Solution            mockSolution      = new SolutionMock();
            CPlusPlusTestConfig testConfiguration = CPlusPlusTestConfig.Open(mockSolution);

            Assert.IsFalse(String.IsNullOrEmpty(testConfiguration.FilePath), "File Path is null");
            testConfiguration.Projects.Add(new ConfiguredProject {
                Name = "Mock Project", TestExe = "mock.exe"
            });
            testConfiguration.Save();
            Assert.IsTrue(File.Exists(testConfiguration.FilePath), "Failed to create configuration file");
            testConfiguration = CPlusPlusTestConfig.Open(mockSolution);
            ConfiguredProject project = testConfiguration.Projects[0];

            Assert.IsNotNull(project, "Failed to restore project for config");
            Assert.AreEqual(project.ListTestCommand, Resources.DefaultGTestList, "List Test's Command Failed to save correctly");
            Assert.AreEqual(project.Name, "Mock Project", "Project name Failed to save correctly");
            Assert.AreEqual(project.RunTestCommand, Resources.DefaultGTestRun, "Run Test's Command Failed to save correctly");
            Assert.AreEqual(project.TestExe, "mock.exe", "Test Exe failed to save correctly");
            File.Delete(testConfiguration.FilePath);
        }
        public void TestInitialize()
        {
            KnownUIContextsAccessor.Reset();
            this.sonarQubeService = new ConfigurableSonarQubeServiceWrapper();
            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.serviceProvider.RegisterService(typeof(IProjectSystemHelper), this.projectSystemHelper);
            this.serviceProvider.RegisterService(typeof(IRuleSetConflictsController), this.conflictsController);

            this.host = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher);
            this.host.SonarQubeService = sonarQubeService;

            // Instead of ignored unexpected service, register one (for telemetry)
            this.serviceProvider.RegisterService(typeof(SComponentModel), new ConfigurableComponentModel());
        }
        public void TestInitialize()
        {
            this.dte = new DTEMock();
            this.serviceProvider = new ConfigurableServiceProvider();
            this.solutionMock = new SolutionMock(dte, Path.Combine(SolutionRoot, "xxx.sln"));
            this.outputPane = new ConfigurableVsOutputWindowPane();
            this.serviceProvider.RegisterService(typeof(SVsGeneralOutputWindowPane), this.outputPane);
            this.projectSystemHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider);
            this.projectFilter = new ConfigurableProjectSystemFilter();
            this.solutionItemsProject = this.solutionMock.AddOrGetProject("Solution items");
            this.projectSystemHelper.SolutionItemsProject = this.solutionItemsProject;
            this.projectSystemHelper.CurrentActiveSolution = this.solutionMock;
            this.sccFileSystem  = new ConfigurableSourceControlledFileSystem();
            this.ruleFS = new ConfigurableRuleSetSerializer(this.sccFileSystem);
            this.solutionBinding = new ConfigurableSolutionBindingSerializer();
            this.ruleSetInfo = new ConfigurableSolutionRuleSetsInformationProvider();
            this.ruleSetInfo.SolutionRootFolder = SolutionRoot;

            this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), this.projectSystemHelper);
            this.serviceProvider.RegisterService(typeof(ISourceControlledFileSystem), this.sccFileSystem);
            this.serviceProvider.RegisterService(typeof(IRuleSetSerializer), this.ruleFS);
            this.serviceProvider.RegisterService(typeof(ISolutionRuleSetsInformationProvider), this.ruleSetInfo);
        }
Ejemplo n.º 12
0
        public void TestStop()
        {
            // set the seed manually.
            RandomGeneratorExtensions.GetGetNewRandom = () => new RandomGenerator(4541247);

            // create solver.
            var solver = new VNSSolver <float, ProblemMock, ObjectiveMock, SolutionMock, float>(
                new GeneratorMock(), new PerturberMock(), new LocalSearchMock());

            // run solver but stop when after a few reported improvements.
            var intermediateCount = 0;
            var best = new SolutionMock()
            {
                Value = 1000
            };

            solver.IntermidiateResult += (s) =>
            {
                intermediateCount++;
                if (intermediateCount > 5)
                { // this should never ever happen!
                    Assert.Fail("Solver has not stopped!");
                }
                if (intermediateCount == 5)
                { // stop solver.
                    solver.Stop();
                    best = s;
                }
            };
            var solution = solver.Solve(new ProblemMock()
            {
                Max = 1000
            }, new ObjectiveMock());

            Assert.AreEqual(best.Value, solution.Value);
        }