public void Registered_Delegate_prefered_over_factory() { var foo = new DisposableFoo(); container.Register(Component.For<DisposableFoo>().LifeStyle.Transient, Component.For<Func<int, DisposableFoo>>().Instance(i => foo), Component.For<UsesDisposableFooDelegate>().LifeStyle.Transient); var dependsOnFoo = container.Resolve<UsesDisposableFooDelegate>(); var otherFoo = dependsOnFoo.GetFoo(); Assert.AreSame(foo, otherFoo); }
public UsesDisposableFoo(DisposableFoo foo) { this.foo = foo; }