Skip to content

Commit

Permalink
Clarified multi-service decoration tests in light of #963.
Browse files Browse the repository at this point in the history
  • Loading branch information
tillig committed Mar 9, 2019
1 parent c3a9040 commit 791d9bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion test/Autofac.Test/Features/Decorators/DecoratorTests.cs
Expand Up @@ -193,7 +193,10 @@ public void DecoratedRegistrationCanIncludeImplementationType()
public void DecoratedRegistrationCanIncludeOtherServices()
{
var builder = new ContainerBuilder();
builder.RegisterType<ImplementorA>().As<IDecoratedService>().As<IService>();

// #963: The SingleInstance here is important - a single component may expose multiple services.
// If that component is decorated, the decorator ALSO needs to expose all of those services.
builder.RegisterType<ImplementorA>().As<IDecoratedService>().As<IService>().SingleInstance();
builder.RegisterDecorator<DecoratorA, IDecoratedService>();
var container = builder.Build();

Expand Down
Expand Up @@ -190,7 +190,10 @@ public void DecoratedRegistrationCanIncludeImplementationType()
public void DecoratedRegistrationCanIncludeOtherServices()
{
var builder = new ContainerBuilder();
builder.RegisterGeneric(typeof(ImplementorA<>)).As(typeof(IDecoratedService<>)).As(typeof(IService<>));

// #963: The SingleInstance here is important - a single component may expose multiple services.
// If that component is decorated, the decorator ALSO needs to expose all of those services.
builder.RegisterGeneric(typeof(ImplementorA<>)).As(typeof(IDecoratedService<>)).As(typeof(IService<>)).SingleInstance();
builder.RegisterGenericDecorator(typeof(DecoratorA<>), typeof(IDecoratedService<>));
var container = builder.Build();

Expand Down

0 comments on commit 791d9bc

Please sign in to comment.