public void WireWithInstanceHandler() { StaticEventHandlerValue wirer = new StaticEventHandlerValue(); wirer.EventName = "Ping"; wirer.MethodName = "OnPing"; PingSource source = new PingSource(); Assert.Throws <FatalObjectException>(() => wirer.Wire(source, new PingListener())); }
public void Wire() { PingSource source = new PingSource(); StaticEventHandlerValue wirer = new StaticEventHandlerValue(source, "OnPing"); wirer.EventName = "Ping"; Type sink = typeof(StaticPingListener); wirer.Wire(source, sink); source.OnPing(); Assert.IsTrue(StaticPingListener.GotPing, "The event handler did not get notified when the event was raised."); Assert.AreEqual(1, StaticPingListener.PingCount, "The event handler was not get notified exactly once when the event was raised exactly once."); }