Ejemplo n.º 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()
            {
            };
        }
Ejemplo n.º 2
0
 public void TestEventReuse()
 {
     MyTestEvent.Invoke(_fixed);
 }
Ejemplo n.º 3
0
 public void TestEventObservable()
 {
     MyTestEvent.Invoke(_fixed);
 }
Ejemplo n.º 4
0
 public void TestEvent()
 {
     MyTestEvent.Invoke(new TestClass());
 }