After the rebase onto 1.4 the 16 SQLI-WIN/SQLI-SYN scripts had their own /* */ format, so SqlScriptTests (rule ids, review header, -- Kilde: blocks) failed. - The scripts have main's header (Regel-id, Titel, Alvor, Versioner, Vurdering, Grænseværdier, Rettigheder, Data kommer fra, Regelkode, Read-only); the Windows WQL/XPath stays word for word in comments. - The synthetic SQL check's SQL is registered (SyntheticCheckRunner.UseDatabaseSql, BeginTransactionSql, RollbackSql, SyntheticCheckSettings.DefaultQuery) and shown as -- Kilde: blocks in SQLI-SYN-001/002 and _collectors/SyntheticCheckRunner.sql. - SqlScriptTests know ServerRuleCatalog; only those rules may be without SQL blocks. - ServerScriptTests: every CimQueries query/filter is in a SQLI-WIN script word for word. - The SQL check cancels the rest of a large answer instead of draining it on close. - Rule counts: README (108 built-in: 92 SQL Server + 13 Windows + 3 synthetic), SQL Scripts/README (rule table, 124 rules, Windows/synthetic section), RuleCatalogTests, CONTRIBUTING (how to add a server rule). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
36 lines
1.4 KiB
C#
36 lines
1.4 KiB
C#
using SQLInsight.Rules.Engine;
|
|
|
|
namespace SQLInsight.Rules.Tests;
|
|
|
|
public class RuleCatalogTests
|
|
{
|
|
[Fact]
|
|
public void Every_rule_has_a_unique_well_formed_id()
|
|
{
|
|
var rules = BuiltInRules.Create();
|
|
|
|
Assert.Equal(rules.Count, rules.Select(r => r.Id).Distinct(StringComparer.OrdinalIgnoreCase).Count());
|
|
Assert.All(rules, r => Assert.Matches("^SQLI-[A-Z]+-[0-9]{3}$", r.Id));
|
|
Assert.All(rules, r => Assert.False(string.IsNullOrWhiteSpace(r.Title)));
|
|
}
|
|
|
|
/// <summary>Keeps the rule count in the README honest.</summary>
|
|
[Fact]
|
|
public void Rule_count()
|
|
{
|
|
Assert.Equal(92, BuiltInRules.Create().Count);
|
|
Assert.Equal(13, Servers.WindowsServerRules.Create().Count);
|
|
Assert.Equal(3, Servers.SyntheticCheckRules.Create().Count);
|
|
Assert.Equal(108, BuiltInRules.Create().Count + Servers.ServerRuleCatalog.All.Count);
|
|
}
|
|
|
|
[Fact]
|
|
public void Server_and_check_rules_have_unique_ids_that_no_instance_rule_has()
|
|
{
|
|
var ids = BuiltInRules.Create().Select(r => r.Id).Concat(Servers.ServerRuleCatalog.All.Select(r => r.Id)).ToList();
|
|
|
|
Assert.Equal(ids.Count, ids.Distinct(StringComparer.OrdinalIgnoreCase).Count());
|
|
Assert.All(Servers.ServerRuleCatalog.All, r => Assert.Matches("^SQLI-(WIN|SYN)-[0-9]{3}$", r.Id));
|
|
Assert.All(Servers.ServerRuleCatalog.All, r => Assert.False(string.IsNullOrWhiteSpace(r.Title)));
|
|
}
|
|
}
|