From f5746dc33c4957f7444254147dc8744e17daa7cc Mon Sep 17 00:00:00 2001 From: Travis Illig Date: Tue, 19 Mar 2019 14:48:48 -0700 Subject: [PATCH] Added skipped/failing test for #963. --- .../Features/DecoratorTests.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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() {