You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using AutoMock, it's possible to build the underlying container that is used to resolve dependencies. This is useful if a test requires a few specific dependencies are fulfilled by the actual implementations, for example.
I've run into a problem when using this pattern: registered decorators seem to be ignored.
Instead of my registered decorator getting injected, a new new mock is automatically created and used instead.
In code, this does not work as expected:
var autoMock = AutoMock.GetLoose(builder =>
{
builder.RegisterType<Service>().Named<IService>("uncached");
builder.RegisterDecorator<IService>(
(ctx, inner) => new CachingService(inner), "uncached");
});
When using AutoMock, it's possible to build the underlying container that is used to resolve dependencies. This is useful if a test requires a few specific dependencies are fulfilled by the actual implementations, for example.
I've run into a problem when using this pattern: registered decorators seem to be ignored.
Instead of my registered decorator getting injected, a new new mock is automatically created and used instead.
In code, this does not work as expected:
By comparison, this workaround does the job:
I may take a look myself as to the cause of this, but I can't make any promises 😄
Used versions
Reproduction
I've added a test that demonstrates the problem in this fork:
https://github.com/Thorarin/Autofac.Extras.Moq/tree/feat/decorators
The text was updated successfully, but these errors were encountered: