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