public void Modularity_Dispatcher_Should_Broadcast_When_Child_Context_Is_Added()
        {
            int eventFireCount = 0;

            AddRootToStage();
            root.AddChild(parentView);
            root.AddChild(childView);
            parentContext
            .Install(typeof(EventDispatcherExtension))
            .Install(typeof(TestSupportViewStateWatcherExtension))
            .Install(typeof(ModularityExtension))
            .Install(typeof(ViewManagerExtension))
            .Install(typeof(SupportParentFinderExtension))
            .Configure(typeof(ContextViewListenerConfig))
            .Configure(new ContextView(parentView));

            GetModularityEventDispatcher().AddEventListener(ModularContextEvent.Type.CONTEXT_ADD, delegate() {
                eventFireCount++;
            });

            IViewManager viewManager = parentContext.injector.GetInstance(typeof(IViewManager)) as IViewManager;

            viewManager.AddContainer(childView);

            childContext
            .Install(typeof(TestSupportViewStateWatcherExtension))
            .Install(typeof(ModularityExtension))
            .Install(typeof(SupportParentFinderExtension))
            .Configure(new ContextView(childView));

            Assert.That(eventFireCount, Is.EqualTo(1));
        }
        public void Modularity_Dispatcher_Should_Broadcast_Add_Child_Before_Child_Context_Is_Initialized()
        {
            bool eventFired = false;
            bool childContextUninitialzied = false;

            AddRootToStage();
            root.AddChild(parentView);
            root.AddChild(childView);
            parentContext
            .Install(typeof(EventDispatcherExtension))
            .Install(typeof(TestSupportViewStateWatcherExtension))
            .Install(typeof(ModularityExtension))
            .Install(typeof(ViewManagerExtension))
            .Install(typeof(SupportParentFinderExtension))
            .Configure(typeof(ContextViewListenerConfig))
            .Configure(new ContextView(parentView));

            GetModularityEventDispatcher().AddEventListener(ModularContextEvent.Type.CONTEXT_ADD, delegate() {
                eventFired = true;
                childContextUninitialzied = childContext.Uninitialized;
            });

            IViewManager viewManager = parentContext.injector.GetInstance(typeof(IViewManager)) as IViewManager;

            viewManager.AddContainer(childView);

            childContext
            .Install(typeof(TestSupportViewStateWatcherExtension))
            .Install(typeof(ModularityExtension))
            .Install(typeof(SupportParentFinderExtension))
            .Configure(new ContextView(childView));

            Assert.That(eventFired, Is.True);
            Assert.That(childContextUninitialzied, Is.True);
        }
        public void Child_Added_To_ViewManager_Inherits_Injector()
        {
            AddRootToStage();
            parentContext
            .Install(typeof(TestSupportViewStateWatcherExtension))
            .Install(typeof(ModularityExtension))
            .Install(typeof(ViewManagerExtension))
            .Install(typeof(SupportParentFinderExtension))
            .Configure(typeof(ContextViewListenerConfig))
            .Configure(new ContextView(parentView));

            IViewManager viewManager = parentContext.injector.GetInstance(typeof(IViewManager)) as IViewManager;

            viewManager.AddContainer(childView);

            childContext
            .Install(typeof(TestSupportViewStateWatcherExtension))
            .Install(typeof(ModularityExtension))
            .Install(typeof(SupportParentFinderExtension))
            .Configure(new ContextView(childView));

            root.AddChild(parentView);
            root.AddChild(childView);

            Assert.That(childContext.injector.parent, Is.EqualTo(parentContext.injector));
        }