コード例 #1
0
        public void Context_Inherits_Parent_Injector()
        {
            AddRootToStage();

            parentContext
            .Install(typeof(SupportParentFinderExtension))
            .Install(typeof(TestSupportViewStateWatcherExtension))
            .Install(typeof(ModularityExtension))
            .Configure(new ContextView(parentView));

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

            ContainerRegistry cr = new ContainerRegistry();

            cr.SetParentFinder(new SupportParentFinder());

            parentContext.injector.Map(typeof(ContainerRegistry)).ToValue(cr);
            childContext.injector.Map(typeof(ContainerRegistry)).ToValue(cr);

            cr.AddContainer(parentView);
            cr.AddContainer(childView);

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

            Assert.That(childContext.injector.parent, Is.EqualTo(parentContext.injector));
        }
コード例 #2
0
        public void Mediator_Is_Removed_From_Factory_When_View_Leaves_Stage()
        {
            int    callCount  = 0;
            object actualView = null;

            manager.ViewRemoved += (Action <object>) delegate(object eventView) {
                callCount++;
                actualView = eventView;
            };
            SupportView      view    = new SupportView();
            IMediatorMapping mapping = new MediatorMapping(CreateTypeFilter(new Type[1] {
                typeof(SupportView)
            }), typeof(CallbackMediator));
            object mediator = injector.InstantiateUnmapped(typeof(CallbackMediator));

            container.AddChild(view);
            manager.AddMediator(mediator, view, mapping);
            container.RemoveChild(view);

            Assert.That(callCount, Is.EqualTo(1));
            Assert.That(actualView, Is.EqualTo(view));
        }
コード例 #3
0
        public void mediator_is_created_if_guard_allows_it()
        {
            mediatorMap.Map(typeof(SupportView)).ToMediator(typeof(ExampleMediatorWatcher)).WithGuards(typeof(OnlyIfViewHasChildrenGuard));
            SupportView view = new SupportView();

            view.AddChild(new SupportView());
            mediatorMap.Mediate(view);

            List <string> expectedNotifications = new List <string> {
                "ExampleMediatorWatcher"
            };

            Assert.That(expectedNotifications, Is.EqualTo(mediatorWatcher.Notifications).AsCollection);
        }
コード例 #4
0
        public void Multiple_Depths_Of_Children_Only_Inherit_The_First_Parents_Injector()
        {
            AddRootToStage();

            parentContext
            .Install(typeof(TestSupportViewStateWatcherExtension))
            .Install(typeof(SupportParentFinderExtension))
            .Install(typeof(ModularityExtension))
            .Configure(new ContextView(parentView));

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


            SupportView anotherChildView    = new SupportView();
            IContext    anotherChildContext = new Context()
                                              .Install(typeof(TestSupportViewStateWatcherExtension))
                                              .Install(typeof(StageSyncExtension))
                                              .Install(typeof(ContextViewExtension))
                                              .Install(typeof(ModularityExtension))
                                              .Install(typeof(SupportParentFinderExtension))
                                              .Configure(new ContextView(anotherChildView));


            ContainerRegistry cr = new ContainerRegistry();

            parentContext.injector.Map(typeof(ContainerRegistry)).ToValue(cr);
            childContext.injector.Map(typeof(ContainerRegistry)).ToValue(cr);
            anotherChildContext.injector.Map(typeof(ContainerRegistry)).ToValue(cr);

            cr.AddContainer(parentView);
            cr.AddContainer(childView);
            cr.AddContainer(anotherChildView);

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

            Assert.That(childContext.injector.parent, Is.EqualTo(parentContext.injector));
            Assert.That(anotherChildContext.injector.parent, Is.EqualTo(childContext.injector));
            Assert.That(anotherChildContext.injector.parent, Is.Not.EqualTo(parentContext.injector));
        }
コード例 #5
0
        /*============================================================================*/
        /* Public Functions                                                           */
        /*============================================================================*/

        public void Hook()
        {
            view.AddChild(new SupportView());
        }