diff --git a/test/Autofac.Specification.Test/Features/DecoratorTests.cs b/test/Autofac.Specification.Test/Features/DecoratorTests.cs index 9a27cf248..5859dcc35 100644 --- a/test/Autofac.Specification.Test/Features/DecoratorTests.cs +++ b/test/Autofac.Specification.Test/Features/DecoratorTests.cs @@ -259,6 +259,24 @@ public void DecoratorAndDecoratedBothDisposedWhenSingleInstance() Assert.Equal(1, decorated.DisposeCallCount); } + [Fact(Skip = "Issue #963: Need to figure out how to track which decorators have already been applied.")] + public void DecoratorAppliedOnlyOnceToComponent() + { + // #965: A nested lifetime scope that has a registration lambda + // causes the decorator to be applied twice - once for the container + // level, once for the scope level. This doesn't seem to happen + // if there's no registration lambda. + var builder = new ContainerBuilder(); + builder.RegisterType().As(); + builder.RegisterDecorator(); + var container = builder.Build(); + + var scope = container.BeginLifetimeScope(b => { }); + var service = scope.Resolve(); + Assert.IsType(service); + Assert.IsType(service.Decorated); + } + [Fact] public void DecoratorCanBeAppliedToServiceRegisteredInChildLifetimeScope() {