From 8ea04f0a15fa3de72011ef080b841271e561f688 Mon Sep 17 00:00:00 2001 From: Travis Illig Date: Fri, 8 Mar 2019 14:08:03 -0800 Subject: [PATCH] Updated decorator tests to handle issue #963 caveats. Skipped for now. --- .../Features/Decorators/DecoratorTests.cs | 11 +++++++---- .../Features/Decorators/OpenGenericDecoratorTests.cs | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/test/Autofac.Test/Features/Decorators/DecoratorTests.cs b/test/Autofac.Test/Features/Decorators/DecoratorTests.cs index 81fd4f4b2..c41bc2e8f 100644 --- a/test/Autofac.Test/Features/Decorators/DecoratorTests.cs +++ b/test/Autofac.Test/Features/Decorators/DecoratorTests.cs @@ -13,12 +13,12 @@ public interface IService { } - public interface IDecoratedService : IService + public interface IDecoratedService { IDecoratedService Decorated { get; } } - public class ImplementorA : IDecoratedService + public class ImplementorA : IDecoratedService, IService { public IDecoratedService Decorated => this; } @@ -189,9 +189,12 @@ public void DecoratedRegistrationCanIncludeImplementationType() Assert.IsType(container.Resolve()); } - [Fact] + [Fact(Skip = "Issue #963")] public void DecoratedRegistrationCanIncludeOtherServices() { + // Issue #963 - Make sure IDecoratedService does _not_ derive from + // IService. The idea is that a component may provide multiple + // services but only one of them may be decorated. var builder = new ContainerBuilder(); builder.RegisterType().As().As(); builder.RegisterDecorator(); @@ -204,7 +207,7 @@ public void DecoratedRegistrationCanIncludeOtherServices() Assert.NotNull(decoratedServiceRegistration); Assert.Same(serviceRegistration, decoratedServiceRegistration); - Assert.IsType(container.Resolve()); + Assert.IsType(container.Resolve()); Assert.IsType(container.Resolve()); } diff --git a/test/Autofac.Test/Features/Decorators/OpenGenericDecoratorTests.cs b/test/Autofac.Test/Features/Decorators/OpenGenericDecoratorTests.cs index bca06a1d1..1058c7761 100644 --- a/test/Autofac.Test/Features/Decorators/OpenGenericDecoratorTests.cs +++ b/test/Autofac.Test/Features/Decorators/OpenGenericDecoratorTests.cs @@ -14,12 +14,12 @@ public interface IService { } - public interface IDecoratedService : IService + public interface IDecoratedService { IDecoratedService Decorated { get; } } - public class ImplementorA : IDecoratedService + public class ImplementorA : IDecoratedService, IService { public IDecoratedService Decorated => this; } @@ -186,9 +186,12 @@ public void DecoratedRegistrationCanIncludeImplementationType() Assert.IsType>(container.Resolve>()); } - [Fact] + [Fact(Skip = "Issue #963")] public void DecoratedRegistrationCanIncludeOtherServices() { + // Issue #963 - Make sure IDecoratedService does _not_ derive from + // IService. The idea is that a component may provide multiple + // services but only one of them may be decorated. var builder = new ContainerBuilder(); builder.RegisterGeneric(typeof(ImplementorA<>)).As(typeof(IDecoratedService<>)).As(typeof(IService<>)); builder.RegisterGenericDecorator(typeof(DecoratorA<>), typeof(IDecoratedService<>)); @@ -201,7 +204,7 @@ public void DecoratedRegistrationCanIncludeOtherServices() Assert.NotNull(decoratedServiceRegistration); Assert.Same(serviceRegistration, decoratedServiceRegistration); - Assert.IsType>(container.Resolve>()); + Assert.IsType>(container.Resolve>()); Assert.IsType>(container.Resolve>()); }