Class ProtoTestHost
- Namespace
- ProtoTest.AspNetCore
- Assembly
- ProtoTest.AspNetCore.dll
The low-ceremony composition for a suite whose subject is one ASP.NET Core application: register it in-process under the default application name, and compose its protocol registrations on the same call.
public static class ProtoTestHost
- Inheritance
-
ProtoTestHost
- Inherited Members
Examples
protected override void Configure(IProtoHostBuilder builder) => ProtoTestHost.For<Program>(builder);
// or with the application's clients declared in the same line:
protected override void Configure(IProtoHostBuilder builder) => ProtoTestHost.For<Program>(
builder,
configure: app => app.AddRest(rest => rest.AddClient()));
Fields
DefaultApplicationName
The application name For<TProgram>(IProtoHostBuilder, string, Action<IProtoApplicationBuilder>?) registers when the caller names none.
public const string DefaultApplicationName = "Api"
Field Value
Methods
For<TProgram>(IProtoHostBuilder, string, Action<IProtoApplicationBuilder>?)
Registers TProgram as the suite's application, hosted in-process, exactly
like AddApplication(applicationName, app => app.AddAspNetCoreServer<TProgram>())
with DefaultApplicationName when no name is given. The callback composes the
application's protocol registrations - its REST, GraphQL or gRPC clients - after the server.
public static IProtoHostBuilder For<TProgram>(IProtoHostBuilder builder, string applicationName = "Api", Action<IProtoApplicationBuilder>? configure = null) where TProgram : class
Parameters
builderIProtoHostBuilderThe host builder to compose.
applicationNamestringThe application name; defaults to DefaultApplicationName.
configureAction<IProtoApplicationBuilder>Optional application registrations, such as
app.AddRest(rest => rest.AddClient()).
Returns
- IProtoHostBuilder
The same host builder, so further composition chains.
Type Parameters
TProgramThe entry point class of the ASP.NET Core application under test.