the code of onHandlerStateChanged method  should be the following

private void onHandlerStateChanged(object source, EventArgs args)
        {
            OnHandlerStateChangedWasCalled = true;
        }



On Mar 29, 4:11 pm, Konstantin <[email protected]> wrote:
> Here is test demonstrating the issue
>
>         [Test]
>         public void Test()
>         {
>             var c = new WindsorContainer();
>             var myFacilty = new MyFacilty();
>             c.AddFacility("my", myFacilty);
>             c.Register(Component.For<A>());
>             Assert.AreEqual(HandlerState.WaitingDependency,
> myFacilty.Handlers["Tests.A"].CurrentState);
>             c.Register(Component.For<B>().Instance(new B()));
>             Assert.AreEqual(HandlerState.Valid,
> myFacilty.Handlers["Tests.A"].CurrentState);
>             var a = c.Resolve<A>();
>             Assert.IsTrue(myFacilty.OnHandlerStateChangedWasCalled,
> "OnHandlerStateChanged was not raised");
>         }
>
> //Classes used in test
>
> namespace Tests
> {
>
>     public class MyFacilty : AbstractFacility
>     {
>         public MyFacilty()
>         {
>             Handlers = new Dictionary<string, IHandler>();
>         }
>
>         protected override void Init()
>         {
>             Kernel.ComponentRegistered += KernelOnComponentRegistered;
>         }
>
>         private void KernelOnComponentRegistered(string key, IHandler
> handler)
>         {
>             Handlers.Add(key, handler);
>             if (handler.CurrentState ==
> HandlerState.WaitingDependency)
>             {
>                 handler.OnHandlerStateChanged +=
> onHandlerStateChanged;
>             }
>         }
>
>         private void onHandlerStateChanged(object source, EventArgs
> args)
>         {
>             Console.WriteLine("onHandlerStateChanged");
>         }
>
>         public bool OnHandlerStateChangedWasCalled { get; set; }
>
>         public Dictionary<string, IHandler> Handlers { get; set; }
>     }
>
>     public struct B
>     {
>     }
>
>     public class A
>     {
>         public A(B b)
>         {
>         }
>     }
>
>
>
> }

-- 
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].
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