public void AddFunctionAsPersonEventHandler() { Person person = new Person() { FirstName = "Adam" }; NameListener listener = new NameListener(); ObjectUtilities.AddHandler(person, "NameEvent", listener, null); person.GetName(); Assert.AreEqual(4, listener.Length); Assert.AreEqual("Adam", listener.Name); }
public void AddEventHandlerToPerson() { NameListener listener = new NameListener(); Person person = new Person() { FirstName = "Adam" }; FunctionWrapper<string, int, MyEvent> wrapper = new FunctionWrapper<string, int, MyEvent>(listener, null); typeof(Person).GetEvent("NameEvent").AddEventHandler(person, wrapper.CreateFunctionDelegate()); person.GetName(); Assert.AreEqual(4, listener.Length); Assert.AreEqual("Adam", listener.Name); }
public void AddEventHandlerToPerson() { NameListener listener = new NameListener(); Person person = new Person() { FirstName = "Adam" }; FunctionWrapper <string, int, MyEvent> wrapper = new FunctionWrapper <string, int, MyEvent>(listener, null); typeof(Person).GetEvent("NameEvent").AddEventHandler(person, wrapper.CreateFunctionDelegate()); person.GetName(); Assert.AreEqual(4, listener.Length); Assert.AreEqual("Adam", listener.Name); }