Ejemplo n.º 1
0
        public void WireWithStaticHandler()
        {
            PingSource source = new PingSource();
            InstanceEventHandlerValue wirer
                = new InstanceEventHandlerValue(source, "OnPing");

            wirer.EventName = "Ping";
            wirer.Wire(source, typeof(StaticPingListener));
        }
Ejemplo n.º 2
0
        public void BailsIfMethodDoesntExist()
        {
            PingSource source = new PingSource();
            InstanceEventHandlerValue wirer
                = new InstanceEventHandlerValue(source, "Roo");

            wirer.EventName = "Ping";
            Assert.Throws <FatalObjectException>(() => wirer.Wire(source, typeof(StaticPingListener)));
        }
Ejemplo n.º 3
0
        public void Wire()
        {
            InstanceEventHandlerValue wirer = new InstanceEventHandlerValue();

            wirer.EventName  = "Ping";
            wirer.MethodName = "OnPing";
            PingSource   source = new PingSource();
            PingListener sink   = new PingListener();

            wirer.Wire(source, sink);
            source.OnPing();
            Assert.IsTrue(sink.GotPing, "The event handler did not get notified when the event was raised.");
            Assert.AreEqual(1, sink.PingCount, "The event handler was not get notified exactly once when the event was raised exactly once.");
        }