< Summary

Information
Class: Intentum.Testing.StubIntentModel
Assembly: Intentum.Testing
File(s): /home/runner/work/Intentum/Intentum/src/Intentum.Testing/StubIntentModel.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 10
Coverable lines: 10
Total lines: 36
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%110%
.ctor(...)0%220%
Infer(...)100%110%

File(s)

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

#LineLine coverage
 1using Intentum.Core.Behavior;
 2using Intentum.Core.Contracts;
 3using Intentum.Core.Intents;
 4
 5namespace Intentum.Testing;
 6
 7/// <summary>
 8/// Stub implementation of <see cref="IIntentModel"/> for unit tests.
 9/// Returns a configurable intent (name, confidence, reasoning) for any input.
 10/// Use when testing policy, chaining, or pipeline without a real model.
 11/// </summary>
 12public sealed class StubIntentModel : IIntentModel
 13{
 14    private readonly Func<BehaviorSpace, Intent> _infer;
 15
 16    /// <summary>
 17    /// Creates a stub that always returns the same intent.
 18    /// </summary>
 019    public StubIntentModel(string intentName, double confidenceScore = 0.8, string? reasoning = null)
 020    {
 021        var confidence = IntentConfidence.FromScore(confidenceScore);
 022        _infer = _ => new Intent(intentName, [], confidence, reasoning);
 023    }
 24
 25    /// <summary>
 26    /// Creates a stub that uses a custom function to produce intent from behavior space.
 27    /// </summary>
 028    public StubIntentModel(Func<BehaviorSpace, Intent> infer)
 029    {
 030        _infer = infer ?? throw new ArgumentNullException(nameof(infer));
 031    }
 32
 33    /// <inheritdoc />
 34    public Intent Infer(BehaviorSpace behaviorSpace, BehaviorVector? precomputedVector = null)
 035        => _infer(behaviorSpace);
 36}