API Reference
RuleBuilder
Fluent API for building rules with simplified syntax.
Inheritance
- Object
- RuleBuilder
Constructors
public RuleBuilder(String name) #Creates a new RuleBuilder for a C# rule with the specified technical name.
Parameters
- name System.String
- Technical rule name (unique within the engine).
Methods
public RuleBuilder AddCountTest(String testName, String propertyPath, Int32 expectedCount, Importance importance = Moderate) #RuleBuilderAdds a count test.
Parameters
- testName System.String
- Display name of the test.
- propertyPath System.String
- Collection property path or "$" for the root list.
- expectedCount System.Int32
- Expected number of items.
- importance TestimoX.Definitions.Importance = Moderate
- Importance/severity if the test fails.
Returns
The same builder.
public RuleBuilder AddCustomTest(String testName, Func<Object, Boolean> predicate, Importance importance = Moderate, String description = null) #RuleBuilderAdds a complex test with custom logic.
Parameters
- testName System.String
- predicate System.Func{System.Object,System.Boolean}
- importance TestimoX.Definitions.Importance = Moderate
- description System.String = null
public RuleBuilder AddNotEmptyTest(String testName, String propertyPath, Importance importance = Moderate) #RuleBuilderAdds an empty check test.
Parameters
- testName System.String
- propertyPath System.String
- importance TestimoX.Definitions.Importance = Moderate
public RuleBuilder AddNotNullTest(String testName, String propertyPath, Importance importance = High) #RuleBuilderAdds a null check test.
Parameters
- testName System.String
- propertyPath System.String
- importance TestimoX.Definitions.Importance = High
public RuleBuilder AddPropertyTest(String testName, String propertyPath, Object expectedValue, Importance importance = Moderate) #RuleBuilderAdds a simple property test.
Parameters
- testName System.String
- Display name of the test.
- propertyPath System.String
- JSON-like property path within a result object.
- expectedValue System.Object
- Expected property value.
- importance TestimoX.Definitions.Importance = Moderate
- Importance/severity if the test fails.
Returns
The same builder.
public RuleBuilder AddRangeTest(String testName, String propertyPath, IComparable min, IComparable max, Importance importance = Moderate) #RuleBuilderAdds a range test.
Parameters
- testName System.String
- Display name of the test.
- propertyPath System.String
- Numeric/date property path.
- min System.IComparable
- Inclusive minimum value.
- max System.IComparable
- Inclusive maximum value.
- importance TestimoX.Definitions.Importance = Moderate
- Importance/severity if the test fails.
Returns
The same builder.
public RuleBuilder AddRiskScoreTest(String testName, Func<Object, RiskScore> calculateRisk, Int32 minimumScore = 70, Importance importance = High) #RuleBuilderAdds a risk score test.
Parameters
- testName System.String
- calculateRisk System.Func{System.Object,TestimoX.Testing.RiskScore}
- minimumScore System.Int32 = 70
- importance TestimoX.Definitions.Importance = High
public RuleBuilder AddTest(Action<TestBuilder> configureTest) #RuleBuilderAdds a test using the TestBuilder.
Parameters
- configureTest System.Action{TestimoX.Testing.TestBuilder}
- Callback that configures a test using TestBuilder.
Returns
The same builder.
public RuleBuilder AddThresholdTest(String testName, String propertyPath, IComparable threshold, Boolean shouldBeGreater = true, Importance importance = Moderate) #RuleBuilderAdds a threshold test.
Parameters
- testName System.String
- Display name of the test.
- propertyPath System.String
- Numeric/date property path.
- threshold System.IComparable
- Threshold to compare against.
- shouldBeGreater System.Boolean = true
- When true, expects property ≥ threshold; otherwise ≤ threshold.
- importance TestimoX.Definitions.Importance = Moderate
- Importance/severity if the test fails.
Returns
The same builder.
public static RuleBuilder Create(String name) #RuleBuilderCreates a new rule builder.
Parameters
- name System.String
- Technical rule name.
Returns
Fluent rule builder.
Examples
var rule = RuleBuilder.Create("SampleRule")
.DisplayName("Sample – Demo")
.Description("Shows the RuleBuilder fluent API.")
.ForScope(Scope.Domain)
.WithSource(p => new object[] { new { Domain = p.Domain, Count = 1 } })
.AddTest(t => t.Named("Count is 1").Where("Count").Equals(1))
.Build();
public RuleBuilder Deprecated() #RuleBuilderMarks this rule as deprecated (kept for compatibility). UIs may surface this tag.
Returns
The same builder.
public RuleBuilder Description(String description) #RuleBuilderSets the rule description (supports markdown).
Parameters
- description System.String
- Rule description (markdown supported).
Returns
The same builder.
public RuleBuilder DisplayName(String displayName) #RuleBuilderSets the display name.
Parameters
- displayName System.String
- Human‑friendly rule title.
Returns
The same builder for chaining.
public RuleBuilder Enabled(Boolean enabled = true) #RuleBuilderSets whether the rule is enabled.
Parameters
- enabled System.Boolean = true
- Whether the rule is enabled by default.
Returns
The same builder.
public RuleBuilder ForScope(Scope scope) #RuleBuilderSets the rule scope.
Parameters
- scope TestimoX.Definitions.Scope
- Scope at which the rule executes.
Returns
The same builder.
public RuleBuilder InCategories(params Category[] categories) #RuleBuilderSets the rule categories.
Parameters
- categories TestimoX.Definitions.Category[]
- Category tags for filtering and UI grouping.
Returns
The same builder.
op_Implicit(TestimoX.Testing.RuleBuilder builder) #Implicitly converts the builder to a Rule.
Parameters
- builder TestimoX.Testing.RuleBuilder
public RuleBuilder WithCost(RuleCost cost) #RuleBuilderSets a rough execution cost hint to help filter heavy rules.
Parameters
- cost TestimoX.Definitions.RuleCost
public RuleBuilder WithParameter(String key, Object value) #RuleBuilderAdds source parameters.
Parameters
- key System.String
- Parameter key passed to the rule source.
- value System.Object
- Parameter value.
Returns
The same builder.
public RuleBuilder WithParameters(IDictionary<String, Object> parameters) #RuleBuilderAdds multiple source parameters.
Parameters
- parameters System.Collections.Generic.IDictionary{System.String,System.Object}
- Key/value parameter pairs.
Returns
The same builder.
public RuleBuilder WithReport(Action<ReportViewBuilder> configure) #RuleBuilderConfigures report rendering hints (summary fields, sections, highlights) for this rule.
Parameters
- configure System.Action{TestimoX.Testing.ReportViewBuilder}
- Callback that uses ReportViewBuilder to shape output.
public RuleBuilder WithScoreKind(ScoreKind kind) #RuleBuilderSets the default scoring domain for this rule. Individual tests can override with TestBuilder.WithScoreKind.
Parameters
- kind TestimoX.Definitions.ScoreKind
public RuleBuilder WithSource<TService>(Func<TService, IDictionary<String, Object>, Task<IEnumerable<Object>>> serviceMethod) #RuleBuilderSets the data source using a delegate with dictionary parameters.
Type Parameters
- TService
Parameters
- sourceMethod System.Func{System.Collections.Generic.IDictionary{System.String,System.Object},System.Threading.Tasks.Task{System.Collections.Generic.IEnumerable{System.Object}}}
- Async delegate returning the rule's result objects.
Returns
The same builder.
WithSource(System.Func{TestimoX.Execution.RuleParameters,System.Threading.Tasks.Task{System.Collections.Generic.IEnumerable{System.Object}}} sourceMethod) #Sets the data source using a delegate with typed parameters.
Parameters
- sourceMethod System.Func{TestimoX.Execution.RuleParameters,System.Threading.Tasks.Task{System.Collections.Generic.IEnumerable{System.Object}}}
- Async delegate using typed RuleParameters.
Returns
The same builder.
WithSource(System.Func{System.Collections.Generic.IDictionary{System.String,System.Object},System.Collections.Generic.IEnumerable{System.Object}} sourceMethod) #Sets the data source using a synchronous delegate with dictionary parameters.
Parameters
- sourceMethod System.Func{System.Collections.Generic.IDictionary{System.String,System.Object},System.Collections.Generic.IEnumerable{System.Object}}
- Synchronous delegate returning result objects.
Returns
The same builder.
WithSource(System.Func{TestimoX.Execution.RuleParameters,System.Collections.Generic.IEnumerable{System.Object}} sourceMethod) #Sets the data source using a synchronous delegate with typed parameters.
Parameters
- sourceMethod System.Func{TestimoX.Execution.RuleParameters,System.Collections.Generic.IEnumerable{System.Object}}
- Synchronous delegate using typed RuleParameters.
Returns
The same builder.
WithSource``1(System.Func{``0,System.Collections.Generic.IDictionary{System.String,System.Object},System.Threading.Tasks.Task{System.Collections.Generic.IEnumerable{System.Object}}} serviceMethod) #Sets the data source using an existing service method.
Type Parameters
- TService
- Service class providing the data method.
Parameters
- serviceMethod System.Func{``0,System.Collections.Generic.IDictionary{System.String,System.Object},System.Threading.Tasks.Task{System.Collections.Generic.IEnumerable{System.Object}}}
- Async method on TService that returns result objects.
Returns
The same builder.
public RuleBuilder WithTags(params String[] tags) #RuleBuilderAdds free-form tags to the rule (e.g., "laps", "acl", "heavy").
Parameters
- tags System.String[]
public RuleBuilder WithVisibility(RuleVisibility visibility) #RuleBuilderSets the rule visibility. Hidden rules stay discoverable via explicit names but are omitted from default UI flows.
Parameters
- visibility TestimoX.Definitions.RuleVisibility
- Desired RuleVisibility.
Returns
The same builder.
Inherited Methods
Extension Methods
public static RuleBuilder AddBooleanTest(RuleBuilder builder, String testName, String propertyPath, Boolean expectedValue = true, Importance importance = Moderate) #RuleBuilderCreates a simple pass/fail test.
Parameters
- builder TestimoX.Testing.RuleBuilder
- testName System.String
- propertyPath System.String
- expectedValue System.Boolean = true
- importance TestimoX.Definitions.Importance = Moderate
public static RuleBuilder AddPercentageTest(RuleBuilder builder, String testName, String propertyPath, Double minPercentage, Importance importance = Moderate) #RuleBuilderCreates a percentage test.
Parameters
- builder TestimoX.Testing.RuleBuilder
- testName System.String
- propertyPath System.String
- minPercentage System.Double
- importance TestimoX.Definitions.Importance = Moderate
public static RuleBuilder AddSecurityScoreTest(RuleBuilder builder, String testName, Dictionary<String, Int32> issueWeights, Int32 minimumScore = 70) #RuleBuilderCreates a security score test.
Parameters
- builder TestimoX.Testing.RuleBuilder
- testName System.String
- issueWeights System.Collections.Generic.Dictionary{System.String,System.Int32}
- minimumScore System.Int32 = 70
public static RuleBuilder Exclude(RuleBuilder builder, params String[] keys) #RuleBuilderExcludes items whose String) property equals any of the provided keys.
Parameters
- builder TestimoX.Testing.RuleBuilder
- Rule builder.
- keys System.String[]
- Values to exclude.
Returns
The same builder.
public static RuleBuilder ExpectSourceOutput(RuleBuilder builder, Boolean expectOutput) #RuleBuilderSets whether the source is expected to return data. Use false for "findings-only" rules that legitimately return an empty list when no issues are present (to avoid failing the gate).
Parameters
- builder TestimoX.Testing.RuleBuilder
- expectOutput System.Boolean
public static RuleBuilder FindingsOnly(RuleBuilder builder) #RuleBuilderSemantic alias for Boolean) when a rule returns only findings. Use on rules whose source produces a list of issues; empty list means "good".
Parameters
- builder TestimoX.Testing.RuleBuilder
public static RuleBuilder Include(RuleBuilder builder, params String[] keys) #RuleBuilderIncludes only items whose String) property equals any of the provided keys.
Parameters
- builder TestimoX.Testing.RuleBuilder
- keys System.String[]
public static RuleBuilder MatchOn(RuleBuilder builder, String propertyPath) #RuleBuilderSets the property path that identifies a unique object (used to match inclusions/exclusions).
Parameters
- builder TestimoX.Testing.RuleBuilder
- Rule builder.
- propertyPath System.String
- Property path (e.g., "SamAccountName").
Returns
The same builder.
public static RuleBuilder RequiresComputers(RuleBuilder builder, Action<ComputerDataRequirement> configure) #RuleBuilderDeclares that the rule requires enumerating computer data and allows specifying filters/scope.
Parameters
- builder TestimoX.Testing.RuleBuilder
- Rule builder.
- configure System.Action{TestimoX.Planning.ComputerDataRequirement}
- Callback to configure computer data needs.
Returns
The same builder.
public static RuleBuilder RequiresDataSets(RuleBuilder builder, params DataSetKind[] dataSets) #RuleBuilderDeclares generic dataset requirements to pre-warm once for this run. Prefer this over specialized helpers.
Parameters
- builder TestimoX.Testing.RuleBuilder
- dataSets TestimoX.Planning.DataSetKind[]
public static RuleBuilder RequiresGpo(RuleBuilder builder, Action<GpoDataRequirement> configure) #RuleBuilderDeclares that the rule requires Group Policy data and specifies which caches to warm.
Parameters
- builder TestimoX.Testing.RuleBuilder
- Rule builder.
- configure System.Action{TestimoX.Planning.GpoDataRequirement}
- Callback to configure GPO data needs.
Returns
The same builder.
public static RuleBuilder RequiresGroups(RuleBuilder builder, Action<GroupDataRequirement> configure) #RuleBuilderDeclares that the rule requires enumerating group data and allows specifying filters/scope.
Parameters
- builder TestimoX.Testing.RuleBuilder
- Rule builder.
- configure System.Action{TestimoX.Planning.GroupDataRequirement}
- Callback to configure group data needs.
Returns
The same builder.
public static RuleBuilder RequiresPermissions(RuleBuilder builder, PermissionRequired permission) #RuleBuilderSets the minimal permission level required to execute this rule.
Parameters
- builder TestimoX.Testing.RuleBuilder
- permission TestimoX.Definitions.PermissionRequired
public static RuleBuilder RequiresUsers(RuleBuilder builder, Action<UserDataRequirement> configure) #RuleBuilderDeclares that the rule requires enumerating user data and allows specifying filters/scope.
Parameters
- builder TestimoX.Testing.RuleBuilder
- Rule builder.
- configure System.Action{TestimoX.Planning.UserDataRequirement}
- Callback to configure user data needs.
Returns
The same builder.
public static RuleBuilder WithCrosswalk(RuleBuilder builder, params RuleVendorRef[] refs) #RuleBuilderAttaches inline crosswalk references to vendor baselines or external docs. This makes mappings visible directly in the rule source.
Parameters
- builder TestimoX.Testing.RuleBuilder
- refs TestimoX.Definitions.RuleVendorRef[]
public static RuleBuilder WithCrosswalk(RuleBuilder builder, Action<CrosswalkBuilder> configure) #RuleBuilderParameters
- builder RuleBuilder
- configure Action<CrosswalkBuilder>
public static RuleBuilder WithGuidance(RuleBuilder builder, Action<GuidanceBuilder> configure) #RuleBuilderAdds guidance (summary, investigation, remediation, references, examples) to a rule.
Parameters
- builder TestimoX.Testing.RuleBuilder
- configure System.Action{TestimoX.Testing.RuleBuilderExtensions.GuidanceBuilder}
Examples
var rule = RuleBuilder.Create("DomainGpoAnonymousPermissions")
.DisplayName("GPO – Anonymous Permissions")
.Description("Checks whether anonymous access to directory data is allowed.")
.ForScope(Scope.Domain)
.WithGuidance(g => g
.Summary("Anonymous access should be disabled to reduce information exposure.")
.WhyItMatters("Unauthenticated users may enumerate users, groups, and other objects.")
.HowToFix(
"Set 'Network access: Do not allow anonymous enumeration of SAM accounts and shares' to Enabled.",
"Ensure 'Allow anonymous SID/Name translation' is Disabled.")
.Reference("Security baseline", "https://aka.ms/win-baselines"))
.Build();
public static RuleBuilder WithLinks(RuleBuilder builder, Action<LinkBuilder> configure) #RuleBuilderConfigures related links for the current rule using a LinkBuilder.
Parameters
- builder TestimoX.Testing.RuleBuilder
- Rule builder being configured.
- configure System.Action{TestimoX.Baselines.Crosswalk.LinkBuilder}
- Delegate that adds links via LinkBuilder.
Returns
The same RuleBuilder for chaining.