Exemple #1
0
        public void removeMediator_removes_mediator_from_manager()
        {
            SupportView      mediatedItem = new SupportView();
            IMediatorMapping mapping      =
                new MediatorMapping(CreateTypeFilter(new Type[1] {
                typeof(SupportView)
            }), typeof(CallbackMediator));

            injector.Map <IMediatorManager> ().ToValue(manager.Object);
            factory = new MediatorFactory(injector);
            factory.CreateMediators(mediatedItem, typeof(SupportView), new List <IMediatorMapping> {
                mapping
            });
            factory.RemoveMediators(mediatedItem);
            factory.RemoveMediators(mediatedItem);

            manager.Verify(_manager => _manager.RemoveMediator(It.IsAny <CallbackMediator> (), It.Is <object> (arg2 => arg2 == mediatedItem), It.Is <IMediatorMapping> (arg3 => arg3 == mapping)), Times.Once);
        }
Exemple #2
0
        public void removeAllMediators_removes_all_mediators_from_manager()
        {
            SupportView      mediatedItem1 = new SupportView();
            SupportView      mediatedItem2 = new SupportView();
            IMediatorMapping mapping1      =
                new MediatorMapping(CreateTypeFilter(new Type[1] {
                typeof(SupportView)
            }), typeof(CallbackMediator));
            IMediatorMapping mapping2 =
                new MediatorMapping(CreateTypeFilter(new Type[1] {
                typeof(SupportContainer)
            }), typeof(ViewInjectedAsRequestedMediator));

            injector.Map <IMediatorManager> ().ToValue(manager.Object);
            factory = new MediatorFactory(injector);
            factory.CreateMediators(mediatedItem1, typeof(SupportView), new List <IMediatorMapping> {
                mapping1, mapping2
            });
            factory.CreateMediators(mediatedItem2, typeof(SupportView), new List <IMediatorMapping> {
                mapping1, mapping2
            });
            factory.RemoveAllMediators();

            manager.Verify(_manager => _manager.RemoveMediator(
                               It.IsAny <CallbackMediator>(),
                               It.Is <object>(arg2 => arg2 == mediatedItem1),
                               It.Is <IMediatorMapping>(arg3 => arg3 == mapping1)), Times.Once);

            manager.Verify(_manager => _manager.RemoveMediator(
                               It.IsAny <ViewInjectedAsRequestedMediator>(),
                               It.Is <object>(arg2 => arg2 == mediatedItem1),
                               It.Is <IMediatorMapping>(arg3 => arg3 == mapping2)), Times.Once);

            manager.Verify(_manager => _manager.RemoveMediator(
                               It.IsAny <CallbackMediator>(),
                               It.Is <object>(arg2 => arg2 == mediatedItem2),
                               It.Is <IMediatorMapping>(arg3 => arg3 == mapping1)), Times.Once);

            manager.Verify(_manager => _manager.RemoveMediator(
                               It.IsAny <ViewInjectedAsRequestedMediator>(),
                               It.Is <object>(arg2 => arg2 == mediatedItem2),
                               It.Is <IMediatorMapping>(arg3 => arg3 == mapping2)), Times.Once);
        }
Exemple #3
0
 public void Setup()
 {
     injector = new RobotlegsInjector();
     factory  = new MediatorFactory(injector);
     manager  = new Mock <IMediatorManager> ();
 }