In my Startup
class I a have method for RegisterAssemblyTypes
through autofac as the following:
public class Startup
{
public void ConfigureContainer(ContainerBuilder builder)
{
builder.RegisterModule(new ApplicationModule());
}
}
public class ApplicationModule : Autofac.Module
{
protected override void Load(ContainerBuilder builder)
{
builder
.RegisterAssemblyTypes(
typeof(EventHandler).GetTypeInfo().Assembly)
.AsClosedTypesOf(typeof(IIntegrationEventHandler<>));
}
}
What is the suggested way of registering assemblies using Autofac
(e.g., RegisterAssemblyTypes
) when the Startup
class is called from integration tests; e.g.,
public class IntegrationTestApplicationFactory : WebApplicationFactory<Startup>
{ }
I am using Autofac 4.9.4.
Question:
how do you register an assembly type in WebApplicationFactory<Startup>
using Autofac
?
Due to incomplete documentation and a very poor support from
Autofac
maintainers, we decided to revertAutofac
usage throughout all the projects in our institute.Now we use ASP.NET Core's built-in registration, which works as expected when called in either of the following methods: