Indeed, adding IDisposable makes the test pass. Many thanks, Krzysztof

вторник, 6 ноября 2012 г., 11:04:17 UTC+2 пользователь Krzysztof Koźmic 
написал:
>
> Vladimir, 
>
> your interceptor wasn't released, because it was never tracked in the 
> first place.
> It's not disposable, has no custom decommission steps, and no dependencies 
> that requires decommission.
>
>
> There's no reason for it to be tracked.
>
>
> -- 
> Krzysztof Kozmic
>
> On Tuesday, 6 November 2012 at 6:59 PM, Vladimir Okhotnikov wrote:
>
> Hi
>
> I have a following failing test in an empty project with Windsor 3.1 from 
> NuGet:
>
> [Test]
> public void TransientInterceptor()
> {
> var interceptorCreated = false;
> var interceptorReleased = false;
>
> var c = new DefaultKernel();
> c.ComponentCreated += (model, instance) =>
> {
> if (model.Implementation == typeof(AnInterceptor))
> {
> interceptorCreated = true;
> }
> };
> c.ComponentDestroyed += (model, instance) =>
> {
> if (model.Implementation == typeof(AnInterceptor))
> {
> interceptorReleased = true;
> }
> };
>
> c.Register(
> Component.For<AComponent>().LifeStyle.Transient,
> Component.For<AnInterceptor>().LifeStyle.Transient);
>
> var component = c.Resolve<AComponent>();
> c.ReleaseComponent(component);
>
> Assert.IsTrue(interceptorCreated);
> Assert.IsTrue(interceptorReleased);
> }
>
> public class AnInterceptor : IInterceptor
> {
> public void Intercept(IInvocation invocation)
> {
> invocation.Proceed();
> }
> }
>
> [Interceptor(typeof(AnInterceptor))]
> public class AComponent
> {
> public virtual void Intercepted() 
> {
> }
> }
>
> The test fails on the very last line, i.e. ComponentDestroyed for the 
> interceptor is never being called. Is it a bug or am I missing something?
>
> Regards,
> Vladimir Okhotnikov
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Castle Project Users" group.
> To post to this group, send email to 
> [email protected]<javascript:>
> .
> To unsubscribe from this group, send email to 
> [email protected] <javascript:>.
> For more options, visit this group at 
> http://groups.google.com/group/castle-project-users?hl=en.
>
>  
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/castle-project-users/-/nYUpHVTfsegJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

Reply via email to