Exemplo n.º 1
0
        public void HandleDelegate_Add_AddsOneListener()
        {
            SignalMediator mediator     = injectionBinder.GetInstance <SignalMediator>();
            var            oneArgSignal = injectionBinder.GetInstance <OneArgSignal>();

            Assert.AreEqual(1, oneArgSignal.listener.GetInvocationList().Length);
            binder.TestHandleDelegate(mediator, mediator.GetType(), true);
            Assert.AreEqual(2, oneArgSignal.listener.GetInvocationList().Length);
        }
Exemplo n.º 2
0
        public void HandleDelegate_Add_ListenerCalledOnDispatch()
        {
            SignalMediator mediator     = injectionBinder.GetInstance <SignalMediator>();
            var            oneArgSignal = injectionBinder.GetInstance <OneArgSignal>();

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

            Assert.AreEqual(0, SignalMediator.Value);
            oneArgSignal.Dispatch(2);
            Assert.AreEqual(2, SignalMediator.Value);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
        }