TestimoX

API Reference

Class

RuleBuilder

Namespace TestimoX.Testing
Assembly TestimoX

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 requiredposition: 0
Technical rule name (unique within the engine).

Methods

public RuleBuilder AddCountTest(String testName, String propertyPath, Int32 expectedCount, Importance importance = Moderate) #
Returns: RuleBuilder

Adds a count test.

Parameters

testName System.String requiredposition: 0
Display name of the test.
propertyPath System.String requiredposition: 1
Collection property path or "$" for the root list.
expectedCount System.Int32 requiredposition: 2
Expected number of items.
importance TestimoX.Definitions.Importance = Moderate optionalposition: 3
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) #
Returns: RuleBuilder

Adds a complex test with custom logic.

Parameters

testName System.String requiredposition: 0
predicate System.Func{System.Object,System.Boolean} requiredposition: 1
importance TestimoX.Definitions.Importance = Moderate optionalposition: 2
description System.String = null optionalposition: 3
public RuleBuilder AddNotEmptyTest(String testName, String propertyPath, Importance importance = Moderate) #
Returns: RuleBuilder

Adds an empty check test.

Parameters

testName System.String requiredposition: 0
propertyPath System.String requiredposition: 1
importance TestimoX.Definitions.Importance = Moderate optionalposition: 2
public RuleBuilder AddNotNullTest(String testName, String propertyPath, Importance importance = High) #
Returns: RuleBuilder

Adds a null check test.

Parameters

testName System.String requiredposition: 0
propertyPath System.String requiredposition: 1
importance TestimoX.Definitions.Importance = High optionalposition: 2
public RuleBuilder AddPropertyTest(String testName, String propertyPath, Object expectedValue, Importance importance = Moderate) #
Returns: RuleBuilder

Adds a simple property test.

Parameters

testName System.String requiredposition: 0
Display name of the test.
propertyPath System.String requiredposition: 1
JSON-like property path within a result object.
expectedValue System.Object requiredposition: 2
Expected property value.
importance TestimoX.Definitions.Importance = Moderate optionalposition: 3
Importance/severity if the test fails.

Returns

The same builder.

public RuleBuilder AddRangeTest(String testName, String propertyPath, IComparable min, IComparable max, Importance importance = Moderate) #
Returns: RuleBuilder

Adds a range test.

Parameters

testName System.String requiredposition: 0
Display name of the test.
propertyPath System.String requiredposition: 1
Numeric/date property path.
min System.IComparable requiredposition: 2
Inclusive minimum value.
max System.IComparable requiredposition: 3
Inclusive maximum value.
importance TestimoX.Definitions.Importance = Moderate optionalposition: 4
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) #
Returns: RuleBuilder

Adds a risk score test.

Parameters

testName System.String requiredposition: 0
calculateRisk System.Func{System.Object,TestimoX.Testing.RiskScore} requiredposition: 1
minimumScore System.Int32 = 70 optionalposition: 2
importance TestimoX.Definitions.Importance = High optionalposition: 3
public RuleBuilder AddTest(Action<TestBuilder> configureTest) #
Returns: RuleBuilder

Adds a test using the TestBuilder.

Parameters

configureTest System.Action{TestimoX.Testing.TestBuilder} requiredposition: 0
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) #
Returns: RuleBuilder

Adds a threshold test.

Parameters

testName System.String requiredposition: 0
Display name of the test.
propertyPath System.String requiredposition: 1
Numeric/date property path.
threshold System.IComparable requiredposition: 2
Threshold to compare against.
shouldBeGreater System.Boolean = true optionalposition: 3
When true, expects property ≥ threshold; otherwise ≤ threshold.
importance TestimoX.Definitions.Importance = Moderate optionalposition: 4
Importance/severity if the test fails.

Returns

The same builder.

public Rule Build() #
Returns: Rule

Builds the rule.

public static RuleBuilder Create(String name) #
Returns: RuleBuilder

Creates a new rule builder.

Parameters

name System.String requiredposition: 0
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() #
Returns: RuleBuilder

Marks this rule as deprecated (kept for compatibility). UIs may surface this tag.

Returns

The same builder.

public RuleBuilder Description(String description) #
Returns: RuleBuilder

Sets the rule description (supports markdown).

Parameters

description System.String requiredposition: 0
Rule description (markdown supported).

Returns

The same builder.

public RuleBuilder DisplayName(String displayName) #
Returns: RuleBuilder

Sets the display name.

Parameters

displayName System.String requiredposition: 0
Human‑friendly rule title.

Returns

The same builder for chaining.

public RuleBuilder Enabled(Boolean enabled = true) #
Returns: RuleBuilder

Sets whether the rule is enabled.

Parameters

enabled System.Boolean = true optionalposition: 0
Whether the rule is enabled by default.

Returns

The same builder.

public RuleBuilder ForScope(Scope scope) #
Returns: RuleBuilder

Sets the rule scope.

Parameters

scope TestimoX.Definitions.Scope requiredposition: 0
Scope at which the rule executes.

Returns

The same builder.

public RuleBuilder Hidden(Boolean hidden = true) #
Returns: RuleBuilder

Convenience helper to mark a rule as hidden or visible.

Parameters

hidden System.Boolean = true optionalposition: 0
True to hide the rule from standard selectors.

Returns

The same builder.

public RuleBuilder InCategories(params Category[] categories) #
Returns: RuleBuilder

Sets the rule categories.

Parameters

categories TestimoX.Definitions.Category[] requiredposition: 0
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 required
public RuleBuilder WithCost(RuleCost cost) #
Returns: RuleBuilder

Sets a rough execution cost hint to help filter heavy rules.

Parameters

cost TestimoX.Definitions.RuleCost requiredposition: 0
public RuleBuilder WithParameter(String key, Object value) #
Returns: RuleBuilder

Adds source parameters.

Parameters

key System.String requiredposition: 0
Parameter key passed to the rule source.
value System.Object requiredposition: 1
Parameter value.

Returns

The same builder.

public RuleBuilder WithParameters(IDictionary<String, Object> parameters) #
Returns: RuleBuilder

Adds multiple source parameters.

Parameters

parameters System.Collections.Generic.IDictionary{System.String,System.Object} requiredposition: 0
Key/value parameter pairs.

Returns

The same builder.

public RuleBuilder WithReport(Action<ReportViewBuilder> configure) #
Returns: RuleBuilder

Configures report rendering hints (summary fields, sections, highlights) for this rule.

Parameters

configure System.Action{TestimoX.Testing.ReportViewBuilder} requiredposition: 0
Callback that uses ReportViewBuilder to shape output.
public RuleBuilder WithScoreKind(ScoreKind kind) #
Returns: RuleBuilder

Sets the default scoring domain for this rule. Individual tests can override with TestBuilder.WithScoreKind.

Parameters

kind TestimoX.Definitions.ScoreKind requiredposition: 0
WithSource 4 overloads
public RuleBuilder WithSource<TService>(Func<TService, IDictionary<String, Object>, Task<IEnumerable<Object>>> serviceMethod) #
Returns: RuleBuilder

Sets 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}}} requiredposition: 0
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}}} required
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}} required
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}} required
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}}} required
Async method on TService that returns result objects.

Returns

The same builder.

public RuleBuilder WithTags(params String[] tags) #
Returns: RuleBuilder

Adds free-form tags to the rule (e.g., "laps", "acl", "heavy").

Parameters

tags System.String[] requiredposition: 0
public RuleBuilder WithVisibility(RuleVisibility visibility) #
Returns: RuleBuilder

Sets the rule visibility. Hidden rules stay discoverable via explicit names but are omitted from default UI flows.

Parameters

visibility TestimoX.Definitions.RuleVisibility requiredposition: 0
Desired RuleVisibility.

Returns

The same builder.

Extension Methods

public static RuleBuilder AddBooleanTest(RuleBuilder builder, String testName, String propertyPath, Boolean expectedValue = true, Importance importance = Moderate) #
Returns: RuleBuilder

Creates a simple pass/fail test.

Parameters

builder TestimoX.Testing.RuleBuilder requiredposition: 0
testName System.String requiredposition: 1
propertyPath System.String requiredposition: 2
expectedValue System.Boolean = true optionalposition: 3
importance TestimoX.Definitions.Importance = Moderate optionalposition: 4
public static RuleBuilder AddPercentageTest(RuleBuilder builder, String testName, String propertyPath, Double minPercentage, Importance importance = Moderate) #
Returns: RuleBuilder

Creates a percentage test.

Parameters

builder TestimoX.Testing.RuleBuilder requiredposition: 0
testName System.String requiredposition: 1
propertyPath System.String requiredposition: 2
minPercentage System.Double requiredposition: 3
importance TestimoX.Definitions.Importance = Moderate optionalposition: 4
public static RuleBuilder AddSecurityScoreTest(RuleBuilder builder, String testName, Dictionary<String, Int32> issueWeights, Int32 minimumScore = 70) #
Returns: RuleBuilder

Creates a security score test.

Parameters

builder TestimoX.Testing.RuleBuilder requiredposition: 0
testName System.String requiredposition: 1
issueWeights System.Collections.Generic.Dictionary{System.String,System.Int32} requiredposition: 2
minimumScore System.Int32 = 70 optionalposition: 3
public static RuleBuilder Exclude(RuleBuilder builder, params String[] keys) #
Returns: RuleBuilder

Excludes items whose String) property equals any of the provided keys.

Parameters

builder TestimoX.Testing.RuleBuilder requiredposition: 0
Rule builder.
keys System.String[] requiredposition: 1
Values to exclude.

Returns

The same builder.

public static RuleBuilder ExpectSourceOutput(RuleBuilder builder, Boolean expectOutput) #
Returns: RuleBuilder

Sets 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 requiredposition: 0
expectOutput System.Boolean requiredposition: 1
public static RuleBuilder FindingsOnly(RuleBuilder builder) #
Returns: RuleBuilder

Semantic 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 requiredposition: 0
public static RuleBuilder Include(RuleBuilder builder, params String[] keys) #
Returns: RuleBuilder

Includes only items whose String) property equals any of the provided keys.

Parameters

builder TestimoX.Testing.RuleBuilder requiredposition: 0
keys System.String[] requiredposition: 1
public static RuleBuilder MatchOn(RuleBuilder builder, String propertyPath) #
Returns: RuleBuilder

Sets the property path that identifies a unique object (used to match inclusions/exclusions).

Parameters

builder TestimoX.Testing.RuleBuilder requiredposition: 0
Rule builder.
propertyPath System.String requiredposition: 1
Property path (e.g., "SamAccountName").

Returns

The same builder.

public static RuleBuilder RequiresComputers(RuleBuilder builder, Action<ComputerDataRequirement> configure) #
Returns: RuleBuilder

Declares that the rule requires enumerating computer data and allows specifying filters/scope.

Parameters

builder TestimoX.Testing.RuleBuilder requiredposition: 0
Rule builder.
configure System.Action{TestimoX.Planning.ComputerDataRequirement} requiredposition: 1
Callback to configure computer data needs.

Returns

The same builder.

public static RuleBuilder RequiresDataSets(RuleBuilder builder, params DataSetKind[] dataSets) #
Returns: RuleBuilder

Declares generic dataset requirements to pre-warm once for this run. Prefer this over specialized helpers.

Parameters

builder TestimoX.Testing.RuleBuilder requiredposition: 0
dataSets TestimoX.Planning.DataSetKind[] requiredposition: 1
public static RuleBuilder RequiresGpo(RuleBuilder builder, Action<GpoDataRequirement> configure) #
Returns: RuleBuilder

Declares that the rule requires Group Policy data and specifies which caches to warm.

Parameters

builder TestimoX.Testing.RuleBuilder requiredposition: 0
Rule builder.
configure System.Action{TestimoX.Planning.GpoDataRequirement} requiredposition: 1
Callback to configure GPO data needs.

Returns

The same builder.

public static RuleBuilder RequiresGroups(RuleBuilder builder, Action<GroupDataRequirement> configure) #
Returns: RuleBuilder

Declares that the rule requires enumerating group data and allows specifying filters/scope.

Parameters

builder TestimoX.Testing.RuleBuilder requiredposition: 0
Rule builder.
configure System.Action{TestimoX.Planning.GroupDataRequirement} requiredposition: 1
Callback to configure group data needs.

Returns

The same builder.

public static RuleBuilder RequiresPermissions(RuleBuilder builder, PermissionRequired permission) #
Returns: RuleBuilder

Sets the minimal permission level required to execute this rule.

Parameters

builder TestimoX.Testing.RuleBuilder requiredposition: 0
permission TestimoX.Definitions.PermissionRequired requiredposition: 1
public static RuleBuilder RequiresUsers(RuleBuilder builder, Action<UserDataRequirement> configure) #
Returns: RuleBuilder

Declares that the rule requires enumerating user data and allows specifying filters/scope.

Parameters

builder TestimoX.Testing.RuleBuilder requiredposition: 0
Rule builder.
configure System.Action{TestimoX.Planning.UserDataRequirement} requiredposition: 1
Callback to configure user data needs.

Returns

The same builder.

WithCrosswalk 2 overloads
public static RuleBuilder WithCrosswalk(RuleBuilder builder, params RuleVendorRef[] refs) #
Returns: RuleBuilder

Attaches inline crosswalk references to vendor baselines or external docs. This makes mappings visible directly in the rule source.

Parameters

builder TestimoX.Testing.RuleBuilder requiredposition: 0
refs TestimoX.Definitions.RuleVendorRef[] requiredposition: 1
public static RuleBuilder WithCrosswalk(RuleBuilder builder, Action<CrosswalkBuilder> configure) #
Returns: RuleBuilder

Parameters

builder RuleBuilder requiredposition: 0
configure Action<CrosswalkBuilder> requiredposition: 1
public static RuleBuilder WithGuidance(RuleBuilder builder, Action<GuidanceBuilder> configure) #
Returns: RuleBuilder

Adds guidance (summary, investigation, remediation, references, examples) to a rule.

Parameters

builder TestimoX.Testing.RuleBuilder requiredposition: 0
configure System.Action{TestimoX.Testing.RuleBuilderExtensions.GuidanceBuilder} requiredposition: 1

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();