示例#1
0
        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!");
 }
 private void OnMyTest(MyTestEvent myTestEvent)
 {
     MyTestEventHandleCount++;
     EventIds.Add(myTestEvent.Sequence);
 }
示例#6
0
 public void TestEventObservable()
 {
     MyTestEvent.Invoke(_fixed);
 }
示例#7
0
 public void TestEventReuse()
 {
     MyTestEvent.Invoke(_fixed);
 }
示例#8
0
 public void TestEvent()
 {
     MyTestEvent.Invoke(new TestClass());
 }