Пример #1
0
        public void Test()
        {
            var eventOwner = new EventOwner();

            int count1 = 0;

            eventOwner.Action1 = () => count1++;
            eventOwner.InvokeAction1();
            Assert.AreEqual(1, count1);

            int count2 = 0;

            eventOwner.Action1 = () => count2++;
            eventOwner.InvokeAction1();
            Assert.AreEqual(1, count1);
            Assert.AreEqual(1, count2);
        }
Пример #2
0
        public void Test2()
        {
            var eventOwner = new EventOwner();

            eventOwner.Event1 += OnEventOwnerEvent1;
            eventOwner.Event1 += OnEventOwnerEvent1;

            eventOwner.RaiseEvent1();
            Assert.AreEqual(2, EventOwnerEvent1Count);

            eventOwner.Event1 -= OnEventOwnerEvent1;
            eventOwner.RaiseEvent1();
            Assert.AreEqual(3, EventOwnerEvent1Count);

            eventOwner.Event1 -= OnEventOwnerEvent1;
            eventOwner.RaiseEvent1();
            Assert.AreEqual(3, EventOwnerEvent1Count);
        }