public void WhenDifferentSignalsAreRegisteredAndPerformCallWithOne_OnlyCallToTheAssociateCallbacksOfThisSignal()
        {
            var eventDispatcher = new EventDispatcherService();
            var callback1       = Substitute.For <SignalDelegate>();
            var callback2       = Substitute.For <SignalDelegate>();

            eventDispatcher.Subscribe <TestSignal>(callback1);
            eventDispatcher.Subscribe <TestSignal2>(callback2);

            var testSignal2 = new TestSignal2(123);

            eventDispatcher.Dispatch(testSignal2);

            callback1.DidNotReceive();
            callback2.Received().Invoke(testSignal2);
        }
        public void WhenMultipleCallbacksAreSubscribedAndPerformCall_CallToTheCallbacks()
        {
            var eventDispatcher = new EventDispatcherService();
            var callback1       = Substitute.For <SignalDelegate>();
            var callback2       = Substitute.For <SignalDelegate>();

            eventDispatcher.Subscribe <TestSignal>(callback1);
            eventDispatcher.Subscribe <TestSignal>(callback2);

            var testSignal = new TestSignal("SomeData");

            eventDispatcher.Dispatch(testSignal);

            callback1.Received().Invoke(testSignal);
            callback2.Received().Invoke(testSignal);
        }
예제 #3
0
        public OrderListSystem()
        {
            EventDispatcherService <GameEntity> .Subscribe(this, Constants.EVENT_ENTITY_START_DRAG);

            EventDispatcherService <GameEntity> .Subscribe(this, Constants.EVENT_ENTITY_CANCEL_DRAG);
        }