public static void test_add_remove_event() { var obj = new Dummy.TestObject(); bool called = true; EventHandler <Dummy.TestObjectEvtWithIntEventArgs> evtCb = (object sender, Dummy.TestObjectEvtWithIntEventArgs e) => { called = true; }; obj.EvtWithIntEvent += evtCb; obj.EmitEventWithInt(42); Test.Assert(called); called = false; obj.EvtWithIntEvent -= evtCb; obj.EmitEventWithInt(42); Test.Assert(!called); }
public static void eina_error_event_raise_exception() { // An event whose managed delegate generates an exception // must set an eina_error so it can be reported back to // the managed code var obj = new Dummy.TestObject(); Listener listener = new Listener(); obj.EvtWithIntEvt += listener.callback; Test.AssertRaises <Efl.EflException>(() => { obj.EmitEventWithInt(2); }); }
public static void event_with_int_payload() { var obj = new Dummy.TestObject(); int received_int = 0; obj.EvtWithIntEvent += (object sender, Dummy.TestObjectEvtWithIntEventArgs e) => { received_int = e.arg; }; obj.EmitEventWithInt(-1984); Test.AssertEquals(-1984, received_int); }
public static void event_in_init_callback() { int received = 0; int sent = 42; var obj = new Dummy.TestObject(); obj.EvtWithIntEvt += (object sender, Dummy.TestObjectEvtWithIntEvt_Args e) => { received = e.arg; }; obj.EmitEventWithInt(sent); Test.AssertEquals(sent, received); }