Ejemplo n.º 1
0
        public void HandleDelegate_AddTwo_BothListenersAreAdded()
        {
            injectionBinder.Bind <SignalMediatorTwo>().ToSingleton();

            SignalMediator    mediator    = injectionBinder.GetInstance <SignalMediator>();
            SignalMediatorTwo mediatorTwo = injectionBinder.GetInstance <SignalMediatorTwo>();
            var oneArgSignal = injectionBinder.GetInstance <OneArgSignal>();

            Assert.AreEqual(1, oneArgSignal.listener.GetInvocationList().Length);

            binder.TestHandleDelegate(mediator, mediator.GetType(), true);
            binder.TestHandleDelegate(mediatorTwo, mediatorTwo.GetType(), true);
            Assert.AreEqual(3, oneArgSignal.listener.GetInvocationList().Length);
        }
Ejemplo n.º 2
0
        public void HandleDelegate_AddTwo_BothListenersCalledOnDispatch()
        {
            injectionBinder.Bind <SignalMediatorTwo>().ToSingleton();

            SignalMediator    mediator    = injectionBinder.GetInstance <SignalMediator>();
            SignalMediatorTwo mediatorTwo = injectionBinder.GetInstance <SignalMediatorTwo>();
            var oneArgSignal = injectionBinder.GetInstance <OneArgSignal>();

            binder.TestHandleDelegate(mediator, mediator.GetType(), true);
            binder.TestHandleDelegate(mediatorTwo, mediatorTwo.GetType(), true);

            Assert.AreEqual(0, SignalMediator.Value);
            Assert.AreEqual(0, SignalMediatorTwo.Value);
            oneArgSignal.Dispatch(2);
            Assert.AreEqual(2, SignalMediator.Value);
            Assert.AreEqual(2, SignalMediatorTwo.Value);
        }
Ejemplo n.º 3
0
        public void HandleDelegate_Remove_AddOrderDoesntMatter()
        {
            injectionBinder.Bind <SignalMediatorTwo>().ToSingleton();

            SignalMediator    mediator    = injectionBinder.GetInstance <SignalMediator>();
            SignalMediatorTwo mediatorTwo = injectionBinder.GetInstance <SignalMediatorTwo>();
            var oneArgSignal = injectionBinder.GetInstance <OneArgSignal>();

            binder.TestHandleDelegate(mediatorTwo, mediatorTwo.GetType(), true);
            binder.TestHandleDelegate(mediator, mediator.GetType(), true);


            binder.TestHandleDelegate(mediator, mediator.GetType(), false);

            oneArgSignal.Dispatch(2);


            //remove
            Assert.AreEqual(0, SignalMediator.Value);
            Assert.AreEqual(2, SignalMediatorTwo.Value);
        }