< Summary

Information
Class: Intentum.Testing.TestHelpers
Assembly: Intentum.Testing
File(s): /home/runner/work/Intentum/Intentum/src/Intentum.Testing/TestHelpers.cs
Line coverage
97%
Covered lines: 37
Uncovered lines: 1
Coverable lines: 38
Total lines: 86
Line coverage: 97.3%
Branch coverage
66%
Covered branches: 4
Total branches: 6
Branch coverage: 66.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
CreateDefaultModel()100%11100%
CreateModel(...)100%11100%
CreateDefaultPolicy()50%4487.5%
CreateSpaceBuilder()100%11100%
CreateSimpleSpace()100%11100%
CreateSpaceWithRetries(...)100%22100%

File(s)

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

#LineLine coverage
 1using Intentum.AI.Embeddings;
 2using Intentum.AI.Mock;
 3using Intentum.AI.Models;
 4using Intentum.AI.Similarity;
 5using Intentum.Core.Behavior;
 6using Intentum.Runtime.Policy;
 7
 8namespace Intentum.Testing;
 9
 10/// <summary>
 11/// Test helpers for creating common test objects.
 12/// </summary>
 13public static class TestHelpers
 14{
 15    /// <summary>
 16    /// Creates a default LlmIntentModel with MockEmbeddingProvider and SimpleAverageSimilarityEngine.
 17    /// </summary>
 18    public static LlmIntentModel CreateDefaultModel()
 719    {
 720        return new LlmIntentModel(
 721            new MockEmbeddingProvider(),
 722            new SimpleAverageSimilarityEngine());
 723    }
 24
 25    /// <summary>
 26    /// Creates a LlmIntentModel with custom embedding provider and similarity engine.
 27    /// </summary>
 28    public static LlmIntentModel CreateModel(
 29        IIntentEmbeddingProvider embeddingProvider,
 30        IIntentSimilarityEngine similarityEngine)
 131    {
 132        return new LlmIntentModel(embeddingProvider, similarityEngine);
 133    }
 34
 35    /// <summary>
 36    /// Creates a default IntentPolicy with common rules.
 37    /// </summary>
 38    public static IntentPolicy CreateDefaultPolicy()
 539    {
 540        return new IntentPolicyBuilder()
 1641            .Block("ExcessiveRetryBlock", i => i.Signals.Count(s => s.Description.Contains("retry", StringComparison.Ord
 542            .Allow("HighConfidenceAllow", i => i.Confidence.Level is "High" or "Certain")
 543            .Observe("MediumConfidenceObserve", i => i.Confidence.Level == "Medium")
 044            .Warn("LowConfidenceWarn", i => i.Confidence.Level == "Low")
 545            .Build();
 546    }
 47
 48    /// <summary>
 49    /// Creates a BehaviorSpaceBuilder for fluent test setup.
 50    /// </summary>
 51    public static BehaviorSpaceBuilder CreateSpaceBuilder()
 152    {
 153        return new BehaviorSpaceBuilder();
 154    }
 55
 56    /// <summary>
 57    /// Creates a simple behavior space with login and submit actions.
 58    /// </summary>
 59    public static BehaviorSpace CreateSimpleSpace()
 2860    {
 2861        return new BehaviorSpaceBuilder()
 2862            .WithActor("user")
 2863                .Action("login")
 2864                .Action("submit")
 2865            .Build();
 2866    }
 67
 68    /// <summary>
 69    /// Creates a behavior space with retries.
 70    /// </summary>
 71    public static BehaviorSpace CreateSpaceWithRetries(int retryCount = 2)
 272    {
 273        var builder = new BehaviorSpaceBuilder()
 274            .WithActor("user")
 275                .Action("login");
 76
 1277        for (int i = 0; i < retryCount; i++)
 478        {
 479            builder.Action("retry");
 480        }
 81
 282        return builder
 283            .Action("submit")
 284            .Build();
 285    }
 86}