private static void AssertExpectedRulesExist(DiagnosticAnalyzer analyzer, JarInfo.Repository repository) { foreach (DiagnosticDescriptor descriptor in analyzer.SupportedDiagnostics) { AssertRuleExists(descriptor, repository); } }
private static void AssertRuleExists(DiagnosticDescriptor descriptor, JarInfo.Repository repository) { IEnumerable <JarInfo.Rule> matches = repository.Rules.Where(r => string.Equals(r.InternalKey, descriptor.Id, System.StringComparison.Ordinal)); Assert.AreNotEqual(0, matches.Count(), "Failed to find expected rule: {0}", descriptor.Id); Assert.AreEqual(1, matches.Count(), "Multiple rules have the same id: {0}", descriptor.Id); JarInfo.Rule actual = matches.Single(); Assert.AreEqual(descriptor.Title.ToString(), actual.Name, "Unexpected rule name"); Assert.AreEqual(descriptor.Id, actual.Key, "Unexpected rule key"); AssertPropertyHasValue(actual.Severity, "Severity"); }
private static void AssertRepositoryIsValid(JarInfo.Repository repository) { Assert.IsNotNull(repository, "Repository should not be null"); AssertPropertyHasValue(repository.Key, "Repository Key"); AssertPropertyHasValue(repository.Name, "Repository Name"); Assert.AreEqual(SupportedLanguages.CSharp, repository.Language, "Unexpected repository language"); Assert.IsNotNull(repository.Rules, "Repository rules should not be null"); Assert.AreNotEqual(0, repository.Rules.Count, "Repository should have at least one rule"); }