Beispiel #1
0
        public void AddHandlerRemove()
        {
            EventHandler [] evs;
            EventHandler    ev  = new EventHandler(EvHandler);
            EventHandler    ev2 = new EventHandler(EvHandler);

            ourCodeActivity ca = new ourCodeActivity();

            evs = ca.ourGetInvocationList <EventHandler> (ourCodeActivity.ExecuteCodeEvent);
            Assert.AreEqual(0, evs.Length, "C1#1");

            ca.AddHandler(ourCodeActivity.ExecuteCodeEvent, ev);
            evs = ca.ourGetInvocationList <EventHandler> (ourCodeActivity.ExecuteCodeEvent);
            Assert.AreEqual(1, evs.Length, "C1#2");
            Assert.AreEqual(ev, evs[0], "C1#3");

            ca.AddHandler(ourCodeActivity.ExecuteCodeEvent, ev);
            evs = ca.ourGetInvocationList <EventHandler> (ourCodeActivity.ExecuteCodeEvent);
            Assert.AreEqual(2, evs.Length, "C1#4");
            Assert.AreEqual(ev, evs[0], "C1#5");
            Assert.AreEqual(ev2, evs[1], "C1#6");
        }