Hi there

I am testing different lifestyle of WindsorContainer. something Bizarre 
happened.  

(.net 4.0, castle.windsor 3.x)

here is my test classes 

public class Holder {
                        public Disposable DisposableReference {get;set;}
                        public NonDisposable NonDisposableReference {get; set;}
                }
 
                /// <summary>
                /// disposable test class
                /// </summary>
                public class Disposable : IDisposable {
                        public void Dispose(){
                                GC.SuppressFinalize(this);
                        }
                } 
 
                /// <summary>
                /// non disposable test class
                /// </summary>
                public class NonDisposable{
                        
                }



Unit Test - A:


[TestMethod]
                public void 
DefaultContainerTracksTransientWithDisposableReference() {
 
                        WeakReference weakHolder;
 
                    var container = new WindsorContainer();
 
                
container.Register(Component.For(typeof(Holder)).Named("holder").LifeStyle.Is(LifestyleType.Transient));
                
container.Register(Component.For(typeof(Disposable)).Named("disposable").LifeStyle.Is(LifestyleType.Transient));
 
 
                weakHolder = new WeakReference(container.Resolve<Holder>());
 
                
Assert.IsNotNull(((Holder)weakHolder.Target).DisposableReference);
                Assert.IsTrue(weakHolder.IsAlive);
 
                GC.Collect();
                Assert.IsTrue(weakHolder.IsAlive);
                    container.Dispose();
 
                }


Unit Test - B:

[TestMethod]
                public void 
DefaultContainerTracksTransientWithSingletonDisposableReference() {
 
                        WeakReference weakHolder;
 
                    var container = new WindsorContainer();
                
container.Register(Component.For(typeof(Holder)).Named("holder").LifeStyle.Is(LifestyleType.Transient));
                
container.Register(Component.For(typeof(Disposable)).Named("disposable").LifeStyle.Is(LifestyleType.Singleton));
 
 
                weakHolder = new WeakReference(container.Resolve<Holder>());
 
                
Assert.IsNotNull(((Holder)weakHolder.Target).DisposableReference);
                Assert.IsTrue(weakHolder.IsAlive);
                GC.Collect();
                
Assert.IsTrue(container.Kernel.ReleasePolicy.HasTrack(weakHolder.Target));
                Assert.IsTrue(weakHolder.IsAlive);
            container.Dispose();
        }


when run these two unit tests, A passed, B failed. 


According to http://docs.castleproject.org/Windsor.Release-Policy.ashx, Both A 
and B should pass, Am i missing something or it's a bug?


Cheers, Bing


-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/castle-project-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to