AgentTestHost.Create(Action<IHostApplicationBuilder>) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates and starts a new AgentTestHost.
public static Microsoft.Agents.Builder.Testing.AgentTestHost Create(Action<Microsoft.Extensions.Hosting.IHostApplicationBuilder> configure);
static member Create : Action<Microsoft.Extensions.Hosting.IHostApplicationBuilder> -> Microsoft.Agents.Builder.Testing.AgentTestHost
Public Shared Function Create (configure As Action(Of IHostApplicationBuilder)) As AgentTestHost
Parameters
- configure
- Action<IHostApplicationBuilder>
Callback to configure services and options — same style as production Program.cs.
At minimum, register IAgent as transient:
builder.Services.AddTransient<IAgent, MyAgent>();
Do not use AddScoped for IAgent or its dependencies; the host resolves
agents from the root scope, and scoped services captured there will not be disposed
between test turns.
Returns
A started AgentTestHost. Dispose when the test is done.