public void Invoking_an_event_when_there_are_no_subscribers_results_in_an_error() { Assert.Throws <NullReferenceException>(() => MyTestEvent.Invoke()); //You can Elvis operator your way to glory to help avoid exceptions. Assert.DoesNotThrow(() => MyTestEvent?.Invoke()); MyTestEvent += DummyAction; MyTestEvent.Invoke(); MyTestEvent -= DummyAction; void DummyAction() { }; }
private void OnMyTest(MyTestEvent myTestEvent) { MyTestEventHandleCount++; EventIds.Add(myTestEvent.Sequence); }
private void GlobalEventFunction(MyTestEvent ev) { //Debug.Log("global event!"); }
private void LocalEventFunction(MyTestEvent ev) { //Debug.Log("local event!"); }
public void TestEventObservable() { MyTestEvent.Invoke(_fixed); }
public void TestEventReuse() { MyTestEvent.Invoke(_fixed); }
public void TestEvent() { MyTestEvent.Invoke(new TestClass()); }