Beispiel #1
0
        public void WhenInvokeMultipleEventsWithHandler_CallHandlerMethod()
        {
            bool calledBegin    = false;
            bool calledComplete = false;

            void HandleBeginEvent(CourierEventBase reiEvent)
            {
                calledBegin = true;
            }

            void HandleCompleteEvent(CourierEventBase reiEvent)
            {
                calledComplete = true;
            }

            //Arrange
            Courier.Register <BeginEvent>(HandleBeginEvent);
            Courier.Register <CompleteEvent>(HandleCompleteEvent);

            //Act
            Courier.Send(new BeginEvent());
            Courier.Send(new CompleteEvent());

            //Assert
            Assert.IsTrue(calledBegin && calledComplete);
        }
Beispiel #2
0
        // Start is called before the first frame update
        void Start()
        {
            Courier.Register <BattleEvent>(Handler_One);
            Courier.Register <BattleEvent>(Handler_Two);
            Courier.Send(new BattleEvent()
            {
                id = 1
            });

            Courier.Unregister <BattleEvent>(Handler_One);
            Courier.Send(new BattleEvent()
            {
                id = 3
            });
        }
Beispiel #3
0
        public void WhenInvokeEventWithHandler_CallHandlerMethod()
        {
            bool called = false;

            void HandlerSample(CourierEventBase reiEvent)
            {
                called = true;
            }

            //Arrange
            Courier.Register <CourierEvent>(HandlerSample);

            //Act
            Courier.Send(new CourierEvent());

            //Assert
            Assert.IsTrue(called);
        }
Beispiel #4
0
        public void WhenAddHandlerTwiceAndInvokeEvent_CallHandlerOnce()
        {
            int calledCount = 0;

            void HandleEvent(CourierEventBase reiEvent)
            {
                calledCount++;
            }

            //Arrange
            Courier.Register <CourierEvent>(HandleEvent);
            Courier.Register <CourierEvent>(HandleEvent);

            //Act
            Courier.Send <CourierEvent>();

            //Assert
            Assert.IsTrue(calledCount == 1);
        }
Beispiel #5
0
 public void WhenInvokeEventWithNoHandlers_DontThrowAnException()
 {
     //Arrange & Act & Assert
     Assert.DoesNotThrow(() => Courier.Send(new CourierEvent()));
 }