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>();
        }
        public void Save_FilesSaved()
        {
            // We can't mock the RuleSet class so we're testing Save by actually
            // writing to disk.
            // Arrange
            var testDir = Path.Combine(TestContext.DeploymentDirectory, TestContext.TestName);

            Directory.CreateDirectory(testDir);

            var rulesetFullPath        = Path.Combine(testDir, "savedRuleSet.txt");
            var additionalFileFullPath = Path.Combine(testDir, "additionalFile.txt");

            var ruleSet        = new FilePathAndContent <RuleSet>(rulesetFullPath, new CoreRuleSet());
            var additionalFile = new FilePathAndContent <SonarLintConfiguration>(additionalFileFullPath, new SonarLintConfiguration());

            var testSubject = new CSharpVBBindingConfig(ruleSet, additionalFile);

            // Act
            testSubject.Save();

            // Assert
            File.Exists(rulesetFullPath).Should().BeTrue();
            File.Exists(additionalFileFullPath).Should().BeTrue();

            var savedAdditionalFile = File.ReadAllText(additionalFileFullPath);

            savedAdditionalFile.Should().Be(@"<?xml version=""1.0"" encoding=""utf-8""?>
<AnalysisInput xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
  <Settings />
  <Rules />
</AnalysisInput>");
        }
        private static CSharpVBBindingConfig CreateCSharpVbBindingConfig(string newSolutionRuleSetPath, CoreRuleSet coreRuleSet)
        {
            var ruleset        = new FilePathAndContent <CoreRuleSet>(newSolutionRuleSetPath, coreRuleSet);
            var additionalFile = new FilePathAndContent <SonarLintConfiguration>("dummy.txt", new SonarLintConfiguration());
            var csharpVbConfig = new CSharpVBBindingConfig(ruleset, additionalFile);

            return(csharpVbConfig);
        }
        public void GetSolutionLevelFilePaths_ReturnFilePaths()
        {
            var ruleSet        = new FilePathAndContent <RuleSet>("ruleset dummy", new CoreRuleSet());
            var additionalFile = new FilePathAndContent <SonarLintConfiguration>("additional file dummy", new SonarLintConfiguration());

            var testSubject = new CSharpVBBindingConfig(ruleSet, additionalFile);

            testSubject.SolutionLevelFilePaths.Count().Should().Be(2);
            testSubject.SolutionLevelFilePaths.First().Should().Be(ruleSet.Path);
            testSubject.SolutionLevelFilePaths.Last().Should().Be(additionalFile.Path);
        }