< Summary

Information
Class: Intentum.Testing.IntentAssertions
Assembly: Intentum.Testing
File(s): /home/runner/work/Intentum/Intentum/src/Intentum.Testing/BehaviorSpaceAssertions.cs
Line coverage
100%
Covered lines: 15
Uncovered lines: 0
Coverable lines: 15
Total lines: 131
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
HasConfidenceLevel(...)100%11100%
HasConfidenceScore(...)100%11100%
HasSignals(...)100%11100%
HasSignalCount(...)100%11100%
ContainsSignal(...)100%11100%

File(s)

/home/runner/work/Intentum/Intentum/src/Intentum.Testing/BehaviorSpaceAssertions.cs

#LineLine coverage
 1using Intentum.Core.Behavior;
 2using Intentum.Core.Intents;
 3using Intentum.Runtime.Policy;
 4using Xunit;
 5
 6namespace Intentum.Testing;
 7
 8/// <summary>
 9/// Assertion helpers for BehaviorSpace testing.
 10/// </summary>
 11public static class BehaviorSpaceAssertions
 12{
 13    /// <summary>
 14    /// Asserts that the behavior space contains a specific event.
 15    /// </summary>
 16    public static void ContainsEvent(
 17        BehaviorSpace space,
 18        string actor,
 19        string action)
 20    {
 21        Assert.Contains(space.Events, e => { _ = e; return e.Actor == actor && e.Action == action; });
 22    }
 23
 24    /// <summary>
 25    /// Asserts that the behavior space contains a specific number of events.
 26    /// </summary>
 27    public static void HasEventCount(BehaviorSpace space, int expectedCount)
 28    {
 29        Assert.Equal(expectedCount, space.Events.Count);
 30    }
 31
 32    /// <summary>
 33    /// Asserts that the behavior space contains events for a specific actor.
 34    /// </summary>
 35    public static void ContainsActor(BehaviorSpace space, string actor)
 36    {
 37        Assert.Contains(space.Events, e => { _ = e; return e.Actor == actor; });
 38    }
 39
 40    /// <summary>
 41    /// Asserts that the behavior space contains a specific action.
 42    /// </summary>
 43    public static void ContainsAction(BehaviorSpace space, string action)
 44    {
 45        Assert.Contains(space.Events, e => { _ = e; return e.Action == action; });
 46    }
 47}
 48
 49/// <summary>
 50/// Assertion helpers for Intent testing.
 51/// </summary>
 52public static class IntentAssertions
 53{
 54    /// <summary>
 55    /// Asserts that the intent has a specific confidence level.
 56    /// </summary>
 57    public static void HasConfidenceLevel(Intent intent, string expectedLevel)
 158    {
 159        Assert.Equal(expectedLevel, intent.Confidence.Level);
 160    }
 61
 62    /// <summary>
 63    /// Asserts that the intent has a confidence score within a range.
 64    /// </summary>
 65    public static void HasConfidenceScore(Intent intent, double minScore, double maxScore)
 166    {
 167        Assert.InRange(intent.Confidence.Score, minScore, maxScore);
 168    }
 69
 70    /// <summary>
 71    /// Asserts that the intent has at least one signal.
 72    /// </summary>
 73    public static void HasSignals(Intent intent)
 174    {
 175        Assert.NotEmpty(intent.Signals);
 176    }
 77
 78    /// <summary>
 79    /// Asserts that the intent has a specific number of signals.
 80    /// </summary>
 81    public static void HasSignalCount(Intent intent, int expectedCount)
 182    {
 183        Assert.Equal(expectedCount, intent.Signals.Count);
 184    }
 85
 86    /// <summary>
 87    /// Asserts that the intent contains a signal with a specific description.
 88    /// </summary>
 89    public static void ContainsSignal(Intent intent, string description)
 190    {
 291        Assert.Contains(intent.Signals, s => s.Description.Contains(description, StringComparison.OrdinalIgnoreCase));
 192    }
 93}
 94
 95/// <summary>
 96/// Assertion helpers for PolicyDecision testing.
 97/// </summary>
 98public static class PolicyDecisionAssertions
 99{
 100    /// <summary>
 101    /// Asserts that the decision is one of the allowed values.
 102    /// </summary>
 103    public static void IsOneOf(PolicyDecision decision, params PolicyDecision[] allowedDecisions)
 104    {
 105        Assert.Contains(decision, allowedDecisions);
 106    }
 107
 108    /// <summary>
 109    /// Asserts that the decision is Allow.
 110    /// </summary>
 111    public static void IsAllow(PolicyDecision decision)
 112    {
 113        Assert.Equal(PolicyDecision.Allow, decision);
 114    }
 115
 116    /// <summary>
 117    /// Asserts that the decision is Block.
 118    /// </summary>
 119    public static void IsBlock(PolicyDecision decision)
 120    {
 121        Assert.Equal(PolicyDecision.Block, decision);
 122    }
 123
 124    /// <summary>
 125    /// Asserts that the decision is not Block.
 126    /// </summary>
 127    public static void IsNotBlock(PolicyDecision decision)
 128    {
 129        Assert.NotEqual(PolicyDecision.Block, decision);
 130    }
 131}