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); }
// 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 }); }
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); }
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); }
public void WhenInvokeEventWithNoHandlers_DontThrowAnException() { //Arrange & Act & Assert Assert.DoesNotThrow(() => Courier.Send(new CourierEvent())); }