public void TestLoadingExisting()
        {
            var path        = Util.CreateTmpDir("ruleset");
            var rulesetPath = Path.Combine(path, "a.ruleset");

            // None exists, so it will be re-created
            var rulesetManager = new MonoDevelopRuleSetManager(rulesetPath);

            var ruleset = rulesetManager.GetGlobalRuleSet();

            Assert.IsNotNull(ruleset);

            rulesetManager = new MonoDevelopRuleSetManager(rulesetPath);
            var ruleset2 = rulesetManager.GetGlobalRuleSet();

            // A new manager will query again, so we can assume no cache is being used.
            Assert.IsNotNull(ruleset2);
            Assert.AreNotSame(ruleset, ruleset2);
        }
        public void TestLoadingBrokenRuleset()
        {
            var path        = Util.CreateTmpDir("ruleset");
            var rulesetPath = Path.Combine(path, "a.ruleset");

            // force ruleset file creation
            var rulesetManager = new MonoDevelopRuleSetManager(rulesetPath);
            var brokenText     = @"<RuleSet Name=""Global Rules"" ToolsVersion=""12.0"">
    <Rules AnalyzerId=""Roslyn"" RuleNamespace=""Roslyn"">>
	    <Rule Id=""RECS0076"" Action=""Suppress""/>
    </Rules>
</RuleSet>
";

            File.WriteAllText(rulesetPath, brokenText);

            var ruleset = rulesetManager.GetGlobalRuleSet();

            Assert.IsNotNull(ruleset);

            var backupPath = rulesetPath + ".backup";

            Assert.IsTrue(File.Exists(backupPath));
        }