1

Closed

DecoratorPredicateContext.ImplementationType returns service type in case the decoratee is not transient or singleton

description

// Arrange
Type expectedImplementationType = typeof(ConcreteCommandHandler);
Type actualImplementationType = null;

var container = new Container();

container.Register<ICommandHandler<ConcreteCommand>, ConcreteCommandHandler>(
    new LifetimeScopeLifestyle());

container.RegisterSingleDecorator(typeof(ICommandHandler<>), 
    typeof(AsyncCommandHandlerProxy<>), c =>
{
    actualImplementationType = c.ImplementationType;
    return true;
});

// Act
container.Verify();

// Assert
Assert.AreEqual(
    expectedImplementationType.ToFriendlyName(), 
    actualImplementationType.ToFriendlyName());
}
The test is expected to succeed, but it will fail, because actualImplementationType is ICommandHandler<ConcreteCommand>.
Closed Apr 10, 2015 at 3:54 PM by dot_NET_Junkie

comments

dot_NET_Junkie wrote Feb 28, 2015 at 4:50 PM

Fixed in changeset c81c6e6b2b372cde137aa7a8dad8e5a2cf83a1e1