Пример #1
0
        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()));
        }
Пример #2
0
        public void Instantiation()
        {
            PingSource source = new PingSource();
            StaticEventHandlerValue wirer
                = new StaticEventHandlerValue(source, "OnPing");

            Assert.IsNotNull(wirer.Source);
            Assert.AreEqual("OnPing", wirer.MethodName);
            Assert.IsTrue(wirer.ToString().IndexOf(wirer.MethodName) > 0);
        }
Пример #3
0
        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.");
        }