public void InjectingMetadata_ForADecoratedInstance_AllowsRetrievingTheImplementationType() { // Arrange var container = ContainerFactory.New(); container.Register<ICommandHandler<RealCommand>, RealCommandHandler>(Lifestyle.Singleton); container.RegisterDecorator( typeof(ICommandHandler<>), typeof(CommandHandlerDecorator<>), Lifestyle.Transient); // Act var service = container.GetInstance<MetadataWrapper<ICommandHandler<RealCommand>>>(); // Assert AssertThat.AreEqual( expectedType: typeof(RealCommandHandler), actualType: service.Metadata.ImplementationType); }
public void ResolvingMetadataAfterVerification_ForADecoratedInstance_AllowsRetrievingTheImplementationType() { // Arrange var container = ContainerFactory.New(); container.Register<ICommandHandler<RealCommand>, RealCommandHandler>(Lifestyle.Singleton); container.RegisterDecorator( typeof(ICommandHandler<>), typeof(CommandHandlerDecorator<>), Lifestyle.Transient); container.Verify(); // Act var metadata = container.GetInstance<DependencyMetadata<ICommandHandler<RealCommand>>>(); // Assert AssertThat.AreEqual( expectedType: typeof(RealCommandHandler), actualType: metadata.ImplementationType); }
private static void _(Type type, Type genericTypeDefinition, Type expected) { Type actual = type.GetClosedTypeOf(genericTypeDefinition); AssertThat.AreEqual(expected, actual); }