AgentPrismTestHost
AgentPrism.Testing.dllIn-memory AgentPrism host.
public sealed class AgentPrismTestHost : IAsyncDisposableInheritance
Section titled “Inheritance”Implements
Section titled “Implements”Inherited Members
Section titled “Inherited Members”object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”Built on WebApplication.CreateSlimBuilder + UseTestServer;
Microsoft.AspNetCore.Mvc.Testing’s WebApplicationFactory<T>
is not used, because it requires an entry-point assembly and locks the
consumer into a hosting model. In-memory stores are a first-class
implementation, so the host needs no database.
AIFunctionArguments.Services is empty in the MAF pipeline: a
dependency your own tool needs is not resolved from DI. Take
the dependency in the tool’s CONSTRUCTOR and register it through a factory
with services.AddSingleton(provider => new AgentPrismToolRegistration(new MyTool(provider), ...)).
Properties
Section titled “Properties”Client
Section titled “ Client”HTTP client bound to the host.
public HttpClient Client { get; }Property Value
Section titled “Property Value”Services
Section titled “ Services”The host’s service provider.
public IServiceProvider Services { get; }Property Value
Section titled “Property Value”Methods
Section titled “Methods”DisposeAsync()
Section titled “ DisposeAsync()”public ValueTask DisposeAsync()Returns
Section titled “Returns”RunAsync(string, string, CancellationToken)
Section titled “ RunAsync(string, string, CancellationToken)”Runs an agent, drains the stream to completion, and returns its record.
public ValueTask<RunAssertions> RunAsync(string agentName, string message, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”agentName string
The name of the agent to run.
message string
The user message.
cancellationToken CancellationToken
Cancellation token.
Returns
Section titled “Returns”An object for building assertions on the run.
Exceptions
Section titled “Exceptions”The run was not accepted, or its record was not found in the store.
StartAsync(Action<AgentPrismTestHostOptions>?, CancellationToken)
Section titled “ StartAsync(Action<AgentPrismTestHostOptions>?, CancellationToken)”Builds and starts a host.
public static ValueTask<AgentPrismTestHost> StartAsync(Action<AgentPrismTestHostOptions>? configure = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”configure Action<AgentPrismTestHostOptions>?
Changes the host settings.
cancellationToken CancellationToken
Cancellation token.
Returns
Section titled “Returns”The running host.