How to use Automoqer with autofac

267 Views Asked by At

I'm trying to resolve a concrete class having a container with autofac

My setup is something like this

[TestInitialize]
public void Setup()
{
    _automoqer = new AutoMoqer();
    _distributeProcessSink = _automoqer.Resolve<DistributedSaveHistorySink>();
}

and my concrete class looks like this

private readonly Func<string, IConsolidationContext, IConsolidationStore> _consolidationStoreFactory;

public DistributedSaveHistorySink(Func<string, IConsolidationContext, IConsolidationStore> consolidationStoreFactory)
{
    _consolidationStoreFactory = consolidationStoreFactory;
}

Initialization method xx threw exception.

Microsoft.Practices.Unity.ResolutionFailedException: 
Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency
failed, type = "xx.DistributedSaveHistorySink", name = "(none)".
Exception occurred while: while resolving.
Exception is: TargetInvocationException - Exception has been thrown by the target
of an invocation.

also my container configuration looks like this

builder.RegisterType<DistributedSaveHistorySink>()
       .Keyed<IProcessSink<MergeMessage>>(PipelineType.Default)
       .PropertiesAutowired();
0

There are 0 best solutions below