Hello
I'm trying to inject WireMockServer instance via module:
public class WireMockServerModule : Module {
protected override void Load(ContainerBuilder builder) {
builder.Register(c =>WireMockServer.Start()) // WireMockServer.Start() returns WireMockServer type, which implements IWireMockServer interface
.As<IWireMockServer>()
.AsSelf()
.SingleInstance();
}
}
public class MyClientTestFixture : INeedModule<WireMockServerModule> {
}
[UseAutofacTestFramework]
public class MyClientTest : IClassFixture<MyClientTestFixture> {
private readonly WireMockServer _server;
public MyClientTest ( WireMockServer server) {
_server = server;
}
}
This fails with
Autofac.Core.Activators.Reflection.NoConstructorsFoundException
No accessible constructors were found for the type 'WireMock.Server.WireMockServer'.
at Autofac.Core.Activators.Reflection.DefaultConstructorFinder.GetDefaultPublicConstructors(Type type)
at Autofac.Core.Activators.Reflection.DefaultConstructorFinder.FindConstructors(Type targetType)
at Autofac.Core.Activators.Reflection.ReflectionActivator.ConfigurePipeline(IComponentRegistryServices componentRegistryServices, IResolvePipelineBuilder pipelineBuilder)
at Autofac.Core.Registration.ComponentRegistration.BuildResolvePipeline(IComponentRegistryServices registryServices, IResolvePipelineBuilder pipelineBuilder)
at Autofac.Core.Registration.ComponentRegistration.BuildResolvePipeline(IComponentRegistryServices registryServices)
at Autofac.Core.Registration.DefaultRegisteredServicesTracker.AddRegistration(IComponentRegistration registration, Boolean preserveDefaults, Boolean originatedFromDynamicSource)
(WireMockServerModule::Load is invoked, but not the callback itself)
However, when I depend on IWireMockServer, it works as expected
Hello I'm trying to inject
WireMockServer
instance via module:This fails with
(
WireMockServerModule::Load
is invoked, but not the callback itself)However, when I depend on
IWireMockServer
, it works as expectedand both
WireMockServerModule::Load
and callback are invoked. Please advise.