public void AttachEvent() { HtmlObject ho = HtmlPage.Document.CreateElement("div"); EventHandler eh = new EventHandler(Handler); Assert.IsTrue(ho.AttachEvent("a", eh), "1"); // twice (same handler) Assert.IsTrue(ho.AttachEvent("a", eh), "2"); // again (different handler) Assert.IsTrue(ho.AttachEvent("a", new EventHandler <HtmlEventArgs> (GenericHandler)), "3"); }
public void AttachEvent_Validations() { HtmlObject ho = HtmlPage.Document.CreateElement("div"); EventHandler eh = new EventHandler(Handler); Assert.Throws <ArgumentNullException> (delegate { ho.AttachEvent(null, eh); }, "AttachEvent(null,EventHandler)"); Assert.Throws <ArgumentException> (delegate { ho.AttachEvent(String.Empty, eh); }, "AttachEvent(Empty,EventHandler)"); Assert.Throws <ArgumentNullException> (delegate { ho.AttachEvent("a", (EventHandler)null); }, "AttachEvent(string,null"); Assert.Throws <ArgumentException> (delegate { ho.AttachEvent("a\0b", eh); }, "AttachEvent(string-with-null,EventHandler"); EventHandler <HtmlEventArgs> geh = new EventHandler <HtmlEventArgs> (GenericHandler); Assert.Throws <ArgumentNullException> (delegate { ho.AttachEvent(null, geh); }, "AttachEvent(null,EventHandler<HtmlEventArgs>)"); Assert.Throws <ArgumentException> (delegate { ho.AttachEvent(String.Empty, geh); }, "AttachEvent(Empty,EventHandler<HtmlEventArgs>)"); Assert.Throws <ArgumentNullException> (delegate { ho.AttachEvent("a", (EventHandler <HtmlEventArgs>)null); }, "AttachEvent(string,EventHandler<HtmlEventArgs>null)"); Assert.Throws <ArgumentException> (delegate { ho.DetachEvent("a\0b", geh); }, "AttachEvent(string-with-null,EventHandler<HtmlEventArgs>"); }
private void Add(EventHandler handler) { _object.AttachEvent(_name, handler); }